about summary refs log tree commit diff
path: root/tests/ui/impl-trait/non-defining-uses/use-item-bound-over-blanket-impl.rs
blob: 7c2766ade3fa51bfc9e39d192efafe562feb1778 (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
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)
//@ check-pass
#![allow(unconditional_recursion)]

// Regression test for trait-system-refactor-initiative#182.

trait Id {
    type This;
}
impl<T> Id for T {
    type This = T;
}
fn to_assoc<T>(x: T) -> <T as Id>::This {
    x
}

fn mirror<T>(x: Vec<T>) -> impl Id<This = Vec<T>> {
    let x = to_assoc(mirror(x));
    // `?x` equals `<opaque::<T> as Id>::This`. We need to eagerly infer the
    // type of `?x` to prevent this method call from resulting in an error.
    //
    // We could use both the item bound to normalize to `Vec<T>`, or the
    // blanket impl to normalize to `opaque::<T>`. We have to go with the
    // item bound.
    x.len();
    x
}
fn main() {}