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

Fix static_mut_ref warning #16

Merged
merged 1 commit into from
Jan 10, 2024
Merged

Fix static_mut_ref warning #16

merged 1 commit into from
Jan 10, 2024

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Jan 10, 2024

New in nightly-2024-01-10 due to rust-lang/rust#117556.

warning: shared reference of mutable static is discouraged
   --> src/lib.rs:170:29
    |
170 |         let argv = unsafe { &ARGV };
    |                             ^^^^^ shared reference of mutable static
    |
    = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
    = note: reference of mutable static is a hard error from 2024 edition
    = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
    = note: `#[warn(static_mut_ref)]` on by default
help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer
    |
170 |         let argv = unsafe { addr_of!(ARGV) };
    |                             ~~~~~~~~~~~~~~

    warning: shared reference of mutable static is discouraged
       --> src/lib.rs:170:29
        |
    170 |         let argv = unsafe { &ARGV };
        |                             ^^^^^ shared reference of mutable static
        |
        = note: for more information, see issue #114447 <rust-lang/rust#114447>
        = note: reference of mutable static is a hard error from 2024 edition
        = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior
        = note: `#[warn(static_mut_ref)]` on by default
    help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer
        |
    170 |         let argv = unsafe { addr_of!(ARGV) };
        |                             ~~~~~~~~~~~~~~
@dtolnay dtolnay merged commit 64b80ef into master Jan 10, 2024
23 checks passed
@dtolnay dtolnay deleted the staticmut branch January 10, 2024 02:44
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

Successfully merging this pull request may close these issues.

1 participant