-
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.
- Loading branch information
Showing
11 changed files
with
124 additions
and
35 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.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,18 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
trait Captures<'a> {} | ||
impl<T> Captures<'_> for T {} | ||
|
||
fn dyn_hoops<T: Sized>() -> dyn for<'a> Iterator<Item = impl Captures<'a>> { | ||
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type | ||
loop {} | ||
} | ||
|
||
pub fn main() { | ||
//~^ ERROR item does not constrain `Opaque::{opaque#0}`, but has it in its signature | ||
type Opaque = impl Sized; | ||
fn define() -> Opaque { | ||
let x: Opaque = dyn_hoops::<()>(); | ||
x | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.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,28 @@ | ||
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type | ||
--> $DIR/bound-lifetime-through-dyn-trait.rs:6:71 | ||
| | ||
LL | fn dyn_hoops<T: Sized>() -> dyn for<'a> Iterator<Item = impl Captures<'a>> { | ||
| ^^ | ||
| | ||
note: lifetime declared here | ||
--> $DIR/bound-lifetime-through-dyn-trait.rs:6:37 | ||
| | ||
LL | fn dyn_hoops<T: Sized>() -> dyn for<'a> Iterator<Item = impl Captures<'a>> { | ||
| ^^ | ||
|
||
error: item does not constrain `Opaque::{opaque#0}`, but has it in its signature | ||
--> $DIR/bound-lifetime-through-dyn-trait.rs:11:8 | ||
| | ||
LL | pub fn main() { | ||
| ^^^^ | ||
| | ||
= note: consider moving the opaque type's declaration and defining uses into a separate module | ||
note: this opaque type is in the signature | ||
--> $DIR/bound-lifetime-through-dyn-trait.rs:13:19 | ||
| | ||
LL | type Opaque = impl Sized; | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0657`. |
13 changes: 13 additions & 0 deletions
13
tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.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(incomplete_features)] | ||
#![feature(non_lifetime_binders)] | ||
|
||
trait Trait<T: ?Sized> {} | ||
|
||
fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> { | ||
//~^ ERROR associated type `Assoc` not found for `Trait` | ||
//~| ERROR associated type `Assoc` not found for `Trait` | ||
//~| the trait bound `{integer}: Trait<()>` is not satisfied | ||
16 | ||
} | ||
|
||
fn main() {} |
30 changes: 30 additions & 0 deletions
30
tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.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,30 @@ | ||
error[E0220]: associated type `Assoc` not found for `Trait` | ||
--> $DIR/non-lifetime-binder-in-constraint.rs:6:39 | ||
| | ||
LL | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> { | ||
| ^^^^^ associated type `Assoc` not found | ||
|
||
error[E0220]: associated type `Assoc` not found for `Trait` | ||
--> $DIR/non-lifetime-binder-in-constraint.rs:6:39 | ||
| | ||
LL | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> { | ||
| ^^^^^ associated type `Assoc` not found | ||
| | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error[E0277]: the trait bound `{integer}: Trait<()>` is not satisfied | ||
--> $DIR/non-lifetime-binder-in-constraint.rs:6:17 | ||
| | ||
LL | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<()>` is not implemented for `{integer}` | ||
| | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/non-lifetime-binder-in-constraint.rs:4:1 | ||
| | ||
LL | trait Trait<T: ?Sized> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0220, E0277. | ||
For more information about an error, try `rustc --explain E0220`. |
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 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(non_lifetime_binders)] | ||
|
||
trait Trait<T> {} | ||
|
||
fn f() -> impl for<T> Trait<impl Trait<T>> {} | ||
//~^ ERROR nested `impl Trait` is not allowed | ||
//~| ERROR the trait bound `(): Trait<impl Trait<T>>` is not satisfied | ||
|
||
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,25 @@ | ||
error[E0666]: nested `impl Trait` is not allowed | ||
--> $DIR/non-lifetime-binder.rs:6:29 | ||
| | ||
LL | fn f() -> impl for<T> Trait<impl Trait<T>> {} | ||
| ------------------^^^^^^^^^^^^^- | ||
| | | | ||
| | nested `impl Trait` here | ||
| outer `impl Trait` | ||
|
||
error[E0277]: the trait bound `(): Trait<impl Trait<T>>` is not satisfied | ||
--> $DIR/non-lifetime-binder.rs:6:11 | ||
| | ||
LL | fn f() -> impl for<T> Trait<impl Trait<T>> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<impl Trait<T>>` is not implemented for `()` | ||
| | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/non-lifetime-binder.rs:4:1 | ||
| | ||
LL | trait Trait<T> {} | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0666. | ||
For more information about an error, try `rustc --explain E0277`. |