Closed
Description
I tried this code:
#![feature(trait_upcasting)]
trait Mirror {
type Assoc;
}
impl<T> Mirror for T {
type Assoc = T;
}
trait Bar<T> {}
trait Foo<T>: Bar<<T as Mirror>::Assoc> {}
fn upcast<T>(x: &dyn Foo<T>) -> &dyn Bar<T> { x }
fn main() {}
I expected to see it compile.
Instead, this happened:
error[E0308]: mismatched types
--> <source>:13:47
|
13 | fn upcast<T>(x: &dyn Foo<T>) -> &dyn Bar<T> { x }
| ----------- ^ expected trait `Bar`, found trait `Foo`
| |
| expected `&dyn Bar<T>` because of return type
|
= note: expected reference `&dyn Bar<T>`
found reference `&dyn Foo<T>`
That's because we're missing a normalize_with_depth_to
call in trait upcasting confirmation.