fix universes in the NLL type tests
In the NLL code, we were not accommodating universes in the `type_test` logic. This led to issue 98095.
This commit is contained in:
parent
b7b3d2cee0
commit
12912b9cde
3 changed files with 61 additions and 1 deletions
21
src/test/ui/nll/type-test-universe.rs
Normal file
21
src/test/ui/nll/type-test-universe.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Regression test for #98095: make sure that
|
||||
// we detect that S needs to outlive 'static.
|
||||
|
||||
fn outlives_forall<T>()
|
||||
where
|
||||
for<'u> T: 'u,
|
||||
{
|
||||
}
|
||||
|
||||
fn test1<S>() {
|
||||
outlives_forall::<S>();
|
||||
//~^ ERROR `S` does not live long enough
|
||||
}
|
||||
|
||||
struct Value<'a>(&'a ());
|
||||
fn test2<'a>() {
|
||||
outlives_forall::<Value<'a>>();
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
16
src/test/ui/nll/type-test-universe.stderr
Normal file
16
src/test/ui/nll/type-test-universe.stderr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
error: `S` does not live long enough
|
||||
--> $DIR/type-test-universe.rs:11:5
|
||||
|
|
||||
LL | outlives_forall::<S>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/type-test-universe.rs:17:5
|
||||
|
|
||||
LL | fn test2<'a>() {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | outlives_forall::<Value<'a>>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue