]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/recursive-impl-trait-type.rs
Rollup merge of #58802 - nnethercote:inline-record_layout, r=oli-obk
[rust.git] / src / test / ui / impl-trait / recursive-impl-trait-type.rs
1 // Test that impl trait does not allow creating recursive types that are
2 // otherwise forbidden.
3
4 #![feature(futures_api, generators)]
5
6 fn option(i: i32) -> impl Sized { //~ ERROR
7     if i < 0 {
8         None
9     } else {
10         Some((option(i - 1), i))
11     }
12 }
13
14 fn tuple() -> impl Sized { //~ ERROR
15     (tuple(),)
16 }
17
18 fn array() -> impl Sized { //~ ERROR
19     [array()]
20 }
21
22 fn ptr() -> impl Sized { //~ ERROR
23     &ptr() as *const _
24 }
25
26 fn fn_ptr() -> impl Sized { //~ ERROR
27     fn_ptr as fn() -> _
28 }
29
30 fn closure_capture() -> impl Sized { //~ ERROR
31     let x = closure_capture();
32     move || { x; }
33 }
34
35 fn closure_ref_capture() -> impl Sized { //~ ERROR
36     let x = closure_ref_capture();
37     move || { &x; }
38 }
39
40 fn closure_sig() -> impl Sized { //~ ERROR
41     || closure_sig()
42 }
43
44 fn generator_sig() -> impl Sized { //~ ERROR
45     || generator_sig()
46 }
47
48 fn generator_capture() -> impl Sized { //~ ERROR
49     let x = generator_capture();
50     move || { yield; x; }
51 }
52
53 fn substs_change<T>() -> impl Sized { //~ ERROR
54     (substs_change::<&T>(),)
55 }
56
57 fn generator_hold() -> impl Sized { //~ ERROR
58     move || {
59         let x = generator_hold();
60         yield;
61         x;
62     }
63 }
64
65 fn use_fn_ptr() -> impl Sized { // OK, error already reported
66     fn_ptr()
67 }
68
69 fn mutual_recursion() -> impl Sync { //~ ERROR
70     mutual_recursion_b()
71 }
72
73 fn mutual_recursion_b() -> impl Sized { //~ ERROR
74     mutual_recursion()
75 }
76
77 fn main() {}