Auto merge of #46100 - KiChjang:mass-dead-check, r=nikomatsakis
Kill the storage for all locals on returning terminators Fixes #45704.
This commit is contained in:
commit
2ca00a9489
6 changed files with 126 additions and 2 deletions
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
||||
|
||||
fn cplusplus_mode(x: isize) -> &'static isize {
|
||||
&x //[ast]~ ERROR `x` does not live long enough
|
||||
//[mir]~^ ERROR `x` does not live long enough (Ast)
|
||||
//[mir]~| ERROR borrowed value does not live long enough (Mir)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2016 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.
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
||||
|
||||
#![feature(thread_local)]
|
||||
|
||||
#[thread_local]
|
||||
static FOO: u8 = 3;
|
||||
|
||||
fn assert_static(_t: &'static u8) {}
|
||||
fn main() {
|
||||
assert_static(&FOO); //[ast]~ ERROR [E0597]
|
||||
//[mir]~^ ERROR (Ast) [E0597]
|
||||
//[mir]~| ERROR (Mir) [E0597]
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
// including) the call to `use_x`. The `else` branch is not included.
|
||||
|
||||
// ignore-tidy-linelength
|
||||
// ignore-test #46267
|
||||
// compile-flags:-Znll -Zverbose
|
||||
// ^^^^^^^^^ force compiler to dump more region information
|
||||
|
||||
|
|
|
|||
19
src/test/run-fail/borrowck-local-borrow.rs
Normal file
19
src/test/run-fail/borrowck-local-borrow.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2016 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.
|
||||
// error-pattern:panic 1
|
||||
|
||||
// revisions: ast mir
|
||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
||||
|
||||
fn main() {
|
||||
let x = 2;
|
||||
let y = &x;
|
||||
panic!("panic 1");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue