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 {
|
||||
GenericsArgsErrExtend::DefVariant(segments) => segments.iter().collect(),
|
||||
_ => segments.collect(),
|
||||
};
|
||||
let segments: Vec<_> = segments.collect();
|
||||
let types_and_spans: Vec<_> = segments
|
||||
.iter()
|
||||
.flat_map(|segment| {
|
||||
|
@ -1511,10 +1508,10 @@ fn generics_args_err_extend<'a>(
|
|||
if args.len() > 1
|
||||
&& let Some(span) = args.into_iter().last()
|
||||
{
|
||||
let msg = "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";
|
||||
err.note(msg);
|
||||
err.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",
|
||||
);
|
||||
err.span_suggestion_verbose(
|
||||
span,
|
||||
"remove the generics arguments from one of the path segments",
|
||||
|
|
|
@ -52,7 +52,7 @@ fn main() {
|
|||
// Tuple struct variant
|
||||
|
||||
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::<()>(());
|
||||
//~^ ERROR type arguments are not allowed on this type [E0109]
|
||||
|
@ -70,7 +70,7 @@ fn main() {
|
|||
// Struct variant
|
||||
|
||||
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: () };
|
||||
//~^ ERROR type arguments are not allowed on this type [E0109]
|
||||
|
@ -88,7 +88,7 @@ fn main() {
|
|||
// Unit variant
|
||||
|
||||
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::<()>;
|
||||
//~^ ERROR type arguments are not allowed on this type [E0109]
|
||||
|
|
|
@ -278,14 +278,13 @@ LL | Self::<()>::UVariant::<()>;
|
|||
| |
|
||||
| not allowed on this type
|
||||
|
||||
error[E0109]: type arguments are not allowed on enum `Enum` and tuple variant `TSVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:54:12
|
||||
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`
|
||||
| not allowed on enum `Enum`
|
||||
| --------- ^^ 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
|
||||
|
@ -354,14 +353,13 @@ LL | AliasFixed::<()>::TSVariant::<()>(());
|
|||
| |
|
||||
| not allowed on this type
|
||||
|
||||
error[E0109]: type arguments are not allowed on enum `Enum` and variant `SVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:72:12
|
||||
error[E0109]: type arguments are not allowed on variant `SVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:72:28
|
||||
|
|
||||
LL | Enum::<()>::SVariant::<()> { v: () };
|
||||
| ---- ^^ -------- ^^ type argument not allowed
|
||||
| | |
|
||||
| | not allowed on variant `SVariant`
|
||||
| not allowed on enum `Enum`
|
||||
| -------- ^^ type argument not allowed
|
||||
| |
|
||||
| not allowed on variant `SVariant`
|
||||
|
|
||||
= 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
|
||||
|
@ -458,14 +456,13 @@ LL - AliasFixed::<()>::SVariant::<()> { v: () };
|
|||
LL + AliasFixed::<()>::SVariant { v: () };
|
||||
|
|
||||
|
||||
error[E0109]: type arguments are not allowed on enum `Enum` and unit variant `UVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:90:12
|
||||
error[E0109]: type arguments are not allowed on unit variant `UVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:90:28
|
||||
|
|
||||
LL | Enum::<()>::UVariant::<()>;
|
||||
| ---- ^^ -------- ^^ type argument not allowed
|
||||
| | |
|
||||
| | not allowed on unit variant `UVariant`
|
||||
| not allowed on enum `Enum`
|
||||
| -------- ^^ type argument not allowed
|
||||
| |
|
||||
| not allowed on unit variant `UVariant`
|
||||
|
|
||||
= 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue