Weird interaction between specialization and RPITITs · Issue #108309 · rust-lang/rust (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
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 { async fn foo(_: T); }
impl MyTrait for MyStruct { default async fn foo(_: T) { println!("default"); } }
impl MyTrait for MyStruct { async fn foo(_: i32) { println!("specialized"); } }
#[tokio::main] async fn main() { MyStruct::foo(42).await; indirection(42).await; }
async fn indirection(x: T) { //explicit type coercion is currently necessary because of https://github.com/rust-lang/rust/issues/67918 <MyStruct as MyTrait>::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)