Use revisions for NLL (consistently) in higher-ranked-trait-bounds

This commit is contained in:
Jack Huey 2022-05-21 12:59:02 -04:00
parent dc435ee762
commit 707d2ebb5b
6 changed files with 49 additions and 27 deletions

View file

@ -1,11 +1,11 @@
error[E0477]: the type `&'a V` does not fulfill the required lifetime
--> $DIR/issue-59311.rs:17:5
--> $DIR/issue-59311.rs:21:5
|
LL | v.t(|| {});
| ^^^^^^^^^^
|
note: type must satisfy the static lifetime as required by this binding
--> $DIR/issue-59311.rs:15:24
--> $DIR/issue-59311.rs:19:24
|
LL | for<'a> &'a V: T + 'static,
| ^^^^^^^

View file

@ -1,13 +1,13 @@
error: higher-ranked lifetime error
--> $DIR/issue-59311.rs:17:5
--> $DIR/issue-59311.rs:21:5
|
LL | v.t(|| {});
| ^^^^^^^^^^
|
= note: could not prove [closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed
= note: could not prove [closure@$DIR/issue-59311.rs:21:9: 21:14] well-formed
error: higher-ranked lifetime error
--> $DIR/issue-59311.rs:17:9
--> $DIR/issue-59311.rs:21:9
|
LL | v.t(|| {});
| ^^^^^

View file

@ -6,6 +6,10 @@
// an error, but the regression test is here to ensure
// that it does not ICE. See discussion on #74889 for details.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
pub trait T {
fn t<F: Fn()>(&self, _: F) {}
}
@ -14,7 +18,10 @@ pub fn crash<V>(v: &V)
where
for<'a> &'a V: T + 'static,
{
v.t(|| {}); //~ ERROR: `&'a V` does not fulfill the required lifetime
v.t(|| {});
//[base]~^ ERROR: `&'a V` does not fulfill the required lifetime
//[nll]~^^ ERROR: higher-ranked lifetime error
//[nll]~| ERROR: higher-ranked lifetime error
}
fn main() {}

View file

@ -0,0 +1,20 @@
error: implementation of `Parser` is not general enough
--> $DIR/issue-71955.rs:49:5
|
LL | foo(bar, "string", |s| s.len() == 5);
| ^^^ implementation of `Parser` is not general enough
|
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`...
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
error: implementation of `Parser` is not general enough
--> $DIR/issue-71955.rs:53:5
|
LL | foo(baz, "string", |s| s.0.len() == 5);
| ^^^ implementation of `Parser` is not general enough
|
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`...
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
error: aborting due to 2 previous errors

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-71955.rs:54:5
--> $DIR/issue-71955.rs:49:5
|
LL | foo(bar, "string", |s| s.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
@ -7,18 +7,18 @@ LL | foo(bar, "string", |s| s.len() == 5);
= note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>`
found type `for<'r> FnOnce<(&'r &str,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:54:24
--> $DIR/issue-71955.rs:49:24
|
LL | foo(bar, "string", |s| s.len() == 5);
| ^^^^^^^^^^^^^^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:34:9
--> $DIR/issue-71955.rs:29:9
|
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/issue-71955.rs:54:5
--> $DIR/issue-71955.rs:49:5
|
LL | foo(bar, "string", |s| s.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
@ -26,18 +26,18 @@ LL | foo(bar, "string", |s| s.len() == 5);
= note: expected type `FnOnce<(&&str,)>`
found type `for<'r> FnOnce<(&'r &str,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:54:24
--> $DIR/issue-71955.rs:49:24
|
LL | foo(bar, "string", |s| s.len() == 5);
| ^^^^^^^^^^^^^^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:34:44
--> $DIR/issue-71955.rs:29:44
|
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
| ^^^^
error[E0308]: mismatched types
--> $DIR/issue-71955.rs:58:5
--> $DIR/issue-71955.rs:53:5
|
LL | foo(baz, "string", |s| s.0.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
@ -45,18 +45,18 @@ LL | foo(baz, "string", |s| s.0.len() == 5);
= note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>`
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:58:24
--> $DIR/issue-71955.rs:53:24
|
LL | foo(baz, "string", |s| s.0.len() == 5);
| ^^^^^^^^^^^^^^^^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:34:9
--> $DIR/issue-71955.rs:29:9
|
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/issue-71955.rs:58:5
--> $DIR/issue-71955.rs:53:5
|
LL | foo(baz, "string", |s| s.0.len() == 5);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
@ -64,12 +64,12 @@ LL | foo(baz, "string", |s| s.0.len() == 5);
= note: expected type `FnOnce<(&Wrapper<'_>,)>`
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-71955.rs:58:24
--> $DIR/issue-71955.rs:53:24
|
LL | foo(baz, "string", |s| s.0.len() == 5);
| ^^^^^^^^^^^^^^^^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:34:44
--> $DIR/issue-71955.rs:29:44
|
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
| ^^^^

View file

@ -1,13 +1,8 @@
// ignore-compare-mode-nll
// revisions: migrate nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// check-fail
// Since we are testing nll (and migration) explicitly as a separate
// revisions, don't worry about the --compare-mode=nll on this test.
// ignore-compare-mode-nll
#![feature(rustc_attrs)]
trait Parser<'s> {
@ -52,11 +47,11 @@ fn main() {
}
foo(bar, "string", |s| s.len() == 5);
//[migrate]~^ ERROR implementation of `Parser` is not general enough
//[base]~^ ERROR implementation of `Parser` is not general enough
//[nll]~^^ ERROR mismatched types
//[nll]~| ERROR mismatched types
foo(baz, "string", |s| s.0.len() == 5);
//[migrate]~^ ERROR implementation of `Parser` is not general enough
//[base]~^ ERROR implementation of `Parser` is not general enough
//[nll]~^^ ERROR mismatched types
//[nll]~| ERROR mismatched types
}