Skip to content

Commit 3dbc11b

Browse files
committed
Updated existing tests with new error messages.
1 parent 00c7a3f commit 3dbc11b

12 files changed

+57
-46
lines changed

src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
//[mir]compile-flags: -Z borrowck=mir
1313

1414
fn cplusplus_mode(x: isize) -> &'static isize {
15-
&x //[ast]~ ERROR `x` does not live long enough
15+
&x
16+
//[ast]~^ ERROR `x` does not live long enough [E0597]
17+
//[mir]~^^ ERROR `x` does not live long enough [E0597]
1618
}
17-
//[mir]~^ ERROR borrowed value does not live long enough
1819

1920
fn main() {}

src/test/compile-fail/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) {
1515
let mut z = (0, 0);
16-
*x = Some(&mut z.1); //[ast]~ ERROR [E0597]
16+
*x = Some(&mut z.1);
17+
//[ast]~^ ERROR `z.1` does not live long enough [E0597]
18+
//[mir]~^^ ERROR `z.1` does not live long enough [E0597]
1719
panic!("catch me for a dangling pointer!")
1820
}
19-
//[mir]~^ ERROR [E0597]
2021

2122
fn main() {
2223
cplusplus_mode_exceptionally_unsafe(&mut None);

src/test/compile-fail/issue-17954.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ static FOO: u8 = 3;
1818

1919
fn main() {
2020
let a = &FOO;
21-
//[ast]~^ ERROR borrowed value does not live long enough
21+
//[mir]~^ ERROR `FOO` does not live long enough [E0597]
22+
//[mir]~| does not live long enough
23+
//[mir]~| NOTE borrowed value must be valid for the static lifetime
24+
//[ast]~^^^^ ERROR borrowed value does not live long enough
2225
//[ast]~| does not live long enough
2326
//[ast]~| NOTE borrowed value must be valid for the static lifetime
2427

2528
std::thread::spawn(move || {
2629
println!("{}", a);
2730
});
28-
} //[ast]~ temporary value only lives until here
29-
//[mir]~^ ERROR borrowed value does not live long enough
31+
}
32+
//[mir]~^ borrowed value only lives until here
33+
//[ast]~^^ temporary value only lives until here

src/test/compile-fail/region-borrow-params-issue-29793-big.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ fn main() {
8282
//[ast]~^ ERROR `x` does not live long enough
8383
//[ast]~| ERROR `y` does not live long enough
8484
});
85-
//[mir]~^ ERROR borrowed value does not live long enough
86-
//[mir]~| ERROR borrowed value does not live long enough
85+
//[mir]~^ ERROR `x` does not live long enough
86+
//[mir]~| ERROR `y` does not live long enough
8787

8888
w.handle(); // This works
8989
// w.handle_ref(); // This doesn't

src/test/ui/nll/capture-ref-in-struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ fn test() {
3030
let closure = SomeStruct {
3131
p: &mut p,
3232
y: &y,
33+
//~^ ERROR `y` does not live long enough [E0597]
3334
};
3435

3536
closure.invoke();
3637
}
37-
//~^ ERROR borrowed value does not live long enough [E0597]
3838

3939
deref(p);
4040
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
error[E0597]: borrowed value does not live long enough
2-
--> $DIR/capture-ref-in-struct.rs:36:6
1+
error[E0597]: `y` does not live long enough
2+
--> $DIR/capture-ref-in-struct.rs:32:16
33
|
4-
28 | let y = 22;
5-
| - temporary value created here
4+
32 | y: &y,
5+
| ^^ does not live long enough
66
...
7-
36 | }
8-
| ^ temporary value dropped here while still borrowed
7+
37 | }
8+
| - borrowed value only lives until here
99
|
10-
= note: consider using a `let` binding to increase its lifetime
10+
= note: borrowed value must be valid for lifetime '_#4r...
1111

1212
error: aborting due to previous error
1313

src/test/ui/nll/closure-requirements/escape-argument.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ fn test() {
3535
let y = 22;
3636
let mut closure = expect_sig(|p, y| *p = y);
3737
closure(&mut p, &y);
38+
//~^ ERROR `y` does not live long enough [E0597]
3839
}
39-
//~^ ERROR borrowed value does not live long enough [E0597]
4040

4141
deref(p);
4242
}

src/test/ui/nll/closure-requirements/escape-argument.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ note: No external requirements
2424
|
2525
= note: defining type: DefId(0/0:3 ~ escape_argument[317d]::test[0]) with substs []
2626

27-
error[E0597]: borrowed value does not live long enough
28-
--> $DIR/escape-argument.rs:38:6
27+
error[E0597]: `y` does not live long enough
28+
--> $DIR/escape-argument.rs:37:25
2929
|
30-
35 | let y = 22;
31-
| - temporary value created here
32-
...
33-
38 | }
34-
| ^ temporary value dropped here while still borrowed
30+
37 | closure(&mut p, &y);
31+
| ^^ does not live long enough
32+
38 | //~^ ERROR `y` does not live long enough [E0597]
33+
39 | }
34+
| - borrowed value only lives until here
3535
|
36-
= note: consider using a `let` binding to increase its lifetime
36+
= note: borrowed value must be valid for lifetime '_#5r...
3737

3838
error: aborting due to previous error
3939

src/test/ui/nll/closure-requirements/escape-upvar-nested.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ fn test() {
2727
{
2828
let y = 22;
2929

30-
let mut closure = || {
30+
let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
3131
let mut closure1 = || p = &y;
3232
closure1();
3333
};
3434

3535
closure();
36-
} //~ ERROR borrowed value does not live long enough
36+
}
3737

3838
deref(p);
3939
}

src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ note: External requirements
1616
note: External requirements
1717
--> $DIR/escape-upvar-nested.rs:30:27
1818
|
19-
30 | let mut closure = || {
19+
30 | let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
2020
| ___________________________^
2121
31 | | let mut closure1 = || p = &y;
2222
32 | | closure1();
@@ -46,16 +46,20 @@ note: No external requirements
4646
|
4747
= note: defining type: DefId(0/0:3 ~ escape_upvar_nested[317d]::test[0]) with substs []
4848

49-
error[E0597]: borrowed value does not live long enough
50-
--> $DIR/escape-upvar-nested.rs:36:6
49+
error[E0597]: `y` does not live long enough
50+
--> $DIR/escape-upvar-nested.rs:30:27
5151
|
52-
28 | let y = 22;
53-
| - temporary value created here
52+
30 | let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
53+
| ___________________________^
54+
31 | | let mut closure1 = || p = &y;
55+
32 | | closure1();
56+
33 | | };
57+
| |_________^ does not live long enough
5458
...
55-
36 | } //~ ERROR borrowed value does not live long enough
56-
| ^ temporary value dropped here while still borrowed
59+
36 | }
60+
| - borrowed value only lives until here
5761
|
58-
= note: consider using a `let` binding to increase its lifetime
62+
= note: borrowed value must be valid for lifetime '_#3r...
5963

6064
error: aborting due to previous error
6165

src/test/ui/nll/closure-requirements/escape-upvar-ref.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ fn test() {
3131
{
3232
let y = 22;
3333
let mut closure = || p = &y;
34+
//~^ ERROR `y` does not live long enough [E0597]
3435
closure();
35-
} //~ ERROR borrowed value does not live long enough
36+
}
3637

3738
deref(p);
3839
}

src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ note: No external requirements
2121
29 | | let mut p = &x;
2222
30 | |
2323
... |
24-
37 | | deref(p);
25-
38 | | }
24+
38 | | deref(p);
25+
39 | | }
2626
| |_^
2727
|
2828
= note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs []
2929

30-
error[E0597]: borrowed value does not live long enough
31-
--> $DIR/escape-upvar-ref.rs:35:6
30+
error[E0597]: `y` does not live long enough
31+
--> $DIR/escape-upvar-ref.rs:33:27
3232
|
33-
32 | let y = 22;
34-
| - temporary value created here
33+
33 | let mut closure = || p = &y;
34+
| ^^^^^^^^^ does not live long enough
3535
...
36-
35 | } //~ ERROR borrowed value does not live long enough
37-
| ^ temporary value dropped here while still borrowed
36+
36 | }
37+
| - borrowed value only lives until here
3838
|
39-
= note: consider using a `let` binding to increase its lifetime
39+
= note: borrowed value must be valid for lifetime '_#3r...
4040

4141
error: aborting due to previous error
4242

0 commit comments

Comments
 (0)