Skip to content

Commit e6c8596

Browse files
committed
Revert "Backport only: avoid ICE on bad placeholder type"
This reverts commit 1cb555a.
1 parent 6d69cab commit e6c8596

File tree

7 files changed

+68
-329
lines changed

7 files changed

+68
-329
lines changed

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
320320
}
321321

322322
fn ty_infer(&self, _: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> {
323-
placeholder_type_error(self.tcx(), span, &[], vec![span], false);
323+
self.tcx().sess.delay_span_bug(span, "bad placeholder type");
324324
self.tcx().types.err
325325
}
326326

src/test/ui/did_you_mean/bad-assoc-ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type D = (u8, u8)::AssocTy;
1717
type E = _::AssocTy;
1818
//~^ ERROR missing angle brackets in associated item path
1919
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
20-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
2120

2221
type F = &'static (u8)::AssocTy;
2322
//~^ ERROR missing angle brackets in associated item path

src/test/ui/did_you_mean/bad-assoc-ty.stderr

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ LL | type E = _::AssocTy;
2929
| ^^^^^^^^^^ help: try: `<_>::AssocTy`
3030

3131
error: missing angle brackets in associated item path
32-
--> $DIR/bad-assoc-ty.rs:22:19
32+
--> $DIR/bad-assoc-ty.rs:21:19
3333
|
3434
LL | type F = &'static (u8)::AssocTy;
3535
| ^^^^^^^^^^^^^ help: try: `<(u8)>::AssocTy`
3636

3737
error: missing angle brackets in associated item path
38-
--> $DIR/bad-assoc-ty.rs:28:10
38+
--> $DIR/bad-assoc-ty.rs:27:10
3939
|
4040
LL | type G = dyn 'static + (Send)::AssocTy;
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<dyn 'static + (Send)>::AssocTy`
4242

4343
error: missing angle brackets in associated item path
44-
--> $DIR/bad-assoc-ty.rs:45:10
44+
--> $DIR/bad-assoc-ty.rs:44:10
4545
|
4646
LL | type I = ty!()::AssocTy;
4747
| ^^^^^^^^^^^^^^ help: try: `<ty!()>::AssocTy`
4848

4949
error: missing angle brackets in associated item path
50-
--> $DIR/bad-assoc-ty.rs:38:19
50+
--> $DIR/bad-assoc-ty.rs:37:19
5151
|
5252
LL | ($ty: ty) => ($ty::AssocTy);
5353
| ^^^^^^^^^^^^ help: try: `<$ty>::AssocTy`
@@ -87,32 +87,26 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa
8787
LL | type E = _::AssocTy;
8888
| ^ not allowed in type signatures
8989

90-
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
91-
--> $DIR/bad-assoc-ty.rs:17:10
92-
|
93-
LL | type E = _::AssocTy;
94-
| ^ not allowed in type signatures
95-
9690
error[E0223]: ambiguous associated type
97-
--> $DIR/bad-assoc-ty.rs:22:19
91+
--> $DIR/bad-assoc-ty.rs:21:19
9892
|
9993
LL | type F = &'static (u8)::AssocTy;
10094
| ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`
10195

10296
error[E0223]: ambiguous associated type
103-
--> $DIR/bad-assoc-ty.rs:28:10
97+
--> $DIR/bad-assoc-ty.rs:27:10
10498
|
10599
LL | type G = dyn 'static + (Send)::AssocTy;
106100
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy`
107101

108102
error[E0223]: ambiguous associated type
109-
--> $DIR/bad-assoc-ty.rs:34:10
103+
--> $DIR/bad-assoc-ty.rs:33:10
110104
|
111105
LL | type H = Fn(u8) -> (u8)::Output;
112106
| ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output`
113107

114108
error[E0223]: ambiguous associated type
115-
--> $DIR/bad-assoc-ty.rs:38:19
109+
--> $DIR/bad-assoc-ty.rs:37:19
116110
|
117111
LL | ($ty: ty) => ($ty::AssocTy);
118112
| ^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`
@@ -123,12 +117,12 @@ LL | type J = ty!(u8);
123117
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
124118

125119
error[E0223]: ambiguous associated type
126-
--> $DIR/bad-assoc-ty.rs:45:10
120+
--> $DIR/bad-assoc-ty.rs:44:10
127121
|
128122
LL | type I = ty!()::AssocTy;
129123
| ^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`
130124

131-
error: aborting due to 20 previous errors
125+
error: aborting due to 19 previous errors
132126

133127
Some errors have detailed explanations: E0121, E0223.
134128
For more information about an error, try `rustc --explain E0121`.

src/test/ui/self/self-infer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ struct S;
22

33
impl S {
44
fn f(self: _) {} //~ERROR the type placeholder `_` is not allowed within types on item sig
5-
//~^ ERROR the type placeholder `_` is not allowed within types on item sig
65
fn g(self: &_) {} //~ERROR the type placeholder `_` is not allowed within types on item sig
7-
//~^ ERROR the type placeholder `_` is not allowed within types on item sig
86
}
97

108
fn main() {}

src/test/ui/self/self-infer.stderr

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
2-
--> $DIR/self-infer.rs:4:16
3-
|
4-
LL | fn f(self: _) {}
5-
| ^ not allowed in type signatures
6-
71
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
82
--> $DIR/self-infer.rs:4:16
93
|
@@ -16,13 +10,7 @@ LL | fn f<T>(self: T) {}
1610
| ^^^ ^
1711

1812
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
19-
--> $DIR/self-infer.rs:6:17
20-
|
21-
LL | fn g(self: &_) {}
22-
| ^ not allowed in type signatures
23-
24-
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
25-
--> $DIR/self-infer.rs:6:17
13+
--> $DIR/self-infer.rs:5:17
2614
|
2715
LL | fn g(self: &_) {}
2816
| ^ not allowed in type signatures
@@ -32,6 +20,6 @@ help: use type parameters instead
3220
LL | fn g<T>(self: &T) {}
3321
| ^^^ ^
3422

35-
error: aborting due to 4 previous errors
23+
error: aborting due to 2 previous errors
3624

3725
For more information about this error, try `rustc --explain E0121`.

src/test/ui/typeck/typeck_type_placeholder_item.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,19 @@ static TEST5: (_, _) = (1, 2);
1919

2020
fn test6(_: _) { }
2121
//~^ 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
2322

2423
fn test6_b<T>(_: _, _: T) { }
2524
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
26-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
2725

2826
fn test6_c<T, K, L, A, B>(_: _, _: (T, K, L, A, B)) { }
2927
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
30-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
3128

3229
fn test7(x: _) { let _x: usize = x; }
3330
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
34-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
3531

3632
fn test8(_f: fn() -> _) { }
3733
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
3834
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
39-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
4035

4136
struct Test9;
4237

@@ -46,7 +41,6 @@ impl Test9 {
4641

4742
fn test10(&self, _x : _) { }
4843
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
49-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
5044
}
5145

5246
fn test11(x: &usize) -> &_ {
@@ -65,16 +59,12 @@ impl Clone for Test9 {
6559

6660
fn clone_from(&mut self, other: _) { *self = Test9; }
6761
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
68-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
6962
}
7063

7164
struct Test10 {
7265
a: _,
7366
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
74-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
7567
b: (_, _),
76-
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
77-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
7868
}
7969

8070
pub fn main() {
@@ -102,16 +92,13 @@ pub fn main() {
10292

10393
fn fn_test6(_: _) { }
10494
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
105-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
10695

10796
fn fn_test7(x: _) { let _x: usize = x; }
10897
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
109-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
11098

11199
fn fn_test8(_f: fn() -> _) { }
112100
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
113101
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
114-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
115102

116103
struct FnTest9;
117104

@@ -121,7 +108,6 @@ pub fn main() {
121108

122109
fn fn_test10(&self, _x : _) { }
123110
//~^ 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
125111
}
126112

127113
impl Clone for FnTest9 {
@@ -130,16 +116,12 @@ pub fn main() {
130116

131117
fn clone_from(&mut self, other: _) { *self = FnTest9; }
132118
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
133-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
134119
}
135120

136121
struct FnTest10 {
137122
a: _,
138123
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
139-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
140124
b: (_, _),
141-
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
142-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
143125
}
144126

145127
fn fn_test11(_: _) -> (_, _) { panic!() }
@@ -156,40 +138,28 @@ pub fn main() {
156138
trait T {
157139
fn method_test1(&self, x: _);
158140
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
159-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
160141
fn method_test2(&self, x: _) -> _;
161142
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
162-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
163-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
164143
fn method_test3(&self) -> _;
165144
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
166-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
167145
fn assoc_fn_test1(x: _);
168146
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
169-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
170147
fn assoc_fn_test2(x: _) -> _;
171148
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
172-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
173-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
174149
fn assoc_fn_test3() -> _;
175150
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
176-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
177151
}
178152

179153
struct BadStruct<_>(_);
180154
//~^ ERROR expected identifier, found reserved identifier `_`
181155
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
182-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
183156
trait BadTrait<_> {}
184157
//~^ ERROR expected identifier, found reserved identifier `_`
185158
impl BadTrait<_> for BadStruct<_> {}
186159
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
187-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
188-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
189160

190161
fn impl_trait() -> impl BadTrait<_> {
191162
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
192-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
193163
unimplemented!()
194164
}
195165

@@ -198,22 +168,18 @@ struct BadStruct1<_, _>(_);
198168
//~| ERROR expected identifier, found reserved identifier `_`
199169
//~| ERROR the name `_` is already used
200170
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
201-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
202171
struct BadStruct2<_, T>(_, T);
203172
//~^ ERROR expected identifier, found reserved identifier `_`
204173
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
205-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
206174

207175
type X = Box<_>;
208176
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
209-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
210177

211178
struct Struct;
212179
trait Trait<T> {}
213180
impl Trait<usize> for Struct {}
214181
type Y = impl Trait<_>;
215182
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
216-
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
217183
fn foo() -> Y {
218184
Struct
219185
}

0 commit comments

Comments
 (0)