Skip to content

Commit fd78a2f

Browse files
committed
update tests with new error messages (mostly worse, I'm afraid)
1 parent 3ff3116 commit fd78a2f

21 files changed

+94
-86
lines changed

src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr

+3-12
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,19 @@ error[E0499]: cannot borrow `*arg` as mutable more than once at a time
22
--> $DIR/mut-borrow-in-loop.rs:20:25
33
|
44
LL | (self.func)(arg) //~ ERROR cannot borrow
5-
| ------------^^^-
6-
| | |
7-
| | mutable borrow starts here in previous iteration of loop
8-
| borrow later used here
5+
| ^^^ mutable borrow starts here in previous iteration of loop
96

107
error[E0499]: cannot borrow `*arg` as mutable more than once at a time
118
--> $DIR/mut-borrow-in-loop.rs:26:25
129
|
1310
LL | (self.func)(arg) //~ ERROR cannot borrow
14-
| ------------^^^-
15-
| | |
16-
| | mutable borrow starts here in previous iteration of loop
17-
| borrow later used here
11+
| ^^^ mutable borrow starts here in previous iteration of loop
1812

1913
error[E0499]: cannot borrow `*arg` as mutable more than once at a time
2014
--> $DIR/mut-borrow-in-loop.rs:33:25
2115
|
2216
LL | (self.func)(arg) //~ ERROR cannot borrow
23-
| ------------^^^-
24-
| | |
25-
| | mutable borrow starts here in previous iteration of loop
26-
| borrow later used here
17+
| ^^^ mutable borrow starts here in previous iteration of loop
2718

2819
error: aborting due to 3 previous errors
2920

src/test/ui/issue-46471.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ LL | &x
1717
...
1818
LL | }
1919
| - borrowed value only lives until here
20-
|
21-
= note: borrowed value must be valid for the static lifetime...
2220

2321
error: aborting due to 2 previous errors
2422

src/test/ui/issue-46472.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ LL | &mut 4
2121
...
2222
LL | }
2323
| - temporary value only lives until here
24-
|
25-
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1...
26-
--> $DIR/issue-46472.rs:13:1
27-
|
28-
LL | fn bar<'a>() -> &'a mut u32 {
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3024

3125
error: aborting due to 2 previous errors
3226

src/test/ui/issue-46983.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#![feature(nll)]
1212

1313
fn foo(x: &u32) -> &'static u32 {
14-
&*x
1514
//~^ ERROR explicit lifetime required in the type of `x` [E0621]
15+
&*x
1616
}
1717

1818
fn main() {}

src/test/ui/issue-46983.stderr

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
error[E0621]: explicit lifetime required in the type of `x`
2-
--> $DIR/issue-46983.rs:14:5
2+
--> $DIR/issue-46983.rs:13:1
33
|
4-
LL | fn foo(x: &u32) -> &'static u32 {
5-
| - consider changing the type of `x` to `&'static u32`
6-
LL | &*x
7-
| ^^^ lifetime `'static` required
4+
LL | fn foo(x: &u32) -> &'static u32 {
5+
| ^ - consider changing the type of `x` to `&'static u32`
6+
| _|
7+
| |
8+
LL | | //~^ ERROR explicit lifetime required in the type of `x` [E0621]
9+
LL | | &*x
10+
LL | | }
11+
| |_^ lifetime `'static` required
812

913
error: aborting due to previous error
1014

src/test/ui/nll/borrowed-universal-error-2.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ LL | &v
66
LL | //~^ ERROR `v` does not live long enough [E0597]
77
LL | }
88
| - borrowed value only lives until here
9-
|
10-
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:1...
11-
--> $DIR/borrowed-universal-error-2.rs:14:1
12-
|
13-
LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159

1610
error: aborting due to previous error
1711

src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// compile-flags:-Zborrowck=mir -Zverbose
1717

1818
fn foo(x: &u32) -> &'static u32 {
19+
//~^ ERROR explicit lifetime required in the type of `x`
1920
&*x
2021
//~^ WARN not reporting region error due to nll
21-
//~| ERROR explicit lifetime required in the type of `x`
2222
}
2323

2424
fn main() { }

src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
warning: not reporting region error due to nll
2-
--> $DIR/region-lbr-anon-does-not-outlive-static.rs:19:5
2+
--> $DIR/region-lbr-anon-does-not-outlive-static.rs:20:5
33
|
44
LL | &*x
55
| ^^^
66

77
error[E0621]: explicit lifetime required in the type of `x`
8-
--> $DIR/region-lbr-anon-does-not-outlive-static.rs:19:5
8+
--> $DIR/region-lbr-anon-does-not-outlive-static.rs:18:1
99
|
10-
LL | fn foo(x: &u32) -> &'static u32 {
11-
| - consider changing the type of `x` to `&ReStatic u32`
12-
LL | &*x
13-
| ^^^ lifetime `ReStatic` required
10+
LL | fn foo(x: &u32) -> &'static u32 {
11+
| ^ - consider changing the type of `x` to `&ReStatic u32`
12+
| _|
13+
| |
14+
LL | | //~^ ERROR explicit lifetime required in the type of `x`
15+
LL | | &*x
16+
LL | | //~^ WARN not reporting region error due to nll
17+
LL | | }
18+
| |_^ lifetime `ReStatic` required
1419

1520
error: aborting due to previous error
1621

src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// compile-flags:-Zborrowck=mir -Zverbose
1717

1818
fn foo<'a>(x: &'a u32) -> &'static u32 {
19+
//~^ ERROR does not outlive free region
1920
&*x
2021
//~^ WARN not reporting region error due to nll
21-
//~| ERROR does not outlive free region
2222
}
2323

2424
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
warning: not reporting region error due to nll
2-
--> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5
2+
--> $DIR/region-lbr-named-does-not-outlive-static.rs:20:5
33
|
44
LL | &*x
55
| ^^^
66

77
error: free region `ReFree(DefId(0/0:3 ~ region_lbr_named_does_not_outlive_static[317d]::foo[0]), BrNamed(crate0:DefIndex(1:9), 'a))` does not outlive free region `ReStatic`
8-
--> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5
8+
--> $DIR/region-lbr-named-does-not-outlive-static.rs:18:1
99
|
10-
LL | &*x
11-
| ^^^
10+
LL | / fn foo<'a>(x: &'a u32) -> &'static u32 {
11+
LL | | //~^ ERROR does not outlive free region
12+
LL | | &*x
13+
LL | | //~^ WARN not reporting region error due to nll
14+
LL | | }
15+
| |_^
1216

1317
error: aborting due to previous error
1418

src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// compile-flags:-Zborrowck=mir -Zverbose
1717

1818
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
19+
//~^ ERROR lifetime mismatch
1920
&*x
2021
//~^ WARN not reporting region error due to nll
21-
//~| ERROR lifetime mismatch
2222
}
2323

2424
fn main() { }

src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
warning: not reporting region error due to nll
2-
--> $DIR/region-lbr1-does-not-outlive-ebr2.rs:19:5
2+
--> $DIR/region-lbr1-does-not-outlive-ebr2.rs:20:5
33
|
44
LL | &*x
55
| ^^^
66

77
error[E0623]: lifetime mismatch
8-
--> $DIR/region-lbr1-does-not-outlive-ebr2.rs:19:5
8+
--> $DIR/region-lbr1-does-not-outlive-ebr2.rs:18:1
99
|
10-
LL | fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
11-
| ------- -------
12-
| |
13-
| this parameter and the return type are declared with different lifetimes...
14-
LL | &*x
15-
| ^^^ ...but data from `x` is returned here
10+
LL | fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
11+
| ^ ------- -------
12+
| | |
13+
| _| this parameter and the return type are declared with different lifetimes...
14+
| |
15+
LL | | //~^ ERROR lifetime mismatch
16+
LL | | &*x
17+
LL | | //~^ WARN not reporting region error due to nll
18+
LL | | }
19+
| |_^ ...but data from `x` is returned here
1620

1721
error: aborting due to previous error
1822

src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | expect_sig(|a, b| b); // ought to return `a`
55
| ^
66

77
error: free region `ReFree(DefId(0/1:9 ~ return_wrong_bound_region[317d]::test[0]::{{closure}}[0]), BrAnon(2))` does not outlive free region `ReFree(DefId(0/1:9 ~ return_wrong_bound_region[317d]::test[0]::{{closure}}[0]), BrAnon(1))`
8-
--> $DIR/return-wrong-bound-region.rs:21:23
8+
--> $DIR/return-wrong-bound-region.rs:21:16
99
|
1010
LL | expect_sig(|a, b| b); // ought to return `a`
11-
| ^
11+
| ^^^^^^^^
1212

1313
note: No external requirements
1414
--> $DIR/return-wrong-bound-region.rs:21:16

src/test/ui/nll/guarantor-issue-46974.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ fn foo(s: &mut (i32,)) -> i32 {
2020
*x
2121
}
2222

23-
fn bar(s: &Box<(i32,)>) -> &'static i32 {
23+
fn bar(s: &Box<(i32,)>) -> &'static i32 { //~ ERROR explicit lifetime required
2424
// FIXME(#46983): error message should be better
25-
&s.0 //~ ERROR explicit lifetime required in the type of `s` [E0621]
25+
&s.0
2626
}
2727

2828
fn main() {

src/test/ui/nll/guarantor-issue-46974.stderr

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ LL | *x
1010
| -- borrow later used here
1111

1212
error[E0621]: explicit lifetime required in the type of `s`
13-
--> $DIR/guarantor-issue-46974.rs:25:5
13+
--> $DIR/guarantor-issue-46974.rs:23:1
1414
|
15-
LL | fn bar(s: &Box<(i32,)>) -> &'static i32 {
16-
| - consider changing the type of `s` to `&'static std::boxed::Box<(i32,)>`
17-
LL | // FIXME(#46983): error message should be better
18-
LL | &s.0 //~ ERROR explicit lifetime required in the type of `s` [E0621]
19-
| ^^^^ lifetime `'static` required
15+
LL | fn bar(s: &Box<(i32,)>) -> &'static i32 { //~ ERROR explicit lifetime required
16+
| ^ - consider changing the type of `s` to `&'static std::boxed::Box<(i32,)>`
17+
| _|
18+
| |
19+
LL | | // FIXME(#46983): error message should be better
20+
LL | | &s.0
21+
LL | | }
22+
| |_^ lifetime `'static` required
2023

2124
error: aborting due to 2 previous errors
2225

src/test/ui/nll/issue-47470.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ LL | &local //~ ERROR `local` does not live long enough
55
| ^^^^^^ borrowed value does not live long enough
66
LL | }
77
| - borrowed value only lives until here
8-
|
9-
note: borrowed value must be valid for the lifetime 'a as defined on the impl at 23:1...
10-
--> $DIR/issue-47470.rs:23:1
11-
|
12-
LL | impl<'a> Bar for Foo<'a> {
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^
148

159
error: aborting due to previous error
1610

src/test/ui/nll/issue-48238.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: free region `` does not outlive free region `'_#1r`
2-
--> $DIR/issue-48238.rs:21:21
2+
--> $DIR/issue-48238.rs:21:5
33
|
44
LL | move || use_val(&orig); //~ ERROR free region `` does not outlive free region `'_#1r`
5-
| ^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to previous error
88

src/test/ui/nll/ty-outlives/impl-trait-captures.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ trait Foo<'a> {
1818
impl<'a, T> Foo<'a> for T { }
1919

2020
fn foo<'a, T>(x: &T) -> impl Foo<'a> {
21+
//~^ ERROR explicit lifetime required in the type of `x` [E0621]
2122
x
2223
//~^ WARNING not reporting region error due to nll
23-
//~| ERROR explicit lifetime required in the type of `x` [E0621]
2424
}
2525

2626
fn main() {}

src/test/ui/nll/ty-outlives/impl-trait-captures.stderr

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
warning: not reporting region error due to nll
2-
--> $DIR/impl-trait-captures.rs:21:5
2+
--> $DIR/impl-trait-captures.rs:22:5
33
|
44
LL | x
55
| ^
66

77
error[E0621]: explicit lifetime required in the type of `x`
8-
--> $DIR/impl-trait-captures.rs:21:5
8+
--> $DIR/impl-trait-captures.rs:20:1
99
|
10-
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
11-
| - consider changing the type of `x` to `&ReEarlyBound(0, 'a) T`
12-
LL | x
13-
| ^ lifetime `ReEarlyBound(0, 'a)` required
10+
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
11+
| ^ - consider changing the type of `x` to `&ReEarlyBound(0, 'a) T`
12+
| _|
13+
| |
14+
LL | | //~^ ERROR explicit lifetime required in the type of `x` [E0621]
15+
LL | | x
16+
LL | | //~^ WARNING not reporting region error due to nll
17+
LL | | }
18+
| |_^ lifetime `ReEarlyBound(0, 'a)` required
1419

1520
error: aborting due to previous error
1621

src/test/ui/nll/ty-outlives/impl-trait-outlives.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use std::fmt::Debug;
1616

1717
fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a
1818
//~^ WARNING not reporting region error due to nll
19+
//~| ERROR the parameter type `T` may not live long enough [E0309]
1920
where
2021
T: Debug,
2122
{
2223
x
23-
//~^ ERROR the parameter type `T` may not live long enough [E0309]
2424
}
2525

2626
fn correct_region<'a, T>(x: Box<T>) -> impl Debug + 'a
@@ -32,11 +32,11 @@ where
3232

3333
fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
3434
//~^ WARNING not reporting region error due to nll
35+
//~| ERROR the parameter type `T` may not live long enough [E0309]
3536
where
3637
T: 'b + Debug,
3738
{
3839
x
39-
//~^ ERROR the parameter type `T` may not live long enough [E0309]
4040
}
4141

4242
fn outlives_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a

src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr

+18-6
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,30 @@ LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
1111
| ^^^^^^^^^^^^^^^
1212

1313
error[E0309]: the parameter type `T` may not live long enough
14-
--> $DIR/impl-trait-outlives.rs:22:5
14+
--> $DIR/impl-trait-outlives.rs:17:1
1515
|
16-
LL | x
17-
| ^
16+
LL | / fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a
17+
LL | | //~^ WARNING not reporting region error due to nll
18+
LL | | //~| ERROR the parameter type `T` may not live long enough [E0309]
19+
LL | | where
20+
... |
21+
LL | | x
22+
LL | | }
23+
| |_^
1824
|
1925
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
2026

2127
error[E0309]: the parameter type `T` may not live long enough
22-
--> $DIR/impl-trait-outlives.rs:38:5
28+
--> $DIR/impl-trait-outlives.rs:33:1
2329
|
24-
LL | x
25-
| ^
30+
LL | / fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
31+
LL | | //~^ WARNING not reporting region error due to nll
32+
LL | | //~| ERROR the parameter type `T` may not live long enough [E0309]
33+
LL | | where
34+
... |
35+
LL | | x
36+
LL | | }
37+
| |_^
2638
|
2739
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
2840

0 commit comments

Comments
 (0)