mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
don't say "did you mean to" - use the standard "consider..."
"Did you mean to ..." sounds a bit condescending to me, since if I meant to write "if let" I probably wouldn't have written "match" :)
This commit is contained in:
parent
a9869e6fe4
commit
846c164709
3 changed files with 8 additions and 9 deletions
|
@ -92,7 +92,7 @@ fn main(){
|
||||||
|
|
||||||
Produce this warning:
|
Produce this warning:
|
||||||
```
|
```
|
||||||
src/main.rs:8:5: 11:6 warning: You seem to be trying to use match for destructuring a single type. Did you mean to use `if let`?, #[warn(single_match)] on by default
|
src/main.rs:8:5: 11:6 warning: you seem to be trying to use match for destructuring a single type. Consider using `if let`, #[warn(single_match)] on by default
|
||||||
src/main.rs:8 match x {
|
src/main.rs:8 match x {
|
||||||
src/main.rs:9 Some(y) => println!("{:?}", y),
|
src/main.rs:9 Some(y) => println!("{:?}", y),
|
||||||
src/main.rs:10 _ => ()
|
src/main.rs:10 _ => ()
|
||||||
|
|
|
@ -37,13 +37,12 @@ impl LintPass for MatchPass {
|
||||||
{
|
{
|
||||||
if in_external_macro(cx, expr.span) {return;}
|
if in_external_macro(cx, expr.span) {return;}
|
||||||
span_help_and_lint(cx, SINGLE_MATCH, expr.span,
|
span_help_and_lint(cx, SINGLE_MATCH, expr.span,
|
||||||
"you seem to be trying to use match for \
|
"you seem to be trying to use match for destructuring a \
|
||||||
destructuring a single pattern. Did you mean to \
|
single pattern. Consider using `if let`",
|
||||||
use `if let`?",
|
&format!("try\nif let {} = {} {}",
|
||||||
&format!("try\nif let {} = {} {}",
|
snippet(cx, arms[0].pats[0].span, ".."),
|
||||||
snippet(cx, arms[0].pats[0].span, ".."),
|
snippet(cx, ex.span, ".."),
|
||||||
snippet(cx, ex.span, ".."),
|
expr_block(cx, &arms[0].body, "..")));
|
||||||
expr_block(cx, &arms[0].body, "..")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check preconditions for MATCH_REF_PATS
|
// check preconditions for MATCH_REF_PATS
|
||||||
|
|
|
@ -30,7 +30,7 @@ impl LintPass for TypePass {
|
||||||
if match_type(cx, inner, &VEC_PATH) {
|
if match_type(cx, inner, &VEC_PATH) {
|
||||||
span_help_and_lint(
|
span_help_and_lint(
|
||||||
cx, BOX_VEC, ast_ty.span,
|
cx, BOX_VEC, ast_ty.span,
|
||||||
"you seem to be trying to use `Box<Vec<T>>`. Did you mean to use `Vec<T>`?",
|
"you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`",
|
||||||
"`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.");
|
"`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue