Skip to content

Commit 545f223

Browse files
committed
Auto merge of #53584 - mcr431:Fix-#53525, r=varkor
Fix #53525 - Unify E0243, E0244, E0087, E0088, E0089, and E0090 into E0107 Fix #53525 This pr merges all errors related to too many or too few generic arguments in types and functions. E0243, E0244, E0087, E0088, E0089, E0090 errors will no longer be emitted and E0107 will be used instead.
2 parents af2be23 + 79afc6e commit 545f223

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+127
-291
lines changed

src/librustc_typeck/astconv.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ enum GenericArgPosition {
9999
MethodCall,
100100
}
101101

102-
// FIXME(#53525): these error codes should all be unified.
103-
struct GenericArgMismatchErrorCode {
104-
lifetimes: (&'static str, &'static str),
105-
types: (&'static str, &'static str),
106-
}
107-
108102
/// Dummy type used for the `Self` of a `TraitRef` created for converting
109103
/// a trait object, and which gets removed in `ExistentialTraitRef`.
110104
/// This type must not appear anywhere in other converted types.
@@ -262,10 +256,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
262256
},
263257
def.parent.is_none() && def.has_self, // `has_self`
264258
seg.infer_types || suppress_mismatch, // `infer_types`
265-
GenericArgMismatchErrorCode {
266-
lifetimes: ("E0090", "E0088"),
267-
types: ("E0089", "E0087"),
268-
},
269259
)
270260
}
271261

@@ -279,7 +269,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
279269
position: GenericArgPosition,
280270
has_self: bool,
281271
infer_types: bool,
282-
error_codes: GenericArgMismatchErrorCode,
283272
) -> bool {
284273
// At this stage we are guaranteed that the generic arguments are in the correct order, e.g.
285274
// that lifetimes will proceed types. So it suffices to check the number of each generic
@@ -325,8 +314,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
325314
}
326315
}
327316

328-
let check_kind_count = |error_code: (&str, &str),
329-
kind,
317+
let check_kind_count = |kind,
330318
required,
331319
permitted,
332320
provided,
@@ -384,21 +372,14 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
384372
bound,
385373
provided,
386374
),
387-
DiagnosticId::Error({
388-
if provided <= permitted {
389-
error_code.0
390-
} else {
391-
error_code.1
392-
}
393-
}.into())
375+
DiagnosticId::Error("E0107".into())
394376
).span_label(span, label).emit();
395377

396378
provided > required // `suppress_error`
397379
};
398380

