Closed
Description
The condition seems complex, but a practical instance is async fn foo() -> Result<TAIT>
I tried this code:
#![feature(type_alias_impl_trait)]
trait Trait {}
type TAIT = impl Trait;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
fn foo() -> TAIT {
struct Bar;
impl Trait for Bar {}
Bar
}
async fn bar() -> Result<TAIT> {
Ok(foo())
}
I expected to see this happen: it compiles
Instead, this happened: error:
error: concrete type differs from previous defining opaque type use
--> src/tmp.rs:15:32
|
15 | async fn bar() -> Result<TAIT> {
| ________________________________^
16 | | Ok(foo())
17 | | }
| |_^ expected `Bar`, got `TAIT`
|
note: previous use here
--> src/tmp.rs:12:5
|
12 | Bar
| ^^^
Notes:
- It compiles in
nightly-2022-08-12
, but failed innightly-2022-09-13
fn() -> Result<TAIT>
works, andasync fn() -> Option<TAIT>
works
Meta
rustc --version --verbose
:
rustc 1.65.0-nightly (fa6ee9375 2022-09-12)
binary: rustc
commit-hash: fa6ee9375242ae784dab1837dfc0b92f43e787ce
commit-date: 2022-09-12
host: aarch64-apple-darwin
release: 1.65.0-nightly
LLVM version: 15.0.0
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done