Skip to content

Fix #53525 - Unify E0243, E0244, E0087, E0088, E0089, and E0090 into E0107 #53584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ enum GenericArgPosition {
MethodCall,
}

// FIXME(#53525): these error codes should all be unified.
struct GenericArgMismatchErrorCode {
lifetimes: (&'static str, &'static str),
types: (&'static str, &'static str),
}

/// Dummy type used for the `Self` of a `TraitRef` created for converting
/// a trait object, and which gets removed in `ExistentialTraitRef`.
/// This type must not appear anywhere in other converted types.
Expand Down Expand Up @@ -262,10 +256,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
},
def.parent.is_none() && def.has_self, // `has_self`
seg.infer_types || suppress_mismatch, // `infer_types`
GenericArgMismatchErrorCode {
lifetimes: ("E0090", "E0088"),
types: ("E0089", "E0087"),
},
)
}

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

let check_kind_count = |error_code: (&str, &str),
kind,
let check_kind_count = |kind,
required,
permitted,
provided,
Expand Down Expand Up @@ -384,21 +372,14 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
bound,
provided,
),
DiagnosticId::Error({
if provided <= permitted {
error_code.0
} else {
error_code.1
}
}.into())
DiagnosticId::Error("E0107".into())
).span_label(span, label).emit();

provided > required // `suppress_error`
};

if !infer_lifetimes || arg_counts.lifetimes > param_counts.lifetimes {
check_kind_count(
error_codes.lifetimes,
"lifetime",
param_counts.lifetimes,
param_counts.lifetimes,
Expand All @@ -409,7 +390,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
if !infer_types
|| arg_counts.types > param_counts.types - defaults.types - has_self as usize {
check_kind_count(
error_codes.types,
"type",
param_counts.types - defaults.types - has_self as usize,
param_counts.types - has_self as usize,
Expand Down Expand Up @@ -587,10 +567,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
GenericArgPosition::Type,
has_self,
infer_types,
GenericArgMismatchErrorCode {
lifetimes: ("E0107", "E0107"),
types: ("E0243", "E0244"),
},
);

let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF);
Expand Down
56 changes: 42 additions & 14 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,11 @@ enum NightsWatch {}
"##,

E0087: r##"
#### Note: this error code is no longer emitted by the compiler.

This comment was marked as resolved.


Too many type arguments were supplied for a function. For example:

```compile_fail,E0087
```compile_fail,E0107
fn foo<T>() {}

fn main() {
Expand All @@ -1057,9 +1059,11 @@ parameters.
"##,

E0088: r##"
#### Note: this error code is no longer emitted by the compiler.

You gave too many lifetime arguments. Erroneous code example:

```compile_fail,E0088
```compile_fail,E0107
fn f() {}

fn main() {
Expand Down Expand Up @@ -1103,9 +1107,11 @@ fn main() {
"##,

E0089: r##"
#### Note: this error code is no longer emitted by the compiler.

Too few type arguments were supplied for a function. For example:

```compile_fail,E0089
```compile_fail,E0107
fn foo<T, U>() {}

fn main() {
Expand All @@ -1116,7 +1122,7 @@ fn main() {
Note that if a function takes multiple type arguments but you want the compiler
to infer some of them, you can use type placeholders:

```compile_fail,E0089
```compile_fail,E0107
fn foo<T, U>(x: T) {}

fn main() {
Expand All @@ -1129,9 +1135,11 @@ fn main() {
"##,

E0090: r##"
#### Note: this error code is no longer emitted by the compiler.

You gave too few lifetime arguments. Example:

```compile_fail,E0090
```compile_fail,E0107
fn foo<'a: 'b, 'b: 'a>() {}

fn main() {
Expand Down Expand Up @@ -1258,18 +1266,34 @@ extern "rust-intrinsic" {
"##,

E0107: r##"
This error means that an incorrect number of lifetime parameters were provided
for a type (like a struct or enum) or trait:
This error means that an incorrect number of generic arguments were provided:

```compile_fail,E0107
struct Foo<'a, 'b>(&'a str, &'b str);
enum Bar { A, B, C }
struct Foo<T> { x: T }

struct Bar { x: Foo } // error: wrong number of type arguments:
// expected 1, found 0
struct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments:
// expected 1, found 2

struct Baz<'a> {
foo: Foo<'a>, // error: expected 2, found 1
bar: Bar<'a>, // error: expected 0, found 1
fn foo<T, U>(x: T, y: U) {}

fn main() {
let x: bool = true;
foo::<bool>(x); // error: wrong number of type arguments:
// expected 2, found 1
foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments:
// expected 2, found 3
}

fn f() {}

fn main() {
f::<'static>(); // error: wrong number of lifetime arguments:
// expected 0, found 1
}
```

"##,

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

E0243: r##"
#### Note: this error code is no longer emitted by the compiler.

This error indicates that not enough type parameters were found in a type or
trait.

For example, the `Foo` struct below is defined to be generic in `T`, but the
type parameter is missing in the definition of `Bar`:

```compile_fail,E0243
```compile_fail,E0107
struct Foo<T> { x: T }

struct Bar { x: Foo }
```
"##,

E0244: r##"
#### Note: this error code is no longer emitted by the compiler.

This error indicates that too many type parameters were found in a type or
trait.

For example, the `Foo` struct below has no type parameters, but is supplied
with two in the definition of `Bar`:

```compile_fail,E0244
```compile_fail,E0107
struct Foo { x: bool }

struct Bar<S, T> { x: Foo<S, T> }
Expand Down
9 changes: 4 additions & 5 deletions src/test/ui/bad/bad-mid-path-type-params.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0087]: wrong number of type arguments: expected 1, found 2
error[E0107]: wrong number of type arguments: expected 1, found 2
--> $DIR/bad-mid-path-type-params.rs:40:28
|
LL | let _ = S::new::<isize,f64>(1, 1.0);
Expand All @@ -10,19 +10,18 @@ error[E0107]: wrong number of lifetime arguments: expected 0, found 1
LL | let _ = S::<'a,isize>::new::<f64>(1, 1.0);
| ^^ unexpected lifetime argument

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

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

error: aborting due to 4 previous errors

Some errors occurred: E0087, E0088, E0107.
For more information about an error, try `rustc --explain E0087`.
For more information about this error, try `rustc --explain E0107`.
11 changes: 5 additions & 6 deletions src/test/ui/constructor-lifetime-args.stderr
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
error[E0090]: wrong number of lifetime arguments: expected 2, found 1
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
--> $DIR/constructor-lifetime-args.rs:27:5
|
LL | S::<'static>(&0, &0);
| ^^^^^^^^^^^^ expected 2 lifetime arguments

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

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

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

error: aborting due to 4 previous errors

Some errors occurred: E0088, E0090.
For more information about an error, try `rustc --explain E0088`.
For more information about this error, try `rustc --explain E0107`.
18 changes: 0 additions & 18 deletions src/test/ui/error-codes/E0087.rs

This file was deleted.

15 changes: 0 additions & 15 deletions src/test/ui/error-codes/E0087.stderr

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/ui/error-codes/E0088.rs

This file was deleted.

15 changes: 0 additions & 15 deletions src/test/ui/error-codes/E0088.stderr

This file was deleted.

15 changes: 0 additions & 15 deletions src/test/ui/error-codes/E0089.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/error-codes/E0089.stderr

This file was deleted.

15 changes: 0 additions & 15 deletions src/test/ui/error-codes/E0090.rs

This file was deleted.

Loading