Skip to content

Commit 11429b2

Browse files
authored
Rollup merge of #59321 - varkor:unify-E0109-E0110-E0111, r=davidtwco
Unify E0109, E0110 and E0111 Error messages should no longer be restricted to specific generic kinds.
2 parents f1f3470 + aff175b commit 11429b2

35 files changed

+206
-223
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,37 +1486,34 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
14861486
segment.with_generic_args(|generic_args| {
14871487
let (mut err_for_lt, mut err_for_ty, mut err_for_ct) = (false, false, false);
14881488
for arg in &generic_args.args {
1489-
let (mut span_err, span, kind) = match arg {
1490-
// FIXME(varkor): unify E0109, E0110 and E0111.
1489+
let (span, kind) = match arg {
14911490
hir::GenericArg::Lifetime(lt) => {
14921491
if err_for_lt { continue }
14931492
err_for_lt = true;
14941493
has_err = true;
1495-
(struct_span_err!(self.tcx().sess, lt.span, E0110,
1496-
"lifetime arguments are not allowed on this entity"),
1497-
lt.span,
1498-
"lifetime")
1494+
(lt.span, "lifetime")
14991495
}
15001496
hir::GenericArg::Type(ty) => {
15011497
if err_for_ty { continue }
15021498
err_for_ty = true;
15031499
has_err = true;
1504-
(struct_span_err!(self.tcx().sess, ty.span, E0109,
1505-
"type arguments are not allowed on this entity"),
1506-
ty.span,
1507-
"type")
1500+
(ty.span, "type")
15081501
}
15091502
hir::GenericArg::Const(ct) => {
15101503
if err_for_ct { continue }
15111504
err_for_ct = true;
1512-
(struct_span_err!(self.tcx().sess, ct.span, E0111,
1513-
"const parameters are not allowed on this type"),
1514-
ct.span,
1515-
"const")
1505+
(ct.span, "const")
15161506
}
15171507
};
1518-
span_err.span_label(span, format!("{} argument not allowed", kind))
1519-
.emit();
1508+
let mut err = struct_span_err!(
1509+
self.tcx().sess,
1510+
span,
1511+
E0109,
1512+
"{} arguments are not allowed for this type",
1513+
kind,
1514+
);
1515+
err.span_label(span, format!("{} argument not allowed", kind));
1516+
err.emit();
15201517
if err_for_lt && err_for_ty && err_for_ct {
15211518
break;
15221519
}

src/librustc_typeck/diagnostics.rs

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,45 +1290,34 @@ fn main() {
12901290
"##,
12911291

12921292
E0109: r##"
1293-
You tried to give a type parameter to a type which doesn't need it. Erroneous
1294-
code example:
1293+
You tried to provide a generic argument to a type which doesn't need it.
1294+
Erroneous code example:
12951295
12961296
```compile_fail,E0109
1297-
type X = u32<i32>; // error: type arguments are not allowed on this entity
1297+
type X = u32<i32>; // error: type arguments are not allowed for this type
1298+
type Y = bool<'static>; // error: lifetime parameters are not allowed on
1299+
// this type
12981300
```
12991301
1300-
Please check that you used the correct type and recheck its definition. Perhaps
1301-
it doesn't need the type parameter.
1302+
Check that you used the correct argument and that the definition is correct.
13021303
13031304
Example:
13041305
13051306
```
1306-
type X = u32; // this compiles
1307+
type X = u32; // ok!
1308+
type Y = bool; // ok!
13071309
```
13081310
1309-
Note that type parameters for enum-variant constructors go after the variant,
1310-
not after the enum (`Option::None::<u32>`, not `Option::<u32>::None`).
1311+
Note that generic arguments for enum variant constructors go after the variant,
1312+
not after the enum. For example, you would write `Option::None::<u32>`,
1313+
rather than `Option::<u32>::None`.
13111314
"##,
13121315

13131316
E0110: r##"
1314-
You tried to give a lifetime parameter to a type which doesn't need it.
1315-
Erroneous code example:
1316-
1317-
```compile_fail,E0110
1318-
type X = u32<'static>; // error: lifetime parameters are not allowed on
1319-
// this type
1320-
```
1321-
1322-
Please check that the correct type was used and recheck its definition; perhaps
1323-
it doesn't need the lifetime parameter. Example:
1324-
1325-
```
1326-
type X = u32; // ok!
1327-
```
1328-
"##,
1317+
#### Note: this error code is no longer emitted by the compiler.
13291318
1330-
E0111: r##"
1331-
You tried to give a const parameter to a type which doesn't need it.
1319+
You tried to provide a lifetime to a type which doesn't need it.
1320+
See `E0109` for more details.
13321321
"##,
13331322

13341323
E0116: r##"

src/test/ui/enum-variant-generic-args.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ impl<T> Enum<T> {
99
Self::TSVariant(());
1010
//~^ ERROR mismatched types [E0308]
1111
Self::TSVariant::<()>(());
12-
//~^ ERROR type arguments are not allowed on this entity [E0109]
12+
//~^ ERROR type arguments are not allowed for this type [E0109]
1313
Self::<()>::TSVariant(());
14-
//~^ ERROR type arguments are not allowed on this entity [E0109]
14+
//~^ ERROR type arguments are not allowed for this type [E0109]
1515
//~^^ ERROR mismatched types [E0308]
1616
Self::<()>::TSVariant::<()>(());
17-
//~^ ERROR type arguments are not allowed on this entity [E0109]
18-
//~^^ ERROR type arguments are not allowed on this entity [E0109]
17+
//~^ ERROR type arguments are not allowed for this type [E0109]
18+
//~^^ ERROR type arguments are not allowed for this type [E0109]
1919
}
2020

2121
fn s_variant() {
2222
Self::SVariant { v: () };
2323
//~^ ERROR mismatched types [E0308]
2424
Self::SVariant::<()> { v: () };
25-
//~^ ERROR type arguments are not allowed on this entity [E0109]
25+
//~^ ERROR type arguments are not allowed for this type [E0109]
2626
//~^^ ERROR mismatched types [E0308]
2727
Self::<()>::SVariant { v: () };
28-
//~^ ERROR type arguments are not allowed on this entity [E0109]
28+
//~^ ERROR type arguments are not allowed for this type [E0109]
2929
//~^^ ERROR mismatched types [E0308]
3030
Self::<()>::SVariant::<()> { v: () };
31-
//~^ ERROR type arguments are not allowed on this entity [E0109]
32-
//~^^ ERROR type arguments are not allowed on this entity [E0109]
31+
//~^ ERROR type arguments are not allowed for this type [E0109]
32+
//~^^ ERROR type arguments are not allowed for this type [E0109]
3333
//~^^^ ERROR mismatched types [E0308]
3434
}
3535
}
@@ -38,36 +38,36 @@ fn main() {
3838
// Tuple struct variant
3939

4040
Enum::<()>::TSVariant::<()>(());
41-
//~^ ERROR type arguments are not allowed on this entity [E0109]
41+
//~^ ERROR type arguments are not allowed for this type [E0109]
4242

4343
Alias::TSVariant::<()>(());
44-
//~^ ERROR type arguments are not allowed on this entity [E0109]
44+
//~^ ERROR type arguments are not allowed for this type [E0109]
4545
Alias::<()>::TSVariant::<()>(());
46-
//~^ ERROR type arguments are not allowed on this entity [E0109]
46+
//~^ ERROR type arguments are not allowed for this type [E0109]
4747

4848
AliasFixed::TSVariant::<()>(());
49-
//~^ ERROR type arguments are not allowed on this entity [E0109]
49+
//~^ ERROR type arguments are not allowed for this type [E0109]
5050
AliasFixed::<()>::TSVariant(());
5151
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
5252
AliasFixed::<()>::TSVariant::<()>(());
53-
//~^ ERROR type arguments are not allowed on this entity [E0109]
53+
//~^ ERROR type arguments are not allowed for this type [E0109]
5454
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
5555

5656
// Struct variant
5757

5858
Enum::<()>::SVariant::<()> { v: () };
59-
//~^ ERROR type arguments are not allowed on this entity [E0109]
59+
//~^ ERROR type arguments are not allowed for this type [E0109]
6060

6161
Alias::SVariant::<()> { v: () };
62-
//~^ ERROR type arguments are not allowed on this entity [E0109]
62+
//~^ ERROR type arguments are not allowed for this type [E0109]
6363
Alias::<()>::SVariant::<()> { v: () };
64-
//~^ ERROR type arguments are not allowed on this entity [E0109]
64+
//~^ ERROR type arguments are not allowed for this type [E0109]
6565

6666
AliasFixed::SVariant::<()> { v: () };
67-
//~^ ERROR type arguments are not allowed on this entity [E0109]
67+
//~^ ERROR type arguments are not allowed for this type [E0109]
6868
AliasFixed::<()>::SVariant { v: () };
6969
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
7070
AliasFixed::<()>::SVariant::<()> { v: () };
71-
//~^ ERROR type arguments are not allowed on this entity [E0109]
71+
//~^ ERROR type arguments are not allowed for this type [E0109]
7272
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
7373
}

src/test/ui/enum-variant-generic-args.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ LL | Self::TSVariant(());
77
= note: expected type `T`
88
found type `()`
99

10-
error[E0109]: type arguments are not allowed on this entity
10+
error[E0109]: type arguments are not allowed for this type
1111
--> $DIR/enum-variant-generic-args.rs:11:27
1212
|
1313
LL | Self::TSVariant::<()>(());
1414
| ^^ type argument not allowed
1515

16-
error[E0109]: type arguments are not allowed on this entity
16+
error[E0109]: type arguments are not allowed for this type
1717
--> $DIR/enum-variant-generic-args.rs:13:16
1818
|
1919
LL | Self::<()>::TSVariant(());
@@ -28,13 +28,13 @@ LL | Self::<()>::TSVariant(());
2828
= note: expected type `T`
2929
found type `()`
3030

31-
error[E0109]: type arguments are not allowed on this entity
31+
error[E0109]: type arguments are not allowed for this type
3232
--> $DIR/enum-variant-generic-args.rs:16:16
3333
|
3434
LL | Self::<()>::TSVariant::<()>(());
3535
| ^^ type argument not allowed
3636

37-
error[E0109]: type arguments are not allowed on this entity
37+
error[E0109]: type arguments are not allowed for this type
3838
--> $DIR/enum-variant-generic-args.rs:16:33
3939
|
4040
LL | Self::<()>::TSVariant::<()>(());
@@ -49,7 +49,7 @@ LL | Self::SVariant { v: () };
4949
= note: expected type `T`
5050
found type `()`
5151

52-
error[E0109]: type arguments are not allowed on this entity
52+
error[E0109]: type arguments are not allowed for this type
5353
--> $DIR/enum-variant-generic-args.rs:24:26
5454
|
5555
LL | Self::SVariant::<()> { v: () };
@@ -64,7 +64,7 @@ LL | Self::SVariant::<()> { v: () };
6464
= note: expected type `T`
6565
found type `()`
6666

67-
error[E0109]: type arguments are not allowed on this entity
67+
error[E0109]: type arguments are not allowed for this type
6868
--> $DIR/enum-variant-generic-args.rs:27:16
6969
|
7070
LL | Self::<()>::SVariant { v: () };
@@ -79,13 +79,13 @@ LL | Self::<()>::SVariant { v: () };
7979
= note: expected type `T`
8080
found type `()`
8181

82-
error[E0109]: type arguments are not allowed on this entity
82+
error[E0109]: type arguments are not allowed for this type
8383
--> $DIR/enum-variant-generic-args.rs:30:16
8484
|
8585
LL | Self::<()>::SVariant::<()> { v: () };
8686
| ^^ type argument not allowed
8787

88-
error[E0109]: type arguments are not allowed on this entity
88+
error[E0109]: type arguments are not allowed for this type
8989
--> $DIR/enum-variant-generic-args.rs:30:32
9090
|
9191
LL | Self::<()>::SVariant::<()> { v: () };
@@ -100,25 +100,25 @@ LL | Self::<()>::SVariant::<()> { v: () };
100100
= note: expected type `T`
101101
found type `()`
102102

103-
error[E0109]: type arguments are not allowed on this entity
103+
error[E0109]: type arguments are not allowed for this type
104104
--> $DIR/enum-variant-generic-args.rs:40:29
105105
|
106106
LL | Enum::<()>::TSVariant::<()>(());
107107
| ^^ type argument not allowed
108108

109-
error[E0109]: type arguments are not allowed on this entity
109+
error[E0109]: type arguments are not allowed for this type
110110
--> $DIR/enum-variant-generic-args.rs:43:24
111111
|
112112
LL | Alias::TSVariant::<()>(());
113113
| ^^ type argument not allowed
114114

115-
error[E0109]: type arguments are not allowed on this entity
115+
error[E0109]: type arguments are not allowed for this type
116116
--> $DIR/enum-variant-generic-args.rs:45:30
117117
|
118118
LL | Alias::<()>::TSVariant::<()>(());
119119
| ^^ type argument not allowed
120120

121-
error[E0109]: type arguments are not allowed on this entity
121+
error[E0109]: type arguments are not allowed for this type
122122
--> $DIR/enum-variant-generic-args.rs:48:29
123123
|
124124
LL | AliasFixed::TSVariant::<()>(());
@@ -136,31 +136,31 @@ error[E0107]: wrong number of type arguments: expected 0, found 1
136136
LL | AliasFixed::<()>::TSVariant::<()>(());
137137
| ^^ unexpected type argument
138138

139-
error[E0109]: type arguments are not allowed on this entity
139+
error[E0109]: type arguments are not allowed for this type
140140
--> $DIR/enum-variant-generic-args.rs:52:35
141141
|
142142
LL | AliasFixed::<()>::TSVariant::<()>(());
143143
| ^^ type argument not allowed
144144

145-
error[E0109]: type arguments are not allowed on this entity
145+
error[E0109]: type arguments are not allowed for this type
146146
--> $DIR/enum-variant-generic-args.rs:58:28
147147
|
148148
LL | Enum::<()>::SVariant::<()> { v: () };
149149
| ^^ type argument not allowed
150150

151-
error[E0109]: type arguments are not allowed on this entity
151+
error[E0109]: type arguments are not allowed for this type
152152
--> $DIR/enum-variant-generic-args.rs:61:23
153153
|
154154
LL | Alias::SVariant::<()> { v: () };
155155
| ^^ type argument not allowed
156156

157-
error[E0109]: type arguments are not allowed on this entity
157+
error[E0109]: type arguments are not allowed for this type
158158
--> $DIR/enum-variant-generic-args.rs:63:29
159159
|
160160
LL | Alias::<()>::SVariant::<()> { v: () };
161161
| ^^ type argument not allowed
162162

163-
error[E0109]: type arguments are not allowed on this entity
163+
error[E0109]: type arguments are not allowed for this type
164164
--> $DIR/enum-variant-generic-args.rs:66:28
165165
|
166166
LL | AliasFixed::SVariant::<()> { v: () };
@@ -178,7 +178,7 @@ error[E0107]: wrong number of type arguments: expected 0, found 1
178178
LL | AliasFixed::<()>::SVariant::<()> { v: () };
179179
| ^^ unexpected type argument
180180

181-
error[E0109]: type arguments are not allowed on this entity
181+
error[E0109]: type arguments are not allowed for this type
182182
--> $DIR/enum-variant-generic-args.rs:70:34
183183
|
184184
LL | AliasFixed::<()>::SVariant::<()> { v: () };

src/test/ui/error-codes/E0109.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0109]: type arguments are not allowed on this entity
1+
error[E0109]: type arguments are not allowed for this type
22
--> $DIR/E0109.rs:1:14
33
|
44
LL | type X = u32<i32>;

src/test/ui/error-codes/E0110.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
type X = u32<'static>; //~ ERROR E0110
1+
type X = u32<'static>; //~ ERROR E0109
22

33
fn main() {}

src/test/ui/error-codes/E0110.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
error[E0110]: lifetime arguments are not allowed on this entity
1+
error[E0109]: lifetime arguments are not allowed for this type
22
--> $DIR/E0110.rs:1:14
33
|
44
LL | type X = u32<'static>;
55
| ^^^^^^^ lifetime argument not allowed
66

77
error: aborting due to previous error
88

9-
For more information about this error, try `rustc --explain E0110`.
9+
For more information about this error, try `rustc --explain E0109`.

src/test/ui/issues/issue-22706.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn is_copy<T: ::std::marker<i32>::Copy>() {}
2-
//~^ ERROR type arguments are not allowed on this entity [E0109]
2+
//~^ ERROR type arguments are not allowed for this type [E0109]
33
fn main() {}

src/test/ui/issues/issue-22706.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0109]: type arguments are not allowed on this entity
1+
error[E0109]: type arguments are not allowed for this type
22
--> $DIR/issue-22706.rs:1:29
33
|
44
LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}

src/test/ui/mod-subitem-as-enum-variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ mod Mod {
66
fn main() {
77
Mod::FakeVariant::<i32>(0);
88
Mod::<i32>::FakeVariant(0);
9-
//~^ ERROR type arguments are not allowed on this entity [E0109]
9+
//~^ ERROR type arguments are not allowed for this type [E0109]
1010
}

src/test/ui/mod-subitem-as-enum-variant.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0109]: type arguments are not allowed on this entity
1+
error[E0109]: type arguments are not allowed for this type
22
--> $DIR/mod-subitem-as-enum-variant.rs:8:11
33
|
44
LL | Mod::<i32>::FakeVariant(0);

0 commit comments

Comments
 (0)