rust/tests/ui/traits/trait-upcasting/fewer-associated.rs
Urgau 4c2d6de70e Stabilize RFC3324 dyn upcasting coercion
Aka trait_upcasting feature.

And also adjust the `deref_into_dyn_supertrait` lint.
2023-11-22 13:56:36 +01:00

24 lines
597 B
Rust

// check-pass
// issue: 114035
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
trait A: B {
type Assoc;
}
trait B {}
fn upcast(a: &dyn A<Assoc = i32>) -> &dyn B {
a
}
// Make sure that we can drop the existential projection `A::Assoc = i32`
// when upcasting `dyn A<Assoc = i32>` to `dyn B`. Before, we used some
// complicated algorithm which required rebuilding a new object type with
// different bounds in order to test that an upcast was valid, but this
// didn't allow upcasting to t that have fewer associated types
// than the source type.
fn main() {}