-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-async_fn_in_traitStatic async fn in traitsStatic async fn in traitsF-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]``#![feature(return_position_impl_trait_in_trait)]`F-specialization`#![feature(specialization)]``#![feature(specialization)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
#108203 didn't fully fix this. the bug still persists when using polymorphic indirection via specialization:
#![feature(async_fn_in_trait)]
#![feature(min_specialization)]
struct MyStruct;
trait MyTrait<T> {
async fn foo(_: T);
}
impl<T> MyTrait<T> for MyStruct {
default async fn foo(_: T) {
println!("default");
}
}
impl MyTrait<i32> for MyStruct {
async fn foo(_: i32) {
println!("specialized");
}
}
#[tokio::main]
async fn main() {
MyStruct::foo(42).await;
indirection(42).await;
}
async fn indirection<T>(x: T) {
//explicit type coercion is currently necessary because of https://github.com/rust-lang/rust/issues/67918
<MyStruct as MyTrait<T>>::foo(x).await;
}
(note that <MyStruct as MyTrait<i32>>::foo(42).await
works just fine, so #67918 probably isn't at fault)
output is
specialized
default
should be
specialized
specialized
Originally commented by @LastExceed em #107002 (comment)
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-async_fn_in_traitStatic async fn in traitsStatic async fn in traitsF-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]``#![feature(return_position_impl_trait_in_trait)]`F-specialization`#![feature(specialization)]``#![feature(specialization)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Non-blocking