Skip to content

Commit

Permalink
update tests + add future compat test
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jun 8, 2022
1 parent c7b6e1d commit 0667b00
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
22 changes: 22 additions & 0 deletions src/test/ui/lub-glb/empty-binder-future-compat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// check-pass
fn lt_in_fn_fn<'a: 'a>() -> fn(fn(&'a ())) {
|_| ()
}


fn foo<'a, 'b, 'lower>(v: bool)
where
'a: 'lower,
'b: 'lower,
{
// if we infer `x` to be higher ranked in the future,
// this would cause a type error.
let x = match v {
true => lt_in_fn_fn::<'a>(),
false => lt_in_fn_fn::<'b>(),
};

let _: fn(fn(&'lower())) = x;
}

fn main() {}
12 changes: 3 additions & 9 deletions src/test/ui/lub-glb/empty-binders-err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ fn lt_in_contra<'a: 'a>() -> Contra<'a> {
Contra(|_| ())
}

fn covariance<'a, 'b, 'upper, 'lower>(v: bool)
fn covariance<'a, 'b, 'upper>(v: bool)
where
'upper: 'a,
'upper: 'b,
'a: 'lower,
'b: 'lower,

{
let _: &'upper () = match v {
Expand All @@ -27,10 +25,8 @@ where
};
}

fn contra_fn<'a, 'b, 'upper, 'lower>(v: bool)
fn contra_fn<'a, 'b, 'lower>(v: bool)
where
'upper: 'a,
'upper: 'b,
'a: 'lower,
'b: 'lower,

Expand All @@ -43,10 +39,8 @@ where
};
}

fn contra_struct<'a, 'b, 'upper, 'lower>(v: bool)
fn contra_struct<'a, 'b, 'lower>(v: bool)
where
'upper: 'a,
'upper: 'b,
'a: 'lower,
'b: 'lower,

Expand Down
20 changes: 10 additions & 10 deletions src/test/ui/lub-glb/empty-binders-err.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: lifetime may not live long enough
--> $DIR/empty-binders-err.rs:22:12
--> $DIR/empty-binders-err.rs:20:12
|
LL | fn covariance<'a, 'b, 'upper, 'lower>(v: bool)
LL | fn covariance<'a, 'b, 'upper>(v: bool)
| -- ------ lifetime `'upper` defined here
| |
| lifetime `'a` defined here
Expand All @@ -12,9 +12,9 @@ LL | let _: &'upper () = match v {
= help: consider adding the following bound: `'a: 'upper`

error: lifetime may not live long enough
--> $DIR/empty-binders-err.rs:22:12
--> $DIR/empty-binders-err.rs:20:12
|
LL | fn covariance<'a, 'b, 'upper, 'lower>(v: bool)
LL | fn covariance<'a, 'b, 'upper>(v: bool)
| -- ------ lifetime `'upper` defined here
| |
| lifetime `'b` defined here
Expand All @@ -30,10 +30,10 @@ help: the following changes may resolve your lifetime errors
= help: add bound `'b: 'upper`

error: lifetime may not live long enough
--> $DIR/empty-binders-err.rs:39:12
--> $DIR/empty-binders-err.rs:35:12
|
LL | fn contra_fn<'a, 'b, 'upper, 'lower>(v: bool)
| -- ------ lifetime `'lower` defined here
LL | fn contra_fn<'a, 'b, 'lower>(v: bool)
| -- ------ lifetime `'lower` defined here
| |
| lifetime `'a` defined here
...
Expand All @@ -43,10 +43,10 @@ LL | let _: fn(&'lower ()) = match v {
= help: consider adding the following bound: `'lower: 'a`

error: lifetime may not live long enough
--> $DIR/empty-binders-err.rs:54:12
--> $DIR/empty-binders-err.rs:48:12
|
LL | fn contra_struct<'a, 'b, 'upper, 'lower>(v: bool)
| -- ------ lifetime `'lower` defined here
LL | fn contra_struct<'a, 'b, 'lower>(v: bool)
| -- ------ lifetime `'lower` defined here
| |
| lifetime `'a` defined here
...
Expand Down

0 comments on commit 0667b00

Please sign in to comment.