]> git.lizzy.rs Git - rust.git/blob - src/test/ui/thread-local-mutation.rs
Merge commit 'dbee13661efa269cb4cd57bb4c6b99a19732b484' into sync_cg_clif-2020-12-27
[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 }