Remove some the spans pointing at the enum in the path and its generic args
``` error[E0109]: type arguments are not allowed on tuple variant `TSVariant` --> $DIR/enum-variant-generic-args.rs:54:29 | LL | Enum::<()>::TSVariant::<()>(()); | --------- ^^ type argument not allowed | | | not allowed on tuple variant `TSVariant` | = note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other help: remove the generics arguments from one of the path segments | LL - Enum::<()>::TSVariant::<()>(()); LL + Enum::<()>::TSVariant(()); | ```
This commit is contained in:
parent
1b98d0ed13
commit
23daa8c724
3 changed files with 23 additions and 29 deletions
|
@ -1047,10 +1047,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
let segments: Vec<_> = match err_extend {
|
let segments: Vec<_> = segments.collect();
|
||||||
GenericsArgsErrExtend::DefVariant(segments) => segments.iter().collect(),
|
|
||||||
_ => segments.collect(),
|
|
||||||
};
|
|
||||||
let types_and_spans: Vec<_> = segments
|
let types_and_spans: Vec<_> = segments
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|segment| {
|
.flat_map(|segment| {
|
||||||
|
@ -1511,10 +1508,10 @@ fn generics_args_err_extend<'a>(
|
||||||
if args.len() > 1
|
if args.len() > 1
|
||||||
&& let Some(span) = args.into_iter().last()
|
&& let Some(span) = args.into_iter().last()
|
||||||
{
|
{
|
||||||
let msg = "generic arguments are not allowed on both an enum and its variant's \
|
err.note(
|
||||||
path segments simultaneously; they are only valid in one place or the \
|
"generic arguments are not allowed on both an enum and its variant's path \
|
||||||
other";
|
segments simultaneously; they are only valid in one place or the other",
|
||||||
err.note(msg);
|
);
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
"remove the generics arguments from one of the path segments",
|
"remove the generics arguments from one of the path segments",
|
||||||
|
|
|
@ -52,7 +52,7 @@ fn main() {
|
||||||
// Tuple struct variant
|
// Tuple struct variant
|
||||||
|
|
||||||
Enum::<()>::TSVariant::<()>(());
|
Enum::<()>::TSVariant::<()>(());
|
||||||
//~^ ERROR type arguments are not allowed on enum `Enum` and tuple variant `TSVariant` [E0109]
|
//~^ ERROR type arguments are not allowed on tuple variant `TSVariant` [E0109]
|
||||||
|
|
||||||
Alias::TSVariant::<()>(());
|
Alias::TSVariant::<()>(());
|
||||||
//~^ ERROR type arguments are not allowed on this type [E0109]
|
//~^ ERROR type arguments are not allowed on this type [E0109]
|
||||||
|
@ -70,7 +70,7 @@ fn main() {
|
||||||
// Struct variant
|
// Struct variant
|
||||||
|
|
||||||
Enum::<()>::SVariant::<()> { v: () };
|
Enum::<()>::SVariant::<()> { v: () };
|
||||||
//~^ ERROR type arguments are not allowed on enum `Enum` and variant `SVariant` [E0109]
|
//~^ ERROR type arguments are not allowed on variant `SVariant` [E0109]
|
||||||
|
|
||||||
Alias::SVariant::<()> { v: () };
|
Alias::SVariant::<()> { v: () };
|
||||||
//~^ ERROR type arguments are not allowed on this type [E0109]
|
//~^ ERROR type arguments are not allowed on this type [E0109]
|
||||||
|
@ -88,7 +88,7 @@ fn main() {
|
||||||
// Unit variant
|
// Unit variant
|
||||||
|
|
||||||
Enum::<()>::UVariant::<()>;
|
Enum::<()>::UVariant::<()>;
|
||||||
//~^ ERROR type arguments are not allowed on enum `Enum` and unit variant `UVariant` [E0109]
|
//~^ ERROR type arguments are not allowed on unit variant `UVariant` [E0109]
|
||||||
|
|
||||||
Alias::UVariant::<()>;
|
Alias::UVariant::<()>;
|
||||||
//~^ ERROR type arguments are not allowed on this type [E0109]
|
//~^ ERROR type arguments are not allowed on this type [E0109]
|
||||||
|
|
|
@ -278,14 +278,13 @@ LL | Self::<()>::UVariant::<()>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this type
|
| not allowed on this type
|
||||||
|
|
||||||
error[E0109]: type arguments are not allowed on enum `Enum` and tuple variant `TSVariant`
|
error[E0109]: type arguments are not allowed on tuple variant `TSVariant`
|
||||||
--> $DIR/enum-variant-generic-args.rs:54:12
|
--> $DIR/enum-variant-generic-args.rs:54:29
|
||||||
|
|
|
|
||||||
LL | Enum::<()>::TSVariant::<()>(());
|
LL | Enum::<()>::TSVariant::<()>(());
|
||||||
| ---- ^^ --------- ^^ type argument not allowed
|
| --------- ^^ type argument not allowed
|
||||||
| | |
|
| |
|
||||||
| | not allowed on tuple variant `TSVariant`
|
| not allowed on tuple variant `TSVariant`
|
||||||
| not allowed on enum `Enum`
|
|
||||||
|
|
|
|
||||||
= note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other
|
= note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other
|
||||||
help: remove the generics arguments from one of the path segments
|
help: remove the generics arguments from one of the path segments
|
||||||
|
@ -354,14 +353,13 @@ LL | AliasFixed::<()>::TSVariant::<()>(());
|
||||||
| |
|
| |
|
||||||
| not allowed on this type
|
| not allowed on this type
|
||||||
|
|
||||||
error[E0109]: type arguments are not allowed on enum `Enum` and variant `SVariant`
|
error[E0109]: type arguments are not allowed on variant `SVariant`
|
||||||
--> $DIR/enum-variant-generic-args.rs:72:12
|
--> $DIR/enum-variant-generic-args.rs:72:28
|
||||||
|
|
|
|
||||||
LL | Enum::<()>::SVariant::<()> { v: () };
|
LL | Enum::<()>::SVariant::<()> { v: () };
|
||||||
| ---- ^^ -------- ^^ type argument not allowed
|
| -------- ^^ type argument not allowed
|
||||||
| | |
|
| |
|
||||||
| | not allowed on variant `SVariant`
|
| not allowed on variant `SVariant`
|
||||||
| not allowed on enum `Enum`
|
|
||||||
|
|
|
|
||||||
= note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other
|
= note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other
|
||||||
help: remove the generics arguments from one of the path segments
|
help: remove the generics arguments from one of the path segments
|
||||||
|
@ -458,14 +456,13 @@ LL - AliasFixed::<()>::SVariant::<()> { v: () };
|
||||||
LL + AliasFixed::<()>::SVariant { v: () };
|
LL + AliasFixed::<()>::SVariant { v: () };
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0109]: type arguments are not allowed on enum `Enum` and unit variant `UVariant`
|
error[E0109]: type arguments are not allowed on unit variant `UVariant`
|
||||||
--> $DIR/enum-variant-generic-args.rs:90:12
|
--> $DIR/enum-variant-generic-args.rs:90:28
|
||||||
|
|
|
|
||||||
LL | Enum::<()>::UVariant::<()>;
|
LL | Enum::<()>::UVariant::<()>;
|
||||||
| ---- ^^ -------- ^^ type argument not allowed
|
| -------- ^^ type argument not allowed
|
||||||
| | |
|
| |
|
||||||
| | not allowed on unit variant `UVariant`
|
| not allowed on unit variant `UVariant`
|
||||||
| not allowed on enum `Enum`
|
|
||||||
|
|
|
|
||||||
= note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other
|
= note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other
|
||||||
help: remove the generics arguments from one of the path segments
|
help: remove the generics arguments from one of the path segments
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue