2017-08-08 10:22:51 -05:00
|
|
|
// Copyright 2017 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.
|
|
|
|
|
2017-12-10 09:11:02 -06:00
|
|
|
// revisions: ast mir
|
|
|
|
//[mir]compile-flags: -Z borrowck=mir
|
|
|
|
|
2017-08-08 10:22:51 -05:00
|
|
|
#![feature(thread_local)]
|
|
|
|
|
|
|
|
#[thread_local]
|
|
|
|
static FOO: u8 = 3;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let a = &FOO;
|
2017-12-10 09:11:02 -06:00
|
|
|
//[ast]~^ ERROR borrowed value does not live long enough
|
|
|
|
//[ast]~| does not live long enough
|
|
|
|
//[ast]~| NOTE borrowed value must be valid for the static lifetime
|
2017-08-08 10:22:51 -05:00
|
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
println!("{}", a);
|
|
|
|
});
|
2017-12-10 09:11:02 -06:00
|
|
|
} //[ast]~ temporary value only lives until here
|
|
|
|
//[mir]~^ ERROR borrowed value does not live long enough
|