about summary refs log tree commit diff
path: root/tests/ui/traits/trait-upcasting/mono-impossible.rs
blob: f19f0538efa70a6522688bc8f9bc3510b2997d44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//@ build-pass

trait Supertrait<T> {
    fn method(&self) {}
}
impl<T> Supertrait<T> for () {}

trait WithAssoc {
    type Assoc;
}
trait Trait<P: WithAssoc>: Supertrait<P::Assoc> + Supertrait<()> {}

fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> {
    x
}

fn call<P>(x: &dyn Trait<P>) {
    x.method();
}

fn main() {
    println!("{:p}", upcast::<()> as *const ());
    println!("{:p}", call::<()> as *const ());
}