Skip to content

Commit c7f5216

Browse files
committed
add some fun tests
1 parent 5ee4525 commit c7f5216

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// We didn't have a single test mentioning
2+
// `ReEmpty` and this test changes that.
3+
fn foo<'a>(_a: &'a u32) where for<'b> &'b (): 'a {
4+
//~^ NOTE type must outlive the empty lifetime as required by this binding
5+
}
6+
7+
fn main() {
8+
foo(&10);
9+
//~^ ERROR the type `&'b ()` does not fulfill the required lifetime
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0477]: the type `&'b ()` does not fulfill the required lifetime
2+
--> $DIR/re-empty-in-error.rs:8:5
3+
|
4+
LL | foo(&10);
5+
| ^^^
6+
|
7+
note: type must outlive the empty lifetime as required by this binding
8+
--> $DIR/re-empty-in-error.rs:3:47
9+
|
10+
LL | fn foo<'a>(_a: &'a u32) where for<'b> &'b (): 'a {
11+
| ^^
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0477`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This test should compile, as the lifetimes
2+
// in matches don't really matter.
3+
//
4+
// We currently use contravariance when checking the
5+
// type of match arms.
6+
7+
trait Foo<'a> {
8+
const C: &'a u32;
9+
}
10+
11+
impl<'a, T> Foo<'a> for T {
12+
const C: &'a u32 = &22;
13+
}
14+
15+
fn foo<'a>(x: &'static u32) {
16+
match x {
17+
<() as Foo<'a>>::C => { }
18+
//~^ ERROR lifetime may not live long enough
19+
&_ => { }
20+
}
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/issue-57280-1-flipped.rs:17:9
3+
|
4+
LL | fn foo<'a>(x: &'static u32) {
5+
| -- lifetime `'a` defined here
6+
LL | match x {
7+
LL | <() as Foo<'a>>::C => { }
8+
| ^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
9+
10+
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)