mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 13:43:17 +00:00
Merge pull request #283 from birkenfeld/wording
don't say "did you mean to" - use the standard "consider..."
This commit is contained in:
commit
2e7496ae7c
3 changed files with 8 additions and 9 deletions
|
@ -92,7 +92,7 @@ fn main(){
|
|||
|
||||
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:9 Some(y) => println!("{:?}", y),
|
||||
src/main.rs:10 _ => ()
|
||||
|
|
|
@ -37,13 +37,12 @@ impl LintPass for MatchPass {
|
|||
{
|
||||
if in_external_macro(cx, expr.span) {return;}
|
||||
span_help_and_lint(cx, SINGLE_MATCH, expr.span,
|
||||
"you seem to be trying to use match for \
|
||||
destructuring a single pattern. Did you mean to \
|
||||
use `if let`?",
|
||||
&format!("try\nif let {} = {} {}",
|
||||
snippet(cx, arms[0].pats[0].span, ".."),
|
||||
snippet(cx, ex.span, ".."),
|
||||
expr_block(cx, &arms[0].body, "..")));
|
||||
"you seem to be trying to use match for destructuring a \
|
||||
single pattern. Consider using `if let`",
|
||||
&format!("try\nif let {} = {} {}",
|
||||
snippet(cx, arms[0].pats[0].span, ".."),
|
||||
snippet(cx, ex.span, ".."),
|
||||
expr_block(cx, &arms[0].body, "..")));
|
||||
}
|
||||
|
||||
// check preconditions for MATCH_REF_PATS
|
||||
|
|
|
@ -30,7 +30,7 @@ impl LintPass for TypePass {
|
|||
if match_type(cx, inner, &VEC_PATH) {
|
||||
span_help_and_lint(
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue