diff options
| author | bors <bors@rust-lang.org> | 2017-11-26 11:43:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-26 11:43:19 +0000 |
| commit | 2ca00a948934766950167e997903a2cc0243c5cf (patch) | |
| tree | ad29a73f9f773afca767cf2a0c7e8a0a95b3dddb /src/test | |
| parent | 2c115551c425c5180d89bfc4b7ca0405b1d00b25 (diff) | |
| parent | efa3ed216eb6be151ead35339b690f93ac251935 (diff) | |
| download | rust-2ca00a948934766950167e997903a2cc0243c5cf.tar.gz rust-2ca00a948934766950167e997903a2cc0243c5cf.zip | |
Auto merge of #46100 - KiChjang:mass-dead-check, r=nikomatsakis
Kill the storage for all locals on returning terminators Fixes #45704.
Diffstat (limited to 'src/test')
4 files changed, 64 insertions, 0 deletions
diff --git a/src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs b/src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs new file mode 100644 index 00000000000..7ff3aa3feb3 --- /dev/null +++ b/src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs @@ -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() {} diff --git a/src/test/compile-fail/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs b/src/test/compile-fail/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs new file mode 100644 index 00000000000..5a6c86fd82b --- /dev/null +++ b/src/test/compile-fail/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs @@ -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] +} diff --git a/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs b/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs index aaeebe74951..3d92054b0b2 100644 --- a/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs +++ b/src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs @@ -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 diff --git a/src/test/run-fail/borrowck-local-borrow.rs b/src/test/run-fail/borrowck-local-borrow.rs new file mode 100644 index 00000000000..7f11f45cbd8 --- /dev/null +++ b/src/test/run-fail/borrowck-local-borrow.rs @@ -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"); +} |
