Updated existing tests with new error messages.
This commit is contained in:
parent
00c7a3f4dc
commit
3dbc11bc63
12 changed files with 57 additions and 46 deletions
|
|
@ -12,8 +12,9 @@
|
|||
//[mir]compile-flags: -Z borrowck=mir
|
||||
|
||||
fn cplusplus_mode(x: isize) -> &'static isize {
|
||||
&x //[ast]~ ERROR `x` does not live long enough
|
||||
&x
|
||||
//[ast]~^ ERROR `x` does not live long enough [E0597]
|
||||
//[mir]~^^ ERROR `x` does not live long enough [E0597]
|
||||
}
|
||||
//[mir]~^ ERROR borrowed value does not live long enough
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@
|
|||
|
||||
fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) {
|
||||
let mut z = (0, 0);
|
||||
*x = Some(&mut z.1); //[ast]~ ERROR [E0597]
|
||||
*x = Some(&mut z.1);
|
||||
//[ast]~^ ERROR `z.1` does not live long enough [E0597]
|
||||
//[mir]~^^ ERROR `z.1` does not live long enough [E0597]
|
||||
panic!("catch me for a dangling pointer!")
|
||||
}
|
||||
//[mir]~^ ERROR [E0597]
|
||||
|
||||
fn main() {
|
||||
cplusplus_mode_exceptionally_unsafe(&mut None);
|
||||
|
|
|
|||
|
|
@ -18,12 +18,16 @@ static FOO: u8 = 3;
|
|||
|
||||
fn main() {
|
||||
let a = &FOO;
|
||||
//[ast]~^ ERROR borrowed value does not live long enough
|
||||
//[mir]~^ ERROR `FOO` does not live long enough [E0597]
|
||||
//[mir]~| does not live long enough
|
||||
//[mir]~| NOTE borrowed value must be valid for the static lifetime
|
||||
//[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
|
||||
|
||||
std::thread::spawn(move || {
|
||||
println!("{}", a);
|
||||
});
|
||||
} //[ast]~ temporary value only lives until here
|
||||
//[mir]~^ ERROR borrowed value does not live long enough
|
||||
}
|
||||
//[mir]~^ borrowed value only lives until here
|
||||
//[ast]~^^ temporary value only lives until here
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ fn main() {
|
|||
//[ast]~^ ERROR `x` does not live long enough
|
||||
//[ast]~| ERROR `y` does not live long enough
|
||||
});
|
||||
//[mir]~^ ERROR borrowed value does not live long enough
|
||||
//[mir]~| ERROR borrowed value does not live long enough
|
||||
//[mir]~^ ERROR `x` does not live long enough
|
||||
//[mir]~| ERROR `y` does not live long enough
|
||||
|
||||
w.handle(); // This works
|
||||
// w.handle_ref(); // This doesn't
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue