Updated existing tests with new error messages.

This commit is contained in:
David Wood 2017-12-11 17:29:31 +00:00
parent 00c7a3f4dc
commit 3dbc11bc63
No known key found for this signature in database
GPG Key ID: 01760B4F9F53F154
12 changed files with 57 additions and 46 deletions

View File

@ -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() {}

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -30,11 +30,11 @@ fn test() {
let closure = SomeStruct {
p: &mut p,
y: &y,
//~^ ERROR `y` does not live long enough [E0597]
};
closure.invoke();
}
//~^ ERROR borrowed value does not live long enough [E0597]
deref(p);
}

View File

@ -1,13 +1,13 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/capture-ref-in-struct.rs:36:6
error[E0597]: `y` does not live long enough
--> $DIR/capture-ref-in-struct.rs:32:16
|
28 | let y = 22;
| - temporary value created here
32 | y: &y,
| ^^ does not live long enough
...
36 | }
| ^ temporary value dropped here while still borrowed
37 | }
| - borrowed value only lives until here
|
= note: consider using a `let` binding to increase its lifetime
= note: borrowed value must be valid for lifetime '_#4r...
error: aborting due to previous error

View File

@ -35,8 +35,8 @@ fn test() {
let y = 22;
let mut closure = expect_sig(|p, y| *p = y);
closure(&mut p, &y);
//~^ ERROR `y` does not live long enough [E0597]
}
//~^ ERROR borrowed value does not live long enough [E0597]
deref(p);
}

View File

@ -24,16 +24,16 @@ note: No external requirements
|
= note: defining type: DefId(0/0:3 ~ escape_argument[317d]::test[0]) with substs []
error[E0597]: borrowed value does not live long enough
--> $DIR/escape-argument.rs:38:6
error[E0597]: `y` does not live long enough
--> $DIR/escape-argument.rs:37:25
|
35 | let y = 22;
| - temporary value created here
...
38 | }
| ^ temporary value dropped here while still borrowed
37 | closure(&mut p, &y);
| ^^ does not live long enough
38 | //~^ ERROR `y` does not live long enough [E0597]
39 | }
| - borrowed value only lives until here
|
= note: consider using a `let` binding to increase its lifetime
= note: borrowed value must be valid for lifetime '_#5r...
error: aborting due to previous error

View File

@ -27,13 +27,13 @@ fn test() {
{
let y = 22;
let mut closure = || {
let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
let mut closure1 = || p = &y;
closure1();
};
closure();
} //~ ERROR borrowed value does not live long enough
}
deref(p);
}

View File

@ -16,7 +16,7 @@ note: External requirements
note: External requirements
--> $DIR/escape-upvar-nested.rs:30:27
|
30 | let mut closure = || {
30 | let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
| ___________________________^
31 | | let mut closure1 = || p = &y;
32 | | closure1();
@ -46,16 +46,20 @@ note: No external requirements
|
= note: defining type: DefId(0/0:3 ~ escape_upvar_nested[317d]::test[0]) with substs []
error[E0597]: borrowed value does not live long enough
--> $DIR/escape-upvar-nested.rs:36:6
error[E0597]: `y` does not live long enough
--> $DIR/escape-upvar-nested.rs:30:27
|
28 | let y = 22;
| - temporary value created here
30 | let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
| ___________________________^
31 | | let mut closure1 = || p = &y;
32 | | closure1();
33 | | };
| |_________^ does not live long enough
...
36 | } //~ ERROR borrowed value does not live long enough
| ^ temporary value dropped here while still borrowed
36 | }
| - borrowed value only lives until here
|
= note: consider using a `let` binding to increase its lifetime
= note: borrowed value must be valid for lifetime '_#3r...
error: aborting due to previous error

View File

@ -31,8 +31,9 @@ fn test() {
{
let y = 22;
let mut closure = || p = &y;
//~^ ERROR `y` does not live long enough [E0597]
closure();
} //~ ERROR borrowed value does not live long enough
}
deref(p);
}

View File

@ -21,22 +21,22 @@ note: No external requirements
29 | | let mut p = &x;
30 | |
... |
37 | | deref(p);
38 | | }
38 | | deref(p);
39 | | }
| |_^
|
= note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs []
error[E0597]: borrowed value does not live long enough
--> $DIR/escape-upvar-ref.rs:35:6
error[E0597]: `y` does not live long enough
--> $DIR/escape-upvar-ref.rs:33:27
|
32 | let y = 22;
| - temporary value created here
33 | let mut closure = || p = &y;
| ^^^^^^^^^ does not live long enough
...
35 | } //~ ERROR borrowed value does not live long enough
| ^ temporary value dropped here while still borrowed
36 | }
| - borrowed value only lives until here
|
= note: consider using a `let` binding to increase its lifetime
= note: borrowed value must be valid for lifetime '_#3r...
error: aborting due to previous error