]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/wf-eval-order.rs
Auto merge of #83339 - Aaron1011:deep-recollect, r=petrochenkov
[rust.git] / src / test / ui / impl-trait / wf-eval-order.rs
1 // Check that we handle evaluating `wf` predicates correctly.
2
3 // check-pass
4
5 struct X<T: B>(T)
6 where
7     T::V: Clone;
8
9 fn hide<T>(t: T) -> impl Sized {
10     t
11 }
12
13 trait A {
14     type U;
15 }
16
17 impl<T> A for T {
18     type U = T;
19 }
20
21 trait B {
22     type V;
23 }
24
25 impl<S: A<U = T>, T> B for S {
26     type V = T;
27 }
28
29 fn main() {
30     // Evaluating `typeof(x): Sized` requires
31     //
32     // - `wf(typeof(x))` because we use a projection candidate.
33     // - `<i32 as B>::V: Clone` because that's a bound on the trait.
34     // - `<i32 as B>::V` normalizes to `_#1` where `<i32 as A>::U == _#1`
35     //
36     // This all works if we evaluate `<i32 as A>::U == _#1` before
37     // `<i32 as B>::V`, but we previously had the opposite order.
38     let x = hide(X(0));
39 }