Skip to content

Commit 5c69a5d

Browse files
committed
add tests in #111906
1 parent 0cf7ab2 commit 5c69a5d

6 files changed

+74
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![allow(unconditional_recursion)]
2+
3+
fn foo<'a: 'a>() -> impl Sized {
4+
let _: *mut &'a () = foo::<'a>();
5+
//~^ ERROR
6+
loop {}
7+
}
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds
2+
--> $DIR/recursive-impl-trait-type-direct-with-earlybound-lifetime-2.rs:4:12
3+
|
4+
LL | fn foo<'a: 'a>() -> impl Sized {
5+
| -- ---------- opaque type defined here
6+
| |
7+
| hidden type `*mut &'a ()` captures the lifetime `'a` as defined here
8+
LL | let _: *mut &'a () = foo::<'a>();
9+
| ^^^^^^^^^^^
10+
|
11+
help: to declare that `impl Sized` captures `'a`, you can add an explicit `'a` lifetime bound
12+
|
13+
LL | fn foo<'a: 'a>() -> impl Sized + 'a {
14+
| ++++
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0700`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
#![allow(unconditional_recursion)]
4+
5+
fn foo<'a: 'a>() -> impl Sized + 'a {
6+
let _: *mut &'a () = foo::<'a>();
7+
loop {}
8+
}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![allow(unconditional_recursion)]
2+
3+
trait Trait<'a, 'b> {}
4+
impl<'a, 'b, T> Trait<'a, 'b> for T {}
5+
6+
fn foo<'a: 'a, 'b: 'b>() -> impl Trait<'a, 'b> {
7+
let _: *mut &'a () = foo::<'a, 'b>();
8+
let _: *mut &'b () = foo::<'a, 'b>();
9+
//~^ ERROR
10+
loop {}
11+
}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: concrete type differs from previous defining opaque type use
2+
--> $DIR/recursive-impl-trait-type-direct-with-earlybound-lifetime-4.rs:8:12
3+
|
4+
LL | let _: *mut &'b () = foo::<'a, 'b>();
5+
| ^^^^^^^^^^^ expected `*mut &'a ()`, got `*mut &'b ()`
6+
|
7+
note: previous use here
8+
--> $DIR/recursive-impl-trait-type-direct-with-earlybound-lifetime-4.rs:7:12
9+
|
10+
LL | let _: *mut &'a () = foo::<'a, 'b>();
11+
| ^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
#![allow(unconditional_recursion)]
4+
5+
fn foo<'a: 'a>() -> impl Sized {
6+
let _: () = foo::<'a>();
7+
loop {}
8+
}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)