Skip to content

Commit

Permalink
Rollup merge of rust-lang#95591 - jackh726:nll-revisions-1, r=oli-obk
Browse files Browse the repository at this point in the history
Use revisions to track NLL test output (part 1)

The idea here is 2 fold: 1) When we eventually do make NLL default on, that PR should be systematic in "delete revisions and corresponding error annotations" 2) This allows us to look at test NLL outputs in chunks. (Though, I've opted here not to "mark" these tests. There are some tests with NLL revisions *now* that will be missed. I expect we do a second pass once we have all the tests with NLL revisions; these tests should be easy enough to eyeball.)

The actual review here should be "easy", but a bit tedious. I expect we should manually go through each test output and confirm it's okay.

The majority of these are either: 1) Only span change (the one I see most common is highlighting an entire function call, rather than just the function name in that call) 2) "E0308 mismatched types" -> "lifetime does not live long enough" 3) "E0495 cannot infer an appropriate lifetime for lifetime parameter" -> "lifetime does not live long enough" 4) "E0312 lifetime of reference outlives lifetime of borrowed content" -> "lifetime does not live long enough" 5) "E0759 `XXX` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement" -> "lifetime does not live long enough" 6) "E0623 lifetime mismatch" -> "lifetime does not live long enough"

Other than the now lack of an error code, most of these look fine (with most giving more helpful suggestions now).

`rfc1623` output isn't great.

cc `@marmeladema` if you want to look through these

Let's r? `@oli-obk` since you've commented on the Zulip thread ;)
  • Loading branch information
Dylan-DPC authored Apr 5, 2022
2 parents a0cb41a + f881bf7 commit 81f1d55
Show file tree
Hide file tree
Showing 111 changed files with 588 additions and 328 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0308]: mismatched types
--> $DIR/issue-50716.rs:14:9
--> $DIR/issue-50716.rs:18:9
|
LL | let _x = *s;
| ^^ lifetime mismatch
|
= note: expected type `<<&'a T as A>::X as Sized>`
found type `<<&'static T as A>::X as Sized>`
note: the lifetime `'a` as defined here...
--> $DIR/issue-50716.rs:9:8
--> $DIR/issue-50716.rs:13:8
|
LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
| ^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/nll/issue-50716.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-50716.rs:14:14
--> $DIR/issue-50716.rs:18:14
|
LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
| -- lifetime `'a` defined here
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/nll/issue-50716.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Regression test for the issue #50716: NLL ignores lifetimes bounds
// derived from `Sized` requirements

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

trait A {
type X: ?Sized;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/issue-52742.rs:12:18
--> $DIR/issue-52742.rs:17:18
|
LL | self.y = b.z
| ^^^
|
note: ...the reference is valid for the lifetime `'_` as defined here...
--> $DIR/issue-52742.rs:10:10
--> $DIR/issue-52742.rs:15:10
|
LL | impl Foo<'_, '_> {
| ^^
note: ...but the borrowed content is only valid for the anonymous lifetime defined here
--> $DIR/issue-52742.rs:11:31
--> $DIR/issue-52742.rs:16:31
|
LL | fn take_bar(&mut self, b: Bar<'_>) {
| ^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/nll/issue-52742.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-52742.rs:12:9
--> $DIR/issue-52742.rs:17:9
|
LL | fn take_bar(&mut self, b: Bar<'_>) {
| --------- -- let's call this `'1`
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/nll/issue-52742.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir


struct Foo<'a, 'b> {
x: &'a u32,
y: &'b u32,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'s` due to conflicting requirements
--> $DIR/issue-55394.rs:9:9
--> $DIR/issue-55394.rs:13:9
|
LL | Foo { bar }
| ^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/issue-55394.rs:8:17
--> $DIR/issue-55394.rs:12:17
|
LL | fn new(bar: &mut Bar) -> Self {
| ^^^^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/issue-55394.rs:9:15
--> $DIR/issue-55394.rs:13:15
|
LL | Foo { bar }
| ^^^
note: but, the lifetime must be valid for the lifetime `'_` as defined here...
--> $DIR/issue-55394.rs:7:10
--> $DIR/issue-55394.rs:11:10
|
LL | impl Foo<'_> {
| ^^
note: ...so that the types are compatible
--> $DIR/issue-55394.rs:9:9
--> $DIR/issue-55394.rs:13:9
|
LL | Foo { bar }
| ^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/nll/issue-55394.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-55394.rs:9:9
--> $DIR/issue-55394.rs:13:9
|
LL | fn new(bar: &mut Bar) -> Self {
| - ---- return type is Foo<'2>
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/nll/issue-55394.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

struct Bar;

struct Foo<'s> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/issue-55401.rs:3:5
--> $DIR/issue-55401.rs:7:5
|
LL | *y
| ^^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/issue-55401.rs:1:47
--> $DIR/issue-55401.rs:5:47
|
LL | fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 {
| ^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/nll/issue-55401.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-55401.rs:3:5
--> $DIR/issue-55401.rs:7:5
|
LL | fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/nll/issue-55401.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 {
let (ref y, _z): (&'a u32, u32) = (&22, 44);
*y //~ ERROR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-if.rs:28:9
--> $DIR/lub-if.rs:32:9
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-if.rs:23:17
--> $DIR/lub-if.rs:27:17
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^

error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-if.rs:35:9
--> $DIR/lub-if.rs:41:9
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-if.rs:32:17
--> $DIR/lub-if.rs:38:17
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/nll/lub-if.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/lub-if.rs:28:9
--> $DIR/lub-if.rs:32:9
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
Expand All @@ -8,7 +8,7 @@ LL | s
| ^ returning this value requires that `'a` must outlive `'static`

error: lifetime may not live long enough
--> $DIR/lub-if.rs:35:9
--> $DIR/lub-if.rs:41:9
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
Expand Down
12 changes: 10 additions & 2 deletions src/test/ui/nll/lub-if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// of the various arms, particularly in the case where regions are
// involved.

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
if maybestr.is_none() {
"(none)"
Expand All @@ -25,14 +29,18 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
"(none)"
} else {
let s: &'a str = maybestr.as_ref().unwrap();
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
}
}

pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
if maybestr.is_some() {
let s: &'a str = maybestr.as_ref().unwrap();
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
} else {
"(none)"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-match.rs:30:13
--> $DIR/lub-match.rs:34:13
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-match.rs:25:17
--> $DIR/lub-match.rs:29:17
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^

error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-match.rs:39:13
--> $DIR/lub-match.rs:45:13
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-match.rs:35:17
--> $DIR/lub-match.rs:41:17
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/nll/lub-match.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/lub-match.rs:30:13
--> $DIR/lub-match.rs:34:13
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
Expand All @@ -8,7 +8,7 @@ LL | s
| ^ returning this value requires that `'a` must outlive `'static`

error: lifetime may not live long enough
--> $DIR/lub-match.rs:39:13
--> $DIR/lub-match.rs:45:13
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
Expand Down
12 changes: 10 additions & 2 deletions src/test/ui/nll/lub-match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// of the various arms, particularly in the case where regions are
// involved.

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
match *maybestr {
Some(ref s) => {
Expand All @@ -27,7 +31,9 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
None => "(none)",
Some(ref s) => {
let s: &'a str = s;
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
}
}
}
Expand All @@ -36,7 +42,9 @@ pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
match *maybestr {
Some(ref s) => {
let s: &'a str = s;
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
}
None => "(none)",
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/type-alias-free-regions.rs:17:9
--> $DIR/type-alias-free-regions.rs:21:9
|
LL | C { f: b }
| ^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/type-alias-free-regions.rs:16:24
--> $DIR/type-alias-free-regions.rs:20:24
|
LL | fn from_box(b: Box<B>) -> Self {
| ^
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:17:16
--> $DIR/type-alias-free-regions.rs:21:16
|
LL | C { f: b }
| ^
= note: expected `Box<Box<&isize>>`
found `Box<Box<&isize>>`
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
--> $DIR/type-alias-free-regions.rs:15:6
--> $DIR/type-alias-free-regions.rs:19:6
|
LL | impl<'a> FromBox<'a> for C<'a> {
| ^^
note: ...so that the types are compatible
--> $DIR/type-alias-free-regions.rs:17:9
--> $DIR/type-alias-free-regions.rs:21:9
|
LL | C { f: b }
| ^^^^^^^^^^
= note: expected `C<'a>`
found `C<'_>`

error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/type-alias-free-regions.rs:27:16
--> $DIR/type-alias-free-regions.rs:31:16
|
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/type-alias-free-regions.rs:26:23
--> $DIR/type-alias-free-regions.rs:30:23
|
LL | fn from_tuple(b: (B,)) -> Self {
| ^
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:27:25
--> $DIR/type-alias-free-regions.rs:31:25
|
LL | C { f: Box::new(b.0) }
| ^^^
= note: expected `Box<&isize>`
found `Box<&isize>`
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
--> $DIR/type-alias-free-regions.rs:25:6
--> $DIR/type-alias-free-regions.rs:29:6
|
LL | impl<'a> FromTuple<'a> for C<'a> {
| ^^
note: ...so that the types are compatible
--> $DIR/type-alias-free-regions.rs:27:9
--> $DIR/type-alias-free-regions.rs:31:9
|
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/nll/type-alias-free-regions.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/type-alias-free-regions.rs:17:9
--> $DIR/type-alias-free-regions.rs:21:9
|
LL | impl<'a> FromBox<'a> for C<'a> {
| -- lifetime `'a` defined here
Expand All @@ -9,7 +9,7 @@ LL | C { f: b }
| ^^^^^^^^^^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`

error: lifetime may not live long enough
--> $DIR/type-alias-free-regions.rs:27:9
--> $DIR/type-alias-free-regions.rs:31:9
|
LL | impl<'a> FromTuple<'a> for C<'a> {
| -- lifetime `'a` defined here
Expand Down
Loading

0 comments on commit 81f1d55

Please sign in to comment.