Skip to content

Fails to compile with unsafe symbols #11

@notpeelz

Description

@notpeelz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions