]>
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(associated_type_defaults)]
3 // revisions: min_tait full_tait
4 #![feature(min_type_alias_impl_trait)]
5 #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
6 //[full_tait]~^ WARN incomplete
7 // This test checks that it is not possible to enable global type
8 // inference by using the `_` type placeholder.
11 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
13 fn test2() -> (_
, _
) { (5, 5) }
14 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
16 static TEST3
: _
= "test";
17 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
19 static TEST4
: _
= 145;
20 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
22 static TEST5
: (_
, _
) = (1, 2);
23 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
26 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
28 fn test6_b
<T
>(_
: _
, _
: T
) { }
29 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
31 fn test6_c
<T
, K
, L
, A
, B
>(_
: _
, _
: (T
, K
, L
, A
, B
)) { }
32 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
34 fn test7(x
: _
) { let _x: usize = x; }
35 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
37 fn test8(_f
: fn() -> _
) { }
38 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
39 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
44 fn test9(&self) -> _ { () }
45 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
47 fn test10(&self, _x
: _
) { }
48 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
51 fn test11(x
: &usize) -> &_
{
52 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
56 unsafe fn test12(x
: *const usize) -> *const *const _
{
57 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
61 impl Clone
for Test9
{
62 fn clone(&self) -> _ { Test9 }
63 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
65 fn clone_from(&mut self, other
: _
) { *self = Test9; }
66 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
71 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for structs
77 //~^ ERROR missing type for `static` item
79 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
80 static C
: Option
<_
> = Some(42);
81 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
82 fn fn_test() -> _ { 5 }
83 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
85 fn fn_test2() -> (_
, _
) { (5, 5) }
86 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
88 static FN_TEST3
: _
= "test";
89 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
91 static FN_TEST4
: _
= 145;
92 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
94 static FN_TEST5
: (_
, _
) = (1, 2);
95 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables
98 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
100 fn fn_test7(x
: _
) { let _x: usize = x; }
101 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
103 fn fn_test8(_f
: fn() -> _
) { }
104 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
105 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
110 fn fn_test9(&self) -> _ { () }
111 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
113 fn fn_test10(&self, _x
: _
) { }
114 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
117 impl Clone
for FnTest9
{
118 fn clone(&self) -> _ { FnTest9 }
119 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
121 fn clone_from(&mut self, other
: _
) { *self = FnTest9; }
122 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
127 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for structs
131 fn fn_test11(_
: _
) -> (_
, _
) { panic!() }
132 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
133 //~| ERROR type annotations needed
135 fn fn_test12(x
: i32) -> (_
, _
) { (x, x) }
136 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
138 fn fn_test13(x
: _
) -> (i32, _
) { (x, x) }
139 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
143 fn method_test1(&self, x
: _
);
144 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
145 fn method_test2(&self, x
: _
) -> _
;
146 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
147 fn method_test3(&self) -> _
;
148 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
149 fn assoc_fn_test1(x
: _
);
150 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
151 fn assoc_fn_test2(x
: _
) -> _
;
152 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
153 fn assoc_fn_test3() -> _
;
154 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions
157 struct BadStruct
<_
>(_
);
158 //~^ ERROR expected identifier, found reserved identifier `_`
159 //~| ERROR the type placeholder `_` is not allowed within types on item signatures for structs
161 //~^ ERROR expected identifier, found reserved identifier `_`
162 impl BadTrait
<_
> for BadStruct
<_
> {}
163 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for implementations
165 fn impl_trait() -> impl BadTrait
<_
> {
166 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for opaque types
170 struct BadStruct1
<_
, _
>(_
);
171 //~^ ERROR expected identifier, found reserved identifier `_`
172 //~| ERROR expected identifier, found reserved identifier `_`
173 //~| ERROR the name `_` is already used
174 //~| ERROR the type placeholder `_` is not allowed within types on item signatures for structs
175 struct BadStruct2
<_
, T
>(_
, T
);
176 //~^ ERROR expected identifier, found reserved identifier `_`
177 //~| ERROR the type placeholder `_` is not allowed within types on item signatures for structs
180 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for type aliases
184 impl Trait
<usize> for Struct {}
185 type Y
= impl Trait
<_
>;
186 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for opaque types
194 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types
196 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants
198 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants
199 // type E: _; // FIXME: make the parser propagate the existence of `B`
200 type F
: std
::ops
::Fn(_
);
201 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types
203 impl Qux
for Struct
{
205 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types
207 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types
209 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants
210 //~| ERROR associated constant in `impl` without body
212 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants
215 fn map
<T
>(_
: fn() -> Option
<&'
static T
>) -> Option
<T
> {
219 fn value() -> Option
<&'
static _
> {
220 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types
221 Option
::<&'
static u8>::None
224 const _
: Option
<_
> = map(value
);
225 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants