Fix an ICE with TAITs and Future
This commit is contained in:
parent
6cc0a764e0
commit
f001e8c519
3 changed files with 68 additions and 5 deletions
24
src/test/ui/type-alias-impl-trait/issue-89686.rs
Normal file
24
src/test/ui/type-alias-impl-trait/issue-89686.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// edition:2018
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
type G<'a, T> = impl Future<Output = ()>;
|
||||
//~^ ERROR: type mismatch resolving `<impl Future as Future>::Output == ()`
|
||||
//~| ERROR: the trait bound `T: Trait` is not satisfied
|
||||
|
||||
trait Trait {
|
||||
type F: Future<Output = ()>;
|
||||
|
||||
fn f(&self) -> Self::F;
|
||||
|
||||
fn g<'a>(&'a self) -> G<'a, Self>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
async move { self.f().await }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
34
src/test/ui/type-alias-impl-trait/issue-89686.stderr
Normal file
34
src/test/ui/type-alias-impl-trait/issue-89686.stderr
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
error[E0271]: type mismatch resolving `<impl Future as Future>::Output == ()`
|
||||
--> $DIR/issue-89686.rs:7:17
|
||||
|
|
||||
LL | type G<'a, T> = impl Future<Output = ()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
||||
...
|
||||
LL | async move { self.f().await }
|
||||
| ------------------ the found `async` block
|
||||
|
|
||||
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
|
||||
|
|
||||
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
|
||||
| ------------------------------- the found opaque type
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found associated type `<impl Future as Future>::Output`
|
||||
= help: consider constraining the associated type `<impl Future as Future>::Output` to `()`
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||
|
||||
error[E0277]: the trait bound `T: Trait` is not satisfied
|
||||
--> $DIR/issue-89686.rs:7:17
|
||||
|
|
||||
LL | type G<'a, T> = impl Future<Output = ()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
LL | type G<'a, T: Trait> = impl Future<Output = ()>;
|
||||
| +++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0271, E0277.
|
||||
For more information about an error, try `rustc --explain E0271`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue