Closed
Description
Code
I tried this code:
#![feature(type_alias_impl_trait)]
trait SomeTrait {}
impl SomeTrait for () {}
trait MyFuture {
type Output;
}
impl<T> MyFuture for T {
type Output = T;
}
trait ReturnsFuture {
type Output: SomeTrait;
type Future: MyFuture<Output=Result<Self::Output, ()>>;
fn func() -> Self::Future;
}
struct Foo;
impl ReturnsFuture for Foo {
type Output = impl SomeTrait;
type Future = impl MyFuture<Output=Result<Self::Output, ()>>;
fn func() -> Self::Future {
Result::<(), ()>::Err(())
}
}
I expected to see this happen: code compiles successfully
Instead, this happened:
error[E0271]: type mismatch resolving `<Result<(), ()> as MyFuture>::Output == Result<impl SomeTrait, ()>`
--> ./demo.rs:24:18
|
22 | type Output = impl SomeTrait;
| -------------- the expected opaque type
23 | type Future = impl MyFuture<Output=Result<Self::Output, ()>>;
24 | fn func() -> Self::Future {
| ^^^^^^^^^^^^ expected opaque type, found `()`
|
= note: expected enum `Result<impl SomeTrait, _>`
found enum `Result<(), _>`
error: could not find defining uses
--> ./demo.rs:22:19
|
22 | type Output = impl SomeTrait;
| ^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Version it worked on
rustc --version --verbose
:
rustc 1.57.0-nightly (5ecc8ad84 2021-09-19)
binary: rustc
commit-hash: 5ecc8ad8462574354a55162a0c16b10eb95e3e70
commit-date: 2021-09-19
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0
Version with regression
rustc --version --verbose
:
rustc 1.57.0-nightly (ac2d9fc50 2021-09-21)
binary: rustc
commit-hash: ac2d9fc509e36d1b32513744adf58c34bcc4f43c
commit-date: 2021-09-21
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0
@rustbot modify labels: +requires-nightly +F-type_alias_impl_trait
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done