]> git.lizzy.rs Git - rust.git/blob - src/test/ui/thread-local-mutation.rs
Merge commit 'a8385522ade6f67853edac730b5bf164ddb298fd' into simd-remove-autosplats
[rust.git] / src / test / ui / thread-local-mutation.rs
1 // Regression test for #54901: immutable thread locals could be mutated. See:
2 // https://github.com/rust-lang/rust/issues/29594#issuecomment-328177697
3 // https://github.com/rust-lang/rust/issues/54901
4
5 #![feature(thread_local)]
6
7 #[thread_local]
8 static S: &str = "before";
9
10 fn set_s() {
11     S = "after"; //~ ERROR cannot assign to immutable
12 }
13
14 fn main() {
15     println!("{}", S);
16     set_s();
17     println!("{}", S);
18 }