diff options
| author | kennytm <kennytm@gmail.com> | 2018-01-23 17:03:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-23 17:03:34 +0800 |
| commit | 0c9b3ec5b0669be0d61f970c190fdaee3460fe74 (patch) | |
| tree | cf4f53d64f7123bf923eb5e5db888c6565e4cffc | |
| parent | 116fb72d3db430c431ffbc9f9e8981529eea804b (diff) | |
| parent | e47cc69697b47f69d18d3c767b136c987a943645 (diff) | |
| download | rust-0c9b3ec5b0669be0d61f970c190fdaee3460fe74.tar.gz rust-0c9b3ec5b0669be0d61f970c190fdaee3460fe74.zip | |
Rollup merge of #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: #47053
| -rw-r--r-- | src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs b/src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs new file mode 100644 index 00000000000..c7dc84c1a91 --- /dev/null +++ b/src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #47053 + +#![feature(nll)] +#![feature(thread_local)] + +#[thread_local] +static FOO: isize = 5; + +fn main() { + FOO = 6; //~ ERROR cannot assign to immutable item `FOO` [E0594] +} |
