1 // Needed for `type Y = impl Trait<_>` and `type B = _;`
2 #![feature(type_alias_impl_trait, associated_type_defaults)]
3 // This test checks that it is not possible to enable global type
4 // inference by using the `_` type placeholder.
7 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
9 fn test2() -> (_, _) { (5, 5) }
10 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
12 static TEST3: _ = "test";
13 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
15 static TEST4: _ = 145;
16 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
18 static TEST5: (_, _) = (1, 2);
19 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
22 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
24 fn test6_b<T>(_: _, _: T) { }
25 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
27 fn test6_c<T, K, L, A, B>(_: _, _: (T, K, L, A, B)) { }
28 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
30 fn test7(x: _) { let _x: usize = x; }
31 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
33 fn test8(_f: fn() -> _) { }
34 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
35 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
40 fn test9(&self) -> _ { () }
41 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
43 fn test10(&self, _x : _) { }
44 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
47 fn test11(x: &usize) -> &_ {
48 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
52 unsafe fn test12(x: *const usize) -> *const *const _ {
53 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
57 impl Clone for Test9 {
58 fn clone(&self) -> _ { Test9 }
59 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
61 fn clone_from(&mut self, other: _) { *self = Test9; }
62 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
67 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
73 //~^ ERROR missing type for `static` item
75 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
76 static C: Option<_> = Some(42);
77 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
79 fn fn_test() -> _ { 5 }
80 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
82 fn fn_test2() -> (_, _) { (5, 5) }
83 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
85 static FN_TEST3: _ = "test";
86 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
88 static FN_TEST4: _ = 145;
89 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
91 static FN_TEST5: (_, _) = (1, 2);
92 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
95 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
97 fn fn_test7(x: _) { let _x: usize = x; }
98 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
100 fn fn_test8(_f: fn() -> _) { }
101 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
102 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
107 fn fn_test9(&self) -> _ { () }
108 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
110 fn fn_test10(&self, _x : _) { }
111 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
114 impl Clone for FnTest9 {
115 fn clone(&self) -> _ { FnTest9 }
116 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
118 fn clone_from(&mut self, other: _) { *self = FnTest9; }
119 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
124 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
128 fn fn_test11(_: _) -> (_, _) { panic!() }
129 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
130 //~| ERROR type annotations needed
132 fn fn_test12(x: i32) -> (_, _) { (x, x) }
133 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
135 fn fn_test13(x: _) -> (i32, _) { (x, x) }
136 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
140 fn method_test1(&self, x: _);
141 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
142 fn method_test2(&self, x: _) -> _;
143 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
144 fn method_test3(&self) -> _;
145 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
146 fn assoc_fn_test1(x: _);
147 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
148 fn assoc_fn_test2(x: _) -> _;
149 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
150 fn assoc_fn_test3() -> _;
151 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
154 struct BadStruct<_>(_);
155 //~^ ERROR expected identifier, found reserved identifier `_`
156 //~| ERROR the type placeholder `_` is not allowed within types on item signatures
158 //~^ ERROR expected identifier, found reserved identifier `_`
159 impl BadTrait<_> for BadStruct<_> {}
160 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
162 fn impl_trait() -> impl BadTrait<_> {
163 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
167 struct BadStruct1<_, _>(_);
168 //~^ ERROR expected identifier, found reserved identifier `_`
169 //~| ERROR expected identifier, found reserved identifier `_`
170 //~| ERROR the name `_` is already used
171 //~| ERROR the type placeholder `_` is not allowed within types on item signatures
172 struct BadStruct2<_, T>(_, T);
173 //~^ ERROR expected identifier, found reserved identifier `_`
174 //~| ERROR the type placeholder `_` is not allowed within types on item signatures
177 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
181 impl Trait<usize> for Struct {}
182 type Y = impl Trait<_>;
183 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
191 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
193 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
195 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
196 // type E: _; // FIXME: make the parser propagate the existence of `B`
197 type F: std::ops::Fn(_);
198 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
200 impl Qux for Struct {
202 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
204 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
206 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
207 //~| ERROR associated constant in `impl` without body
209 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures