-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't ICE on higher ranked hidden types
- Loading branch information
Showing
7 changed files
with
109 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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 @@ | ||
// The nested impl Trait references a higher-ranked region | ||
|
||
trait Trait<'a> { type Assoc; } | ||
impl<'a> Trait<'a> for () { type Assoc = &'a str; } | ||
|
||
fn test() -> impl for<'a> Trait<'a, Assoc = impl Sized> {} | ||
//~^ ERROR captures lifetime that does not appear in bounds | ||
|
||
fn main() {} |
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,12 @@ | ||
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
--> $DIR/nested-rpit-hrtb-2.rs:6:57 | ||
| | ||
LL | fn test() -> impl for<'a> Trait<'a, Assoc = impl Sized> {} | ||
| -- ---------- ^^ | ||
| | | | ||
| | opaque type defined here | ||
| hidden type `&'a str` captures the lifetime `'a` as defined here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0700`. |
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,15 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
trait Trait<'a> { type Assoc; } | ||
impl<'a> Trait<'a> for () { type Assoc = &'a str; } | ||
|
||
type WithoutLt = impl Sized; | ||
fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {} | ||
//~^ ERROR captures lifetime that does not appear in bounds | ||
|
||
type WithLt<'a> = impl Sized + 'a; | ||
//~^ ERROR concrete type differs from previous defining opaque type use | ||
fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {} | ||
//~^ ERROR expected generic lifetime parameter, found `'a` | ||
|
||
fn main() {} |
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,35 @@ | ||
error[E0700]: hidden type for `WithoutLt` captures lifetime that does not appear in bounds | ||
--> $DIR/nested-tait-hrtb.rs:7:62 | ||
| | ||
LL | type WithoutLt = impl Sized; | ||
| ---------- opaque type defined here | ||
LL | fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {} | ||
| -- ^^ | ||
| | | ||
| hidden type `&'a str` captures the lifetime `'a` as defined here | ||
|
||
error[E0792]: expected generic lifetime parameter, found `'a` | ||
--> $DIR/nested-tait-hrtb.rs:12:60 | ||
| | ||
LL | type WithLt<'a> = impl Sized + 'a; | ||
| -- this generic parameter must be used with a generic lifetime parameter | ||
LL | | ||
LL | fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {} | ||
| ^^ | ||
|
||
error: concrete type differs from previous defining opaque type use | ||
--> $DIR/nested-tait-hrtb.rs:10:19 | ||
| | ||
LL | type WithLt<'a> = impl Sized + 'a; | ||
| ^^^^^^^^^^^^^^^ expected `&'a str`, got `{type error}` | ||
| | ||
note: previous use here | ||
--> $DIR/nested-tait-hrtb.rs:12:17 | ||
| | ||
LL | fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0700, E0792. | ||
For more information about an error, try `rustc --explain E0700`. |