]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/typeck/typeck_type_placeholder_item.rs
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
39 fn test9(&self) -> _ { () }
40 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
42 fn test10(&self, _x
: _
) { }
43 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
46 fn test11(x
: &usize) -> &_
{
47 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
51 unsafe fn test12(x
: *const usize) -> *const *const _
{
52 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
56 impl Clone
for Test9
{
57 fn clone(&self) -> _ { Test9 }
58 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
60 fn clone_from(&mut self, other
: _
) { *self = Test9; }
61 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
66 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
72 //~^ ERROR missing type for `static` item
74 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
75 static C
: Option
<_
> = Some(42);
76 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
78 fn fn_test() -> _ { 5 }
79 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
81 fn fn_test2() -> (_
, _
) { (5, 5) }
82 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
84 static FN_TEST3
: _
= "test";
85 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
87 static FN_TEST4
: _
= 145;
88 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
90 static FN_TEST5
: (_
, _
) = (1, 2);
91 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
94 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
96 fn fn_test7(x
: _
) { let _x: usize = x; }
97 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
99 fn fn_test8(_f
: fn() -> _
) { }
100 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
105 fn fn_test9(&self) -> _ { () }
106 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
108 fn fn_test10(&self, _x
: _
) { }
109 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
112 impl Clone
for FnTest9
{
113 fn clone(&self) -> _ { FnTest9 }
114 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
116 fn clone_from(&mut self, other
: _
) { *self = FnTest9; }
117 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
122 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
126 fn fn_test11(_
: _
) -> (_
, _
) { panic!() }
127 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
128 //~| ERROR type annotations needed
130 fn fn_test12(x
: i32) -> (_
, _
) { (x, x) }
131 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
133 fn fn_test13(x
: _
) -> (i32, _
) { (x, x) }
134 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
138 fn method_test1(&self, x
: _
);
139 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
140 fn method_test2(&self, x
: _
) -> _
;
141 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
142 fn method_test3(&self) -> _
;
143 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
144 fn assoc_fn_test1(x
: _
);
145 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
146 fn assoc_fn_test2(x
: _
) -> _
;
147 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
148 fn assoc_fn_test3() -> _
;
149 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
152 struct BadStruct
<_
>(_
);
153 //~^ ERROR expected identifier, found reserved identifier `_`
154 //~| ERROR the type placeholder `_` is not allowed within types on item signatures
156 //~^ ERROR expected identifier, found reserved identifier `_`
157 impl BadTrait
<_
> for BadStruct
<_
> {}
158 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
160 fn impl_trait() -> impl BadTrait
<_
> {
161 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
165 struct BadStruct1
<_
, _
>(_
);
166 //~^ ERROR expected identifier, found reserved identifier `_`
167 //~| ERROR expected identifier, found reserved identifier `_`
168 //~| ERROR the name `_` is already used
169 //~| ERROR the type placeholder `_` is not allowed within types on item signatures
170 struct BadStruct2
<_
, T
>(_
, T
);
171 //~^ ERROR expected identifier, found reserved identifier `_`
172 //~| ERROR the type placeholder `_` is not allowed within types on item signatures
175 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
179 impl Trait
<usize> for Struct {}
180 type Y
= impl Trait
<_
>;
181 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
189 //~^ 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
194 // type E: _; // FIXME: make the parser propagate the existence of `B`
196 impl Qux
for Struct
{
198 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
200 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
202 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
203 //~| ERROR associated constant in `impl` without body
205 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures