Skip to content

Commit 0c9b3ec

Browse files
authored
Rollup merge of rust-lang#47425 - EdSchouten:immutable-tls, r=nikomatsakis
Properly pass down immutability info for thread-locals. For thread-locals we call into cat_rvalue_node() to create a CMT (Category, Mutability, Type) that always has McDeclared. This is incorrect for thread-locals that don't have the 'mut' keyword; we should use McImmutable there. Extend cat_rvalue_node() to have an additional mutability parameter. Fix up all the callers to make use of that function. Also extend one of the existing unit tests to cover this. Fixes: rust-lang#47053
2 parents 116fb72 + e47cc69 commit 0c9b3ec

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test for issue #47053
12+
13+
#![feature(nll)]
14+
#![feature(thread_local)]
15+
16+
#[thread_local]
17+
static FOO: isize = 5;
18+
19+
fn main() {
20+
FOO = 6; //~ ERROR cannot assign to immutable item `FOO` [E0594]
21+
}

0 commit comments

Comments
 (0)