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

Fails to compile with unsafe symbols #11

Open
notpeelz opened this issue Mar 26, 2023 · 0 comments
Open

Fails to compile with unsafe symbols #11

notpeelz opened this issue Mar 26, 2023 · 0 comments

Comments

@notpeelz
Copy link

Given this code:

static mut TEST: u8 = 0;

fn main() {
    println!("{}", ::nameof::name_of!(TEST));
}

the compiler fails with this error:

error[E0133]: use of mutable static is unsafe and requires unsafe function or block
 --> src/main.rs:4:20
  |
4 |     println!("{}", ::nameof::name_of!(TEST));
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^ use of mutable static
  |
  = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
  = note: this error originates in the macro `::nameof::name_of` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0133`.
error: could not compile `bug-repro-rust-nameof-unsafe` due to previous error
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