-
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.
Ensure opaque types can't have themselves as a hidden type with incom…
…patible lifetimes
- Loading branch information
Showing
8 changed files
with
98 additions
and
19 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
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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
error[E0720]: cannot resolve opaque type | ||
--> $DIR/issue-100075.rs:13:37 | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-100075.rs:15:16 | ||
| | ||
LL | fn _g<T>(t: &'static T) -> &'static impl Marker { | ||
| ^^^^^^^^^^^ recursive opaque type | ||
... | ||
| ----------- | ||
| | | ||
| the expected opaque type | ||
| the found opaque type | ||
LL | if let Some(t) = maybe(t) { | ||
LL | return _g(t); | ||
| ----- returning here with type `&impl Marker` | ||
| ^^^^^ expected type parameter `T`, found `&T` | ||
| | ||
= note: expected opaque type `impl Marker` (type parameter `T`) | ||
found opaque type `impl Marker` (`&T`) | ||
= note: distinct uses of `impl Trait` result in different opaque types | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0720`. | ||
For more information about this error, try `rustc --explain E0308`. |
14 changes: 14 additions & 0 deletions
14
tests/ui/type-alias-impl-trait/different_args_considered_equal.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,14 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
pub type Opaque<'a> = impl Sized; | ||
|
||
fn get_one<'a>(a: *mut &'a str) -> Opaque<'a> { | ||
a | ||
} | ||
|
||
fn get_iter<'a>() -> impl IntoIterator<Item = Opaque<'a>> { | ||
None::<Opaque<'static>> | ||
//~^ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
tests/ui/type-alias-impl-trait/different_args_considered_equal.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,10 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/different_args_considered_equal.rs:10:5 | ||
| | ||
LL | fn get_iter<'a>() -> impl IntoIterator<Item = Opaque<'a>> { | ||
| -- lifetime `'a` defined here | ||
LL | None::<Opaque<'static>> | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'a` must outlive `'static` | ||
|
||
error: aborting due to 1 previous error | ||
|