unneeded-field-pattern: make lint adhere to lint message convention

This commit is contained in:
Matthias Krüger 2020-07-23 23:31:33 +02:00
parent 2792260636
commit 4418ff122f
2 changed files with 9 additions and 9 deletions

View file

@ -298,9 +298,9 @@ impl EarlyLintPass for MiscEarlyLints {
cx,
UNNEEDED_FIELD_PATTERN,
pat.span,
"All the struct fields are matched to a wildcard pattern, consider using `..`.",
"all the struct fields are matched to a wildcard pattern, consider using `..`",
None,
&format!("Try with `{} {{ .. }}` instead", type_name),
&format!("try with `{} {{ .. }}` instead", type_name),
);
return;
}
@ -313,7 +313,7 @@ impl EarlyLintPass for MiscEarlyLints {
cx,
UNNEEDED_FIELD_PATTERN,
field.span,
"You matched a field with a wildcard pattern. Consider using `..` instead",
"you matched a field with a wildcard pattern, consider using `..` instead",
);
} else {
let mut normal = vec![];
@ -333,10 +333,10 @@ impl EarlyLintPass for MiscEarlyLints {
cx,
UNNEEDED_FIELD_PATTERN,
field.span,
"You matched a field with a wildcard pattern. Consider using `..` \
"you matched a field with a wildcard pattern, consider using `..` \
instead",
None,
&format!("Try with `{} {{ {}, .. }}`", type_name, normal[..].join(", ")),
&format!("try with `{} {{ {}, .. }}`", type_name, normal[..].join(", ")),
);
}
}

View file

@ -1,19 +1,19 @@
error: You matched a field with a wildcard pattern. Consider using `..` instead
error: you matched a field with a wildcard pattern, consider using `..` instead
--> $DIR/unneeded_field_pattern.rs:14:15
|
LL | Foo { a: _, b: 0, .. } => {},
| ^^^^
|
= note: `-D clippy::unneeded-field-pattern` implied by `-D warnings`
= help: Try with `Foo { b: 0, .. }`
= help: try with `Foo { b: 0, .. }`
error: All the struct fields are matched to a wildcard pattern, consider using `..`.
error: all the struct fields are matched to a wildcard pattern, consider using `..`
--> $DIR/unneeded_field_pattern.rs:16:9
|
LL | Foo { a: _, b: _, c: _ } => {},
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: Try with `Foo { .. }` instead
= help: try with `Foo { .. }` instead
error: aborting due to 2 previous errors