diff options
| author | Yuki Okushi <yuki.okushi@huawei.com> | 2021-10-16 18:30:37 +0900 |
|---|---|---|
| committer | Yuki Okushi <yuki.okushi@huawei.com> | 2021-10-16 18:30:37 +0900 |
| commit | f001e8c519c68a2233e56ea64b4bfe8c7fedf0ea (patch) | |
| tree | 88c150dc6b7c428c76032a625694931660468970 /src/test | |
| parent | 6cc0a764e082d9c0abcf37a768d5889247ba13e2 (diff) | |
| download | rust-f001e8c519c68a2233e56ea64b4bfe8c7fedf0ea.tar.gz rust-f001e8c519c68a2233e56ea64b4bfe8c7fedf0ea.zip | |
Fix an ICE with TAITs and Future
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/issue-89686.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/issue-89686.stderr | 34 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.rs b/src/test/ui/type-alias-impl-trait/issue-89686.rs new file mode 100644 index 00000000000..2b6ce49e7e2 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-89686.rs @@ -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() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.stderr b/src/test/ui/type-alias-impl-trait/issue-89686.stderr new file mode 100644 index 00000000000..accc84d30a7 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-89686.stderr @@ -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`. |
