about summary refs log tree commit diff
path: root/tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs
blob: 3e3e1dc50e58b942547e71295ba9d1ac103fb967 (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
//@ compile-flags: --crate-type=lib
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[current] check-pass
//@[next] compile-flags: -Znext-solver
//@[next] check-fail

// Test that we avoid incomplete inference when normalizing. Without this,
// `Trait`'s implicit `MetaSized` supertrait requires proving `T::Assoc<_>: MetaSized`
// before checking the `new` arguments, resulting in eagerly constraining the inference
// var to `u32`. This is undesirable and would breaking code.

pub trait Trait {
    type Assoc<G>: OtherTrait<G>;
}

pub trait OtherTrait<R> {
    fn new(r: R) -> R {
        r
    }
}

pub fn function<T: Trait>()
where
    T::Assoc<[u32; 1]>: Clone,
{
    let _x = T::Assoc::new(());
//[next]~^ ERROR mismatched types
}