]> git.proxmox.com Git - rustc.git/blob - src/test/ui/thread-local-mutation.rs
New upstream version 1.67.1+dfsg1
[rustc.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 }