Skip to content
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

Unify E0109, E0110 and E0111 #59321

Merged
merged 3 commits into from
Mar 23, 2019
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
29 changes: 13 additions & 16 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,37 +1486,34 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
segment.with_generic_args(|generic_args| {
let (mut err_for_lt, mut err_for_ty, mut err_for_ct) = (false, false, false);
for arg in &generic_args.args {
let (mut span_err, span, kind) = match arg {
// FIXME(varkor): unify E0109, E0110 and E0111.
let (span, kind) = match arg {
hir::GenericArg::Lifetime(lt) => {
if err_for_lt { continue }
err_for_lt = true;
has_err = true;
(struct_span_err!(self.tcx().sess, lt.span, E0110,
"lifetime arguments are not allowed on this entity"),
lt.span,
"lifetime")
(lt.span, "lifetime")
}
hir::GenericArg::Type(ty) => {
if err_for_ty { continue }
err_for_ty = true;
has_err = true;
(struct_span_err!(self.tcx().sess, ty.span, E0109,
"type arguments are not allowed on this entity"),
ty.span,
"type")
(ty.span, "type")
}
hir::GenericArg::Const(ct) => {
if err_for_ct { continue }
err_for_ct = true;
(struct_span_err!(self.tcx().sess, ct.span, E0111,
"const parameters are not allowed on this type"),
ct.span,
"const")
(ct.span, "const")
}
};
span_err.span_label(span, format!("{} argument not allowed", kind))
.emit();
let mut err = struct_span_err!(
self.tcx().sess,
span,
E0109,
"{} arguments are not allowed for this type",
kind,
);
err.span_label(span, format!("{} argument not allowed", kind));
err.emit();
if err_for_lt && err_for_ty && err_for_ct {
break;
}
Expand Down
39 changes: 14 additions & 25 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,45 +1290,34 @@ fn main() {
"##,

E0109: r##"
You tried to give a type parameter to a type which doesn't need it. Erroneous
code example:
You tried to provide a generic argument to a type which doesn't need it.
Erroneous code example:

```compile_fail,E0109
type X = u32<i32>; // error: type arguments are not allowed on this entity
type X = u32<i32>; // error: type arguments are not allowed for this type
type Y = bool<'static>; // error: lifetime parameters are not allowed on
// this type
```

Please check that you used the correct type and recheck its definition. Perhaps
it doesn't need the type parameter.
Check that you used the correct argument and that the definition is correct.

Example:

```
type X = u32; // this compiles
type X = u32; // ok!
type Y = bool; // ok!
```

Note that type parameters for enum-variant constructors go after the variant,
not after the enum (`Option::None::<u32>`, not `Option::<u32>::None`).
Note that generic arguments for enum variant constructors go after the variant,
not after the enum. For example, you would write `Option::None::<u32>`,
rather than `Option::<u32>::None`.
"##,

E0110: r##"
You tried to give a lifetime parameter to a type which doesn't need it.
Erroneous code example:

```compile_fail,E0110
type X = u32<'static>; // error: lifetime parameters are not allowed on
// this type
```

Please check that the correct type was used and recheck its definition; perhaps
it doesn't need the lifetime parameter. Example:

```
type X = u32; // ok!
```
"##,
#### Note: this error code is no longer emitted by the compiler.

E0111: r##"
You tried to give a const parameter to a type which doesn't need it.
You tried to provide a lifetime to a type which doesn't need it.
See `E0109` for more details.
"##,

E0116: r##"
Expand Down
36 changes: 18 additions & 18 deletions src/test/ui/enum-variant-generic-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ impl<T> Enum<T> {
Self::TSVariant(());
//~^ ERROR mismatched types [E0308]
Self::TSVariant::<()>(());
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
Self::<()>::TSVariant(());
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
//~^^ ERROR mismatched types [E0308]
Self::<()>::TSVariant::<()>(());
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
//~^^ ERROR type arguments are not allowed for this type [E0109]
}

fn s_variant() {
Self::SVariant { v: () };
//~^ ERROR mismatched types [E0308]
Self::SVariant::<()> { v: () };
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
//~^^ ERROR mismatched types [E0308]
Self::<()>::SVariant { v: () };
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
//~^^ ERROR mismatched types [E0308]
Self::<()>::SVariant::<()> { v: () };
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
//~^^ ERROR type arguments are not allowed for this type [E0109]
//~^^^ ERROR mismatched types [E0308]
}
}
Expand All @@ -38,36 +38,36 @@ fn main() {
// Tuple struct variant

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

Alias::TSVariant::<()>(());
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
Alias::<()>::TSVariant::<()>(());
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]

AliasFixed::TSVariant::<()>(());
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
AliasFixed::<()>::TSVariant(());
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
AliasFixed::<()>::TSVariant::<()>(());
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]

// Struct variant

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

Alias::SVariant::<()> { v: () };
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
Alias::<()>::SVariant::<()> { v: () };
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]

AliasFixed::SVariant::<()> { v: () };
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
AliasFixed::<()>::SVariant { v: () };
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
AliasFixed::<()>::SVariant::<()> { v: () };
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
}
36 changes: 18 additions & 18 deletions src/test/ui/enum-variant-generic-args.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ LL | Self::TSVariant(());
= note: expected type `T`
found type `()`

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

error[E0109]: type arguments are not allowed on this entity
error[E0109]: type arguments are not allowed for this type
--> $DIR/enum-variant-generic-args.rs:70:34
|
LL | AliasFixed::<()>::SVariant::<()> { v: () };
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0109.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0109]: type arguments are not allowed on this entity
error[E0109]: type arguments are not allowed for this type
--> $DIR/E0109.rs:1:14
|
LL | type X = u32<i32>;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0110.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
type X = u32<'static>; //~ ERROR E0110
type X = u32<'static>; //~ ERROR E0109

fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0110.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0110]: lifetime arguments are not allowed on this entity
error[E0109]: lifetime arguments are not allowed for this type
--> $DIR/E0110.rs:1:14
|
LL | type X = u32<'static>;
| ^^^^^^^ lifetime argument not allowed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0110`.
For more information about this error, try `rustc --explain E0109`.
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-22706.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn is_copy<T: ::std::marker<i32>::Copy>() {}
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-22706.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0109]: type arguments are not allowed on this entity
error[E0109]: type arguments are not allowed for this type
--> $DIR/issue-22706.rs:1:29
|
LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/mod-subitem-as-enum-variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mod Mod {
fn main() {
Mod::FakeVariant::<i32>(0);
Mod::<i32>::FakeVariant(0);
//~^ ERROR type arguments are not allowed on this entity [E0109]
//~^ ERROR type arguments are not allowed for this type [E0109]
}
2 changes: 1 addition & 1 deletion src/test/ui/mod-subitem-as-enum-variant.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0109]: type arguments are not allowed on this entity
error[E0109]: type arguments are not allowed for this type
--> $DIR/mod-subitem-as-enum-variant.rs:8:11
|
LL | Mod::<i32>::FakeVariant(0);
Expand Down
Loading