Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suppress "creating a shared reference to mutable static is discouraged" warnings #27

Open
Dicklessgreat opened this issue Dec 19, 2024 · 0 comments

Comments

@Dicklessgreat
Copy link
Owner

Dicklessgreat commented Dec 19, 2024

The following warning messages have been observed when I build this project:

warning: creating a shared reference to mutable static is discouraged
  --> src/audio.rs:89:17
   |
89 |                 TX_BUFFER.initialize_all_copied(0);
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
   = note: `#[warn(static_mut_refs)]` on by default

warning: creating a shared reference to mutable static is discouraged
  --> src/audio.rs:90:34
   |
90 |                 let (ptr, len) = TX_BUFFER.get_ptr_len();
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

from discord discussion:
Corvus Prudens says:
This will probably take a little time to be resolved in the general ecosystem
really what we need as a direct replacement is SyncUnsafeCell, but that's currently unstable
(of course, for full safety, we have many options that introduce a bit of runtime checking like embedded mutexes)

@Dicklessgreat Dicklessgreat changed the title suppress "creating a shared reference to mutable static is discouraged" suppress "creating a shared reference to mutable static is discouraged" warnings Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant