-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cf7ab2
commit 5c69a5d
Showing
6 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
tests/ui/impl-trait/recursive/recursive-impl-trait-type-direct-with-earlybound-lifetime-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![allow(unconditional_recursion)] | ||
|
||
fn foo<'a: 'a>() -> impl Sized { | ||
let _: *mut &'a () = foo::<'a>(); | ||
//~^ ERROR | ||
loop {} | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
...i/impl-trait/recursive/recursive-impl-trait-type-direct-with-earlybound-lifetime-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
--> $DIR/recursive-impl-trait-type-direct-with-earlybound-lifetime-2.rs:4:12 | ||
| | ||
LL | fn foo<'a: 'a>() -> impl Sized { | ||
| -- ---------- opaque type defined here | ||
| | | ||
| hidden type `*mut &'a ()` captures the lifetime `'a` as defined here | ||
LL | let _: *mut &'a () = foo::<'a>(); | ||
| ^^^^^^^^^^^ | ||
| | ||
help: to declare that `impl Sized` captures `'a`, you can add an explicit `'a` lifetime bound | ||
| | ||
LL | fn foo<'a: 'a>() -> impl Sized + 'a { | ||
| ++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0700`. |
10 changes: 10 additions & 0 deletions
10
tests/ui/impl-trait/recursive/recursive-impl-trait-type-direct-with-earlybound-lifetime-3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// check-pass | ||
|
||
#![allow(unconditional_recursion)] | ||
|
||
fn foo<'a: 'a>() -> impl Sized + 'a { | ||
let _: *mut &'a () = foo::<'a>(); | ||
loop {} | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/impl-trait/recursive/recursive-impl-trait-type-direct-with-earlybound-lifetime-4.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![allow(unconditional_recursion)] | ||
|
||
trait Trait<'a, 'b> {} | ||
impl<'a, 'b, T> Trait<'a, 'b> for T {} | ||
|
||
fn foo<'a: 'a, 'b: 'b>() -> impl Trait<'a, 'b> { | ||
let _: *mut &'a () = foo::<'a, 'b>(); | ||
let _: *mut &'b () = foo::<'a, 'b>(); | ||
//~^ ERROR | ||
loop {} | ||
} | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
...i/impl-trait/recursive/recursive-impl-trait-type-direct-with-earlybound-lifetime-4.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: concrete type differs from previous defining opaque type use | ||
--> $DIR/recursive-impl-trait-type-direct-with-earlybound-lifetime-4.rs:8:12 | ||
| | ||
LL | let _: *mut &'b () = foo::<'a, 'b>(); | ||
| ^^^^^^^^^^^ expected `*mut &'a ()`, got `*mut &'b ()` | ||
| | ||
note: previous use here | ||
--> $DIR/recursive-impl-trait-type-direct-with-earlybound-lifetime-4.rs:7:12 | ||
| | ||
LL | let _: *mut &'a () = foo::<'a, 'b>(); | ||
| ^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
10 changes: 10 additions & 0 deletions
10
tests/ui/impl-trait/recursive/recursive-impl-trait-type-direct-with-earlybound-lifetime.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// check-pass | ||
|
||
#![allow(unconditional_recursion)] | ||
|
||
fn foo<'a: 'a>() -> impl Sized { | ||
let _: () = foo::<'a>(); | ||
loop {} | ||
} | ||
|
||
fn main() {} |