rust/tests/ui/thread-local/thread-local-mutation.rs
jyn 01b75e20f2 Move some UI tests into subdirectories
to avoid going over the existing limit now that the ui-fulldeps tests have
been moved to ui.
2023-04-02 19:42:30 -04:00

19 lines
416 B
Rust

// Regression test for #54901: immutable thread locals could be mutated. See:
// https://github.com/rust-lang/rust/issues/29594#issuecomment-328177697
// https://github.com/rust-lang/rust/issues/54901
#![feature(thread_local)]
#[thread_local]
static S: &str = "before";
fn set_s() {
S = "after"; //~ ERROR cannot assign to immutable
}
fn main() {
println!("{}", S);
set_s();
println!("{}", S);
}