]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/recursive-impl-trait-type-indirect.rs
Be more careful about unresolved exprs in suggestion
[rust.git] / src / test / ui / impl-trait / recursive-impl-trait-type-indirect.rs
1 // Test that impl trait does not allow creating recursive types that are
2 // otherwise forbidden.
3
4 #![feature(generators)]
5 #![allow(unconditional_recursion)]
6
7 fn option(i: i32) -> impl Sized {
8     //~^ ERROR cannot resolve opaque type
9     if i < 0 { None } else { Some((option(i - 1), i)) }
10 }
11
12 fn tuple() -> impl Sized {
13     //~^ ERROR
14     (tuple(),)
15 }
16
17 fn array() -> impl Sized {
18     //~^ ERROR
19     [array()]
20 }
21
22 fn ptr() -> impl Sized {
23     //~^ ERROR
24     &ptr() as *const _
25 }
26
27 fn fn_ptr() -> impl Sized {
28     //~^ ERROR
29     fn_ptr as fn() -> _
30 }
31
32 fn closure_capture() -> impl Sized {
33     //~^ ERROR
34     let x = closure_capture();
35     move || {
36         x;
37     }
38 }
39
40 fn closure_ref_capture() -> impl Sized {
41     //~^ ERROR
42     let x = closure_ref_capture();
43     move || {
44         &x;
45     }
46 }
47
48 fn closure_sig() -> impl Sized {
49     //~^ ERROR
50     || closure_sig()
51 }
52
53 fn generator_sig() -> impl Sized {
54     //~^ ERROR
55     || generator_sig()
56 }
57
58 fn generator_capture() -> impl Sized {
59     //~^ ERROR
60     let x = generator_capture();
61     move || {
62         yield;
63         x;
64     }
65 }
66
67 fn substs_change<T: 'static>() -> impl Sized {
68     //~^ ERROR
69     (substs_change::<&T>(),)
70 }
71
72 fn generator_hold() -> impl Sized {
73     //~^ ERROR
74     move || {
75         let x = generator_hold();
76         yield;
77         x;
78     }
79 }
80
81 fn use_fn_ptr() -> impl Sized {
82     // OK, error already reported
83     fn_ptr()
84 }
85
86 fn mutual_recursion() -> impl Sync {
87     //~^ ERROR
88     mutual_recursion_b()
89 }
90
91 fn mutual_recursion_b() -> impl Sized {
92     //~^ ERROR
93     mutual_recursion()
94 }
95
96 fn main() {}