Specialize ..
help message for all fields vs. the rest
This commit is contained in:
parent
a5e8e6ec2d
commit
fe82cc38a0
9 changed files with 21 additions and 21 deletions
|
@ -1071,14 +1071,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if subpats.is_empty() || all_wildcards {
|
if subpats.is_empty() || all_wildcards {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
all_fields_span,
|
all_fields_span,
|
||||||
"use `..` to ignore all unmentioned fields",
|
"use `..` to ignore all fields",
|
||||||
String::from(".."),
|
String::from(".."),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
after_fields_span,
|
after_fields_span,
|
||||||
"use `..` to ignore all unmentioned fields",
|
"use `..` to ignore the rest of the fields",
|
||||||
String::from(", .."),
|
String::from(", .."),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,7 +36,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | TupleStruct(_, _) = TupleStruct(1, 2);
|
LL | TupleStruct(_, _) = TupleStruct(1, 2);
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | TupleStruct(..) = TupleStruct(1, 2);
|
LL | TupleStruct(..) = TupleStruct(1, 2);
|
||||||
| ^^
|
| ^^
|
||||||
|
@ -63,7 +63,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | Enum::SingleVariant(_, _) = Enum::SingleVariant(1, 2);
|
LL | Enum::SingleVariant(_, _) = Enum::SingleVariant(1, 2);
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | Enum::SingleVariant(..) = Enum::SingleVariant(1, 2);
|
LL | Enum::SingleVariant(..) = Enum::SingleVariant(1, 2);
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
@ -11,7 +11,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | Fruit::Apple(a, _) => {},
|
LL | Fruit::Apple(a, _) => {},
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore the rest of the fields
|
||||||
|
|
|
|
||||||
LL | Fruit::Apple(a, ..) => {},
|
LL | Fruit::Apple(a, ..) => {},
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
@ -22,7 +22,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | let P(_) = U {};
|
LL | let P(_) = U {};
|
||||||
| ^
|
| ^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | let P(..) = U {};
|
LL | let P(..) = U {};
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
@ -31,7 +31,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | Binder(_a, _x @ .., _) => {}
|
LL | Binder(_a, _x @ .., _) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore the rest of the fields
|
||||||
|
|
|
|
||||||
LL | Binder(_a, _x @ .., ..) => {}
|
LL | Binder(_a, _x @ .., ..) => {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
@ -11,7 +11,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | Color::Rgb(_, _, _) => { }
|
LL | Color::Rgb(_, _, _) => { }
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | Color::Rgb(..) => { }
|
LL | Color::Rgb(..) => { }
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
@ -31,7 +31,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | E::A(x @ .., _) => {
|
LL | E::A(x @ .., _) => {
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore the rest of the fields
|
||||||
|
|
|
|
||||||
LL | E::A(x @ .., ..) => {
|
LL | E::A(x @ .., ..) => {
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
@ -8,38 +8,38 @@ fn main() {
|
||||||
S(x) => {}
|
S(x) => {}
|
||||||
//~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
|
||||||
//~| HELP use `_` to explicitly ignore each field
|
//~| HELP use `_` to explicitly ignore each field
|
||||||
//~| HELP use `..` to ignore all unmentioned fields
|
//~| HELP use `..` to ignore the rest of the fields
|
||||||
}
|
}
|
||||||
match S(0, 1.0) {
|
match S(0, 1.0) {
|
||||||
S(_) => {}
|
S(_) => {}
|
||||||
//~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
|
||||||
//~| HELP use `_` to explicitly ignore each field
|
//~| HELP use `_` to explicitly ignore each field
|
||||||
//~| HELP use `..` to ignore all unmentioned fields
|
//~| HELP use `..` to ignore all fields
|
||||||
}
|
}
|
||||||
match S(0, 1.0) {
|
match S(0, 1.0) {
|
||||||
S() => {}
|
S() => {}
|
||||||
//~^ ERROR this pattern has 0 fields, but the corresponding tuple struct has 2 fields
|
//~^ ERROR this pattern has 0 fields, but the corresponding tuple struct has 2 fields
|
||||||
//~| HELP use `_` to explicitly ignore each field
|
//~| HELP use `_` to explicitly ignore each field
|
||||||
//~| HELP use `..` to ignore all unmentioned fields
|
//~| HELP use `..` to ignore all fields
|
||||||
}
|
}
|
||||||
|
|
||||||
match E::S(0, 1.0) {
|
match E::S(0, 1.0) {
|
||||||
E::S(x) => {}
|
E::S(x) => {}
|
||||||
//~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
|
||||||
//~| HELP use `_` to explicitly ignore each field
|
//~| HELP use `_` to explicitly ignore each field
|
||||||
//~| HELP use `..` to ignore all unmentioned fields
|
//~| HELP use `..` to ignore the rest of the fields
|
||||||
}
|
}
|
||||||
match E::S(0, 1.0) {
|
match E::S(0, 1.0) {
|
||||||
E::S(_) => {}
|
E::S(_) => {}
|
||||||
//~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
|
//~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
|
||||||
//~| HELP use `_` to explicitly ignore each field
|
//~| HELP use `_` to explicitly ignore each field
|
||||||
//~| HELP use `..` to ignore all unmentioned fields
|
//~| HELP use `..` to ignore all fields
|
||||||
}
|
}
|
||||||
match E::S(0, 1.0) {
|
match E::S(0, 1.0) {
|
||||||
E::S() => {}
|
E::S() => {}
|
||||||
//~^ ERROR this pattern has 0 fields, but the corresponding tuple variant has 2 fields
|
//~^ ERROR this pattern has 0 fields, but the corresponding tuple variant has 2 fields
|
||||||
//~| HELP use `_` to explicitly ignore each field
|
//~| HELP use `_` to explicitly ignore each field
|
||||||
//~| HELP use `..` to ignore all unmentioned fields
|
//~| HELP use `..` to ignore all fields
|
||||||
}
|
}
|
||||||
match E::S(0, 1.0) {
|
match E::S(0, 1.0) {
|
||||||
E::S => {}
|
E::S => {}
|
||||||
|
|
|
@ -20,7 +20,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | S(x, _) => {}
|
LL | S(x, _) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore the rest of the fields
|
||||||
|
|
|
|
||||||
LL | S(x, ..) => {}
|
LL | S(x, ..) => {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -38,7 +38,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | S(_, _) => {}
|
LL | S(_, _) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | S(..) => {}
|
LL | S(..) => {}
|
||||||
| ^^
|
| ^^
|
||||||
|
@ -56,7 +56,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | S(_, _) => {}
|
LL | S(_, _) => {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | S(..) => {}
|
LL | S(..) => {}
|
||||||
| ^^
|
| ^^
|
||||||
|
@ -74,7 +74,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | E::S(x, _) => {}
|
LL | E::S(x, _) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore the rest of the fields
|
||||||
|
|
|
|
||||||
LL | E::S(x, ..) => {}
|
LL | E::S(x, ..) => {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -92,7 +92,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | E::S(_, _) => {}
|
LL | E::S(_, _) => {}
|
||||||
| ^^^
|
| ^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | E::S(..) => {}
|
LL | E::S(..) => {}
|
||||||
| ^^
|
| ^^
|
||||||
|
@ -110,7 +110,7 @@ help: use `_` to explicitly ignore each field
|
||||||
|
|
|
|
||||||
LL | E::S(_, _) => {}
|
LL | E::S(_, _) => {}
|
||||||
| ^^^^
|
| ^^^^
|
||||||
help: use `..` to ignore all unmentioned fields
|
help: use `..` to ignore all fields
|
||||||
|
|
|
|
||||||
LL | E::S(..) => {}
|
LL | E::S(..) => {}
|
||||||
| ^^
|
| ^^
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue