rust/tests/ui/traits/trait-upcasting/upcast-defining-opaque.rs
Oli Scherer 7f292f41a0 Allow defining opaque types during trait object upcasting.
No stable code is affected, as this requires the `trait_upcasting` feature gate.
2024-05-23 16:02:20 +00:00

25 lines
412 B
Rust

//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)
//@check-pass
#![feature(trait_upcasting, type_alias_impl_trait)]
trait Super {
type Assoc;
}
trait Sub: Super {}
impl<T: ?Sized> Super for T {
type Assoc = i32;
}
type Foo = impl Sized;
fn upcast(x: &dyn Sub<Assoc = Foo>) -> &dyn Super<Assoc = i32> {
x
}
fn main() {}