|
| 1 | +#![feature(type_alias_impl_trait)] // Needed for single test `type Y = impl Trait<_>` |
1 | 2 | // This test checks that it is not possible to enable global type
|
2 | 3 | // inference by using the `_` type placeholder.
|
3 | 4 |
|
@@ -42,6 +43,16 @@ impl Test9 {
|
42 | 43 | //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
43 | 44 | }
|
44 | 45 |
|
| 46 | +fn test11(x: &usize) -> &_ { |
| 47 | +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures |
| 48 | + &x |
| 49 | +} |
| 50 | + |
| 51 | +unsafe fn test12(x: *const usize) -> *const *const _ { |
| 52 | +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures |
| 53 | + &x |
| 54 | +} |
| 55 | + |
45 | 56 | impl Clone for Test9 {
|
46 | 57 | fn clone(&self) -> _ { Test9 }
|
47 | 58 | //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
@@ -144,3 +155,24 @@ fn impl_trait() -> impl BadTrait<_> {
|
144 | 155 | //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
145 | 156 | unimplemented!()
|
146 | 157 | }
|
| 158 | + |
| 159 | +struct BadStruct1<_, _>(_); |
| 160 | +//~^ ERROR expected identifier, found reserved identifier `_` |
| 161 | +//~| ERROR expected identifier, found reserved identifier `_` |
| 162 | +//~| ERROR the name `_` is already used |
| 163 | +//~| ERROR the type placeholder `_` is not allowed within types on item signatures |
| 164 | +struct BadStruct2<_, T>(_, T); |
| 165 | +//~^ ERROR expected identifier, found reserved identifier `_` |
| 166 | +//~| ERROR the type placeholder `_` is not allowed within types on item signatures |
| 167 | + |
| 168 | +type X = Box<_>; |
| 169 | +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures |
| 170 | + |
| 171 | +struct Struct; |
| 172 | +trait Trait<T> {} |
| 173 | +impl Trait<usize> for Struct {} |
| 174 | +type Y = impl Trait<_>; |
| 175 | +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures |
| 176 | +fn foo() -> Y { |
| 177 | + Struct |
| 178 | +} |
0 commit comments