Skip to content

Commit

Permalink
Rollup merge of rust-lang#47425 - EdSchouten:immutable-tls, r=nikomat…
Browse files Browse the repository at this point in the history
…sakis

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
  • Loading branch information
kennytm authored Jan 23, 2018
2 parents 116fb72 + e47cc69 commit 0c9b3ec
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs
Original file line number Diff line number Diff line change
@@ -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]
}

0 comments on commit 0c9b3ec

Please sign in to comment.