Skip to content

Commit 6e04cf0

Browse files
committed
review comments: more tests
1 parent c751961 commit 6e04cf0

File tree

2 files changed

+195
-85
lines changed

2 files changed

+195
-85
lines changed

src/test/ui/typeck/typeck_type_placeholder_item.rs

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(type_alias_impl_trait)] // Needed for single test `type Y = impl Trait<_>`
12
// This test checks that it is not possible to enable global type
23
// inference by using the `_` type placeholder.
34

@@ -42,6 +43,16 @@ impl Test9 {
4243
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
4344
}
4445

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+
4556
impl Clone for Test9 {
4657
fn clone(&self) -> _ { Test9 }
4758
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
@@ -144,3 +155,24 @@ fn impl_trait() -> impl BadTrait<_> {
144155
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
145156
unimplemented!()
146157
}
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

Comments
 (0)