]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/normalize-supertrait.rs
Rollup merge of #100953 - joshtriplett:write-docs, r=Mark-Simulacrum
[rust.git] / src / test / ui / traits / normalize-supertrait.rs
1 // Regression test for #77653
2 // When monomorphizing `f` we need to prove `dyn Derived<()>: Base<()>`. This
3 // requires us to normalize the `Base<<() as Proj>::S>` to `Base<()>` when
4 // comparing the supertrait `Derived<()>` to the expected trait.
5
6 // build-pass
7
8 trait Proj {
9     type S;
10 }
11
12 impl Proj for () {
13     type S = ();
14 }
15
16 impl Proj for i32 {
17     type S = i32;
18 }
19
20 trait Base<T> {
21     fn is_base(&self);
22 }
23
24 trait Derived<B: Proj>: Base<B::S> + Base<()> {
25     fn is_derived(&self);
26 }
27
28 fn f<P: Proj>(obj: &dyn Derived<P>) {
29     obj.is_derived();
30     Base::<P::S>::is_base(obj);
31     Base::<()>::is_base(obj);
32 }
33
34 fn main() {
35     let x: fn(_) = f::<()>;
36     let x: fn(_) = f::<i32>;
37 }