Skip to content

Commit ec08596

Browse files
committed
Rollup merge of #54367 - spastorino:add-thread-local-static-borrow-test, r=pnkfelix
Add regression test for thread local static mut borrows FIXME(#54366) - We probably shouldn't allow `#[thread_local] static mut` to get a `'static` lifetime, but for now, we should at least test the behavior that `rustc` currently has.
2 parents e76ca54 + ae42e53 commit ec08596

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2016 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+
// run-pass
12+
//
13+
// FIXME(#54366) - We probably shouldn't allow #[thread_local] static mut to get a 'static lifetime.
14+
15+
#![feature(nll)]
16+
#![feature(thread_local)]
17+
18+
#[thread_local]
19+
static mut X1: u64 = 0;
20+
21+
struct S1 {
22+
a: &'static mut u64,
23+
}
24+
25+
impl S1 {
26+
fn new(_x: u64) -> S1 {
27+
S1 {
28+
a: unsafe { &mut X1 },
29+
}
30+
}
31+
}
32+
33+
fn main() {
34+
S1::new(0).a;
35+
}

0 commit comments

Comments
 (0)