-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-trait_upcasting`#![feature(trait_upcasting)]``#![feature(trait_upcasting)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
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.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-trait_upcasting`#![feature(trait_upcasting)]``#![feature(trait_upcasting)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.