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
45
46
47
48
49
50
51
  | 
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
// Test several spicy non-trivial recursive opaque definitions inferred from HIR typeck
// don't cause stack overflows in exhaustiveness code, which currently reveals opaques
// manually in a way that is not overflow aware.
//
// These should eventually be outright rejected, but today (some) non-trivial recursive
// opaque definitions are accepted, and changing that requires an FCP, so for now just
// make sure we don't stack overflow :^)
// Opaque<T> = Opaque<Opaque<T>>
//
// We unfortunately accept this today, and due to how opaque type relating is implemented
// in the NLL type relation, this defines `Opaque<T> = T`.
fn build<T>(x: T) -> impl Sized {
    //[current]~^ ERROR cannot resolve opaque type
    let (x,) = (build(x),);
    //[next]~^ ERROR type annotations needed
    build(x)
}
// Opaque<T> = (Opaque<T>,)
//
// Not allowed today. Detected as recursive.
fn build2<T>(x: T) -> impl Sized {
    //[current]~^ ERROR cannot resolve opaque type
    let (x,) = (build2(x),);
    (build2(x),)
    //[next]~^ ERROR type mismatch resolving
    //[next]~| ERROR type mismatch resolving
    //[next]~| ERROR the size for values of type
}
// Opaque<T> = Opaque<(T,)>
//
// Not allowed today. Detected as not defining.
fn build3<T>(x: T) -> impl Sized {
    //[current]~^ ERROR cannot resolve opaque type
    let (x,) = (build3((x,)),);
    //[next]~^ ERROR type mismatch resolving
    //[next]~| ERROR type mismatch resolving
    //[next]~| ERROR type mismatch resolving
    //[next]~| ERROR type mismatch resolving
    //[next]~| ERROR the size for values of type
    //[next]~| ERROR mismatched types
    build3(x)
}
fn main() {}
 
  |