399381
if !infer_lifetimes || arg_counts.lifetimes > param_counts.lifetimes {
400382
check_kind_count(
401-
error_codes.lifetimes,
402383
"lifetime",
403384
param_counts.lifetimes,
404385
param_counts.lifetimes,
@@ -409,7 +390,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
409390
if !infer_types
410391
|| arg_counts.types > param_counts.types - defaults.types - has_self as usize {
411392
check_kind_count(
412-
error_codes.types,
413393
"type",
414394
param_counts.types - defaults.types - has_self as usize,
415395
param_counts.types - has_self as usize,
@@ -587,10 +567,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
587567
GenericArgPosition::Type,
588568
has_self,
589569
infer_types,
590-
GenericArgMismatchErrorCode {
591-
lifetimes: ("E0107", "E0107"),
592-
types: ("E0243", "E0244"),
593-
},
594570
);
595571

596572
let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF);

src/librustc_typeck/diagnostics.rs

+42-14
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,11 @@ enum NightsWatch {}
10411041
"##,
10421042

10431043
E0087: r##"
1044+
#### Note: this error code is no longer emitted by the compiler.
1045+
10441046
Too many type arguments were supplied for a function. For example:
10451047
1046-
```compile_fail,E0087
1048+
```compile_fail,E0107
10471049
fn foo<T>() {}
10481050
10491051
fn main() {
@@ -1057,9 +1059,11 @@ parameters.
10571059
"##,
10581060

10591061
E0088: r##"
1062+
#### Note: this error code is no longer emitted by the compiler.
1063+
10601064
You gave too many lifetime arguments. Erroneous code example:
10611065
1062-
```compile_fail,E0088
1066+
```compile_fail,E0107
10631067
fn f() {}
10641068
10651069
fn main() {
@@ -1103,9 +1107,11 @@ fn main() {
11031107
"##,
11041108

11051109
E0089: r##"
1110+
#### Note: this error code is no longer emitted by the compiler.
1111+
11061112
Too few type arguments were supplied for a function. For example:
11071113
1108-
```compile_fail,E0089
1114+
```compile_fail,E0107
11091115
fn foo<T, U>() {}
11101116
11111117
fn main() {
@@ -1116,7 +1122,7 @@ fn main() {
11161122
Note that if a function takes multiple type arguments but you want the compiler
11171123
to infer some of them, you can use type placeholders:
11181124
1119-
```compile_fail,E0089
1125+
```compile_fail,E0107
11201126
fn foo<T, U>(x: T) {}
11211127
11221128
fn main() {
@@ -1129,9 +1135,11 @@ fn main() {
11291135
"##,
11301136

11311137
E0090: r##"
1138+
#### Note: this error code is no longer emitted by the compiler.
1139+
11321140
You gave too few lifetime arguments. Example:
11331141
1134-
```compile_fail,E0090
1142+
```compile_fail,E0107
11351143
fn foo<'a: 'b, 'b: 'a>() {}
11361144
11371145
fn main() {
@@ -1258,18 +1266,34 @@ extern "rust-intrinsic" {
12581266
"##,
12591267

12601268
E0107: r##"
1261-
This error means that an incorrect number of lifetime parameters were provided
1262-
for a type (like a struct or enum) or trait:
1269+
This error means that an incorrect number of generic arguments were provided:
12631270
12641271
```compile_fail,E0107
1265-
struct Foo<'a, 'b>(&'a str, &'b str);
1266-
enum Bar { A, B, C }
1272+
struct Foo<T> { x: T }
1273+
1274+
struct Bar { x: Foo } // error: wrong number of type arguments:
1275+
// expected 1, found 0
1276+
struct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments:
1277+
// expected 1, found 2
12671278
1268-
struct Baz<'a> {
1269-
foo: Foo<'a>, // error: expected 2, found 1
1270-
bar: Bar<'a>, // error: expected 0, found 1
1279+
fn foo<T, U>(x: T, y: U) {}
1280+
1281+
fn main() {
1282+
let x: bool = true;
1283+
foo::<bool>(x); // error: wrong number of type arguments:
1284+
// expected 2, found 1
1285+
foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments:
1286+
// expected 2, found 3
1287+
}
1288+
1289+
fn f() {}
1290+
1291+
fn main() {
1292+
f::<'static>(); // error: wrong number of lifetime arguments:
1293+
// expected 0, found 1
12711294
}
12721295
```
1296+
12731297
"##,
12741298

12751299
E0109: r##"
@@ -2397,27 +2421,31 @@ fn baz<I>(x: &<I as Foo>::A) where I: Foo<A=Bar> {}
23972421
"##,
23982422

23992423
E0243: r##"
2424+
#### Note: this error code is no longer emitted by the compiler.
2425+
24002426
This error indicates that not enough type parameters were found in a type or
24012427
trait.
24022428
24032429
For example, the `Foo` struct below is defined to be generic in `T`, but the
24042430
type parameter is missing in the definition of `Bar`:
24052431
2406-
```compile_fail,E0243
2432+
```compile_fail,E0107
24072433
struct Foo<T> { x: T }
24082434
24092435
struct Bar { x: Foo }
24102436
```
24112437
"##,
24122438

24132439
E0244: r##"
2440+
#### Note: this error code is no longer emitted by the compiler.
2441+
24142442
This error indicates that too many type parameters were found in a type or
24152443
trait.
24162444
24172445
For example, the `Foo` struct below has no type parameters, but is supplied
24182446
with two in the definition of `Bar`:
24192447
2420-
```compile_fail,E0244
2448+
```compile_fail,E0107
24212449
struct Foo { x: bool }
24222450
24232451
struct Bar<S, T> { x: Foo<S, T> }
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0087]: wrong number of type arguments: expected 1, found 2
1+
error[E0107]: wrong number of type arguments: expected 1, found 2
22
--> $DIR/bad-mid-path-type-params.rs:40:28
33
|
44
LL | let _ = S::new::<isize,f64>(1, 1.0);
@@ -10,19 +10,18 @@ error[E0107]: wrong number of lifetime arguments: expected 0, found 1
1010
LL | let _ = S::<'a,isize>::new::<f64>(1, 1.0);
1111
| ^^ unexpected lifetime argument
1212

13-
error[E0087]: wrong number of type arguments: expected 1, found 2
13+
error[E0107]: wrong number of type arguments: expected 1, found 2
1414
--> $DIR/bad-mid-path-type-params.rs:46:36
1515
|
1616
LL | let _: S2 = Trait::new::<isize,f64>(1, 1.0);
1717
| ^^^ unexpected type argument
1818

19-
error[E0088]: wrong number of lifetime arguments: expected 0, found 1
19+
error[E0107]: wrong number of lifetime arguments: expected 0, found 1
2020
--> $DIR/bad-mid-path-type-params.rs:49:25
2121
|
2222
LL | let _: S2 = Trait::<'a,isize>::new::<f64>(1, 1.0);
2323
| ^^ unexpected lifetime argument
2424

2525
error: aborting due to 4 previous errors
2626

27-
Some errors occurred: E0087, E0088, E0107.
28-
For more information about an error, try `rustc --explain E0087`.
27+
For more information about this error, try `rustc --explain E0107`.
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
error[E0090]: wrong number of lifetime arguments: expected 2, found 1
1+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
22
--> $DIR/constructor-lifetime-args.rs:27:5
33
|
44
LL | S::<'static>(&0, &0);
55
| ^^^^^^^^^^^^ expected 2 lifetime arguments
66

7-
error[E0088]: wrong number of lifetime arguments: expected 2, found 3
7+
error[E0107]: wrong number of lifetime arguments: expected 2, found 3
88
--> $DIR/constructor-lifetime-args.rs:29:27
99
|
1010
LL | S::<'static, 'static, 'static>(&0, &0);
1111
| ^^^^^^^ unexpected lifetime argument
1212

13-
error[E0090]: wrong number of lifetime arguments: expected 2, found 1
13+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
1414
--> $DIR/constructor-lifetime-args.rs:32:5
1515
|
1616
LL | E::V::<'static>(&0);
1717
| ^^^^^^^^^^^^^^^ expected 2 lifetime arguments
1818

19-
error[E0088]: wrong number of lifetime arguments: expected 2, found 3
19+
error[E0107]: wrong number of lifetime arguments: expected 2, found 3
2020
--> $DIR/constructor-lifetime-args.rs:34:30
2121
|
2222
LL | E::V::<'static, 'static, 'static>(&0);
2323
| ^^^^^^^ unexpected lifetime argument
2424

2525
error: aborting due to 4 previous errors
2626

27-
Some errors occurred: E0088, E0090.
28-
For more information about an error, try `rustc --explain E0088`.
27+
For more information about this error, try `rustc --explain E0107`.

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

-18
This file was deleted.

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

-15
This file was deleted.

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

-17
This file was deleted.

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

-15
This file was deleted.

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

-15
This file was deleted.

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

-9
This file was deleted.

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

-15
This file was deleted.

0 commit comments

Comments
 (0)