Skip to content

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
@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.

2 participants