about summary refs log tree commit diff
path: root/tests/ui/traits/next-solver/normalize/eager-norm-pre-normalizes-to.rs
blob: ea18ac54c05574a5d8e6c198aacf784cc1d79324 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//@ check-pass
//@ compile-flags: -Znext-solver

// A regression test for trait-system-refactor-initiative#184.
//
// When adding nested goals we replace aliases with infer vars
// and add `AliasRelate` goals to constrain them. When doing this
// for `NormalizesTo` goals, we then first tries to prove the
// `NormalizesTo` goal and then normalized the nested aliases.

trait Trait<T> {
    type Assoc;
}
impl<T, U> Trait<U> for T {
    type Assoc = ();
}

trait Id {
    type This;
}
impl<T> Id for T {
    type This = T;
}
trait Relate<T> {
    type Alias;
}
impl<T, U> Relate<U> for T {
    type Alias = <T as Trait<<U as Id>::This>>::Assoc;
}


fn guide_me<T: Trait<u32>>() {
    // Normalizing `<T as Relate<i32>>::Alias` relates the associated type with an unconstrained
    // term. This resulted in a `NormalizesTo(<T as Trait<<U as Id>::This>>::Assoc, ?x)` goal.
    // We replace `<i32 as Id>::This` with an infer var `?y`, resulting in the following goals:
    // - `NormalizesTo(<T as Trait<?y>::Assoc, ?x)`
    // - `AliasRelate(<i32 as Id>::This, ?y)`
    //
    // When proving the `NormalizesTo` goal first, we incompletely constrain `?y` to `u32`,
    // causing an unexpected type mismatch.
    let _: <T as Relate<i32>>::Alias;
}

fn main() {}