Get rid of double double colons
This commit is contained in:
parent
00c5105463
commit
72b2e9539f
@ -96,7 +96,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
|
||||
expr.span,
|
||||
"redundant closure found",
|
||||
|db| if let Some(snippet) = snippet_opt(cx, caller.span) {
|
||||
db.span_suggestion(expr.span, "remove closure as shown:", snippet);
|
||||
db.span_suggestion(expr.span, "remove closure as shown", snippet);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ fn check_len_zero(cx: &LateContext, span: Span, name: Name, args: &[Expr], lit:
|
||||
LEN_ZERO,
|
||||
span,
|
||||
"length comparison to zero",
|
||||
"using `is_empty` is more concise:",
|
||||
"using `is_empty` is more concise",
|
||||
format!("{}{}.is_empty()", op, snippet(cx, args[0].span, "_")));
|
||||
}
|
||||
}
|
||||
|
@ -1233,7 +1233,7 @@ fn lint_single_char_pattern(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr)
|
||||
SINGLE_CHAR_PATTERN,
|
||||
arg.span,
|
||||
"single-character string constant used as pattern",
|
||||
|db| { db.span_suggestion(expr.span, "try using a char instead:", hint); });
|
||||
|db| { db.span_suggestion(expr.span, "try using a char instead", hint); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -366,12 +366,12 @@ impl MiscEarly {
|
||||
|db| {
|
||||
db.span_suggestion(
|
||||
lit.span,
|
||||
"if you mean to use a decimal constant, remove the `0` to remove confusion:",
|
||||
"if you mean to use a decimal constant, remove the `0` to remove confusion",
|
||||
src.trim_left_matches('0').to_string(),
|
||||
);
|
||||
db.span_suggestion(
|
||||
lit.span,
|
||||
"if you mean to use an octal constant, use `0o`:",
|
||||
"if you mean to use an octal constant, use `0o`",
|
||||
format!("0o{}", src.trim_left_matches('0')),
|
||||
);
|
||||
});
|
||||
|
@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||
BOOL_COMPARISON,
|
||||
e.span,
|
||||
"equality checks against true are unnecessary",
|
||||
"try simplifying it as shown:",
|
||||
"try simplifying it as shown",
|
||||
hint);
|
||||
},
|
||||
(Other, Bool(true)) => {
|
||||
@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||
BOOL_COMPARISON,
|
||||
e.span,
|
||||
"equality checks against true are unnecessary",
|
||||
"try simplifying it as shown:",
|
||||
"try simplifying it as shown",
|
||||
hint);
|
||||
},
|
||||
(Bool(false), Other) => {
|
||||
@ -144,7 +144,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||
BOOL_COMPARISON,
|
||||
e.span,
|
||||
"equality checks against false can be replaced by a negation",
|
||||
"try simplifying it as shown:",
|
||||
"try simplifying it as shown",
|
||||
(!hint).to_string());
|
||||
},
|
||||
(Other, Bool(false)) => {
|
||||
@ -153,7 +153,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||
BOOL_COMPARISON,
|
||||
e.span,
|
||||
"equality checks against false can be replaced by a negation",
|
||||
"try simplifying it as shown:",
|
||||
"try simplifying it as shown",
|
||||
(!hint).to_string());
|
||||
},
|
||||
_ => (),
|
||||
|
@ -97,7 +97,7 @@ impl ReturnPass {
|
||||
ret_span,
|
||||
"unneeded return statement",
|
||||
|db| if let Some(snippet) = snippet_opt(cx, inner_span) {
|
||||
db.span_suggestion(ret_span, "remove `return` as shown:", snippet);
|
||||
db.span_suggestion(ret_span, "remove `return` as shown", snippet);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ error: equality checks against true are unnecessary
|
||||
--> bool_comparison.rs:7:8
|
||||
|
|
||||
7 | if x == true { "yes" } else { "no" };
|
||||
| ^^^^^^^^^ help: try simplifying it as shown:: `x`
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
|
||||
= note: `-D bool-comparison` implied by `-D warnings`
|
||||
|
||||
@ -10,19 +10,19 @@ error: equality checks against false can be replaced by a negation
|
||||
--> bool_comparison.rs:8:8
|
||||
|
|
||||
8 | if x == false { "yes" } else { "no" };
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown:: `!x`
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> bool_comparison.rs:9:8
|
||||
|
|
||||
9 | if true == x { "yes" } else { "no" };
|
||||
| ^^^^^^^^^ help: try simplifying it as shown:: `x`
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> bool_comparison.rs:10:8
|
||||
|
|
||||
10 | if false == x { "yes" } else { "no" };
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown:: `!x`
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -2,7 +2,7 @@ error: redundant closure found
|
||||
--> eta.rs:7:27
|
||||
|
|
||||
7 | let a = Some(1u8).map(|a| foo(a));
|
||||
| ^^^^^^^^^^ help: remove closure as shown:: `foo`
|
||||
| ^^^^^^^^^^ help: remove closure as shown: `foo`
|
||||
|
|
||||
= note: `-D redundant-closure` implied by `-D warnings`
|
||||
|
||||
@ -10,13 +10,13 @@ error: redundant closure found
|
||||
--> eta.rs:8:10
|
||||
|
|
||||
8 | meta(|a| foo(a));
|
||||
| ^^^^^^^^^^ help: remove closure as shown:: `foo`
|
||||
| ^^^^^^^^^^ help: remove closure as shown: `foo`
|
||||
|
||||
error: redundant closure found
|
||||
--> eta.rs:9:27
|
||||
|
|
||||
9 | let c = Some(1u8).map(|a| {1+2; foo}(a));
|
||||
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown:: `{1+2; foo}`
|
||||
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}`
|
||||
|
||||
error: this expression borrows a reference that is immediately dereferenced by the compiler
|
||||
--> eta.rs:11:21
|
||||
@ -30,7 +30,7 @@ error: redundant closure found
|
||||
--> eta.rs:18:27
|
||||
|
|
||||
18 | let e = Some(1u8).map(|a| generic(a));
|
||||
| ^^^^^^^^^^^^^^ help: remove closure as shown:: `generic`
|
||||
| ^^^^^^^^^^^^^^ help: remove closure as shown: `generic`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
@ -46,7 +46,7 @@ error: length comparison to zero
|
||||
--> len_zero.rs:130:8
|
||||
|
|
||||
130 | if x.len() == 0 {
|
||||
| ^^^^^^^^^^^^ help: using `is_empty` is more concise:: `x.is_empty()`
|
||||
| ^^^^^^^^^^^^ help: using `is_empty` is more concise: `x.is_empty()`
|
||||
|
|
||||
= note: `-D len-zero` implied by `-D warnings`
|
||||
|
||||
@ -54,37 +54,37 @@ error: length comparison to zero
|
||||
--> len_zero.rs:134:8
|
||||
|
|
||||
134 | if "".len() == 0 {
|
||||
| ^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `"".is_empty()`
|
||||
| ^^^^^^^^^^^^^ help: using `is_empty` is more concise: `"".is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> len_zero.rs:148:8
|
||||
|
|
||||
148 | if has_is_empty.len() == 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `has_is_empty.is_empty()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> len_zero.rs:151:8
|
||||
|
|
||||
151 | if has_is_empty.len() != 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `!has_is_empty.is_empty()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> len_zero.rs:154:8
|
||||
|
|
||||
154 | if has_is_empty.len() > 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `!has_is_empty.is_empty()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> len_zero.rs:160:8
|
||||
|
|
||||
160 | if with_is_empty.len() == 0 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `with_is_empty.is_empty()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `with_is_empty.is_empty()`
|
||||
|
||||
error: length comparison to zero
|
||||
--> len_zero.rs:172:8
|
||||
|
|
||||
172 | if b.len() != 0 {
|
||||
| ^^^^^^^^^^^^ help: using `is_empty` is more concise:: `!b.is_empty()`
|
||||
| ^^^^^^^^^^^^ help: using `is_empty` is more concise: `!b.is_empty()`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
@ -33,11 +33,11 @@ error: this is a decimal constant
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D zero-prefixed-literal` implied by `-D warnings`
|
||||
help: if you mean to use a decimal constant, remove the `0` to remove confusion:
|
||||
help: if you mean to use a decimal constant, remove the `0` to remove confusion
|
||||
|
|
||||
17 | let fail_multi_zero = 123usize;
|
||||
| ^^^^^^^^
|
||||
help: if you mean to use an octal constant, use `0o`:
|
||||
help: if you mean to use an octal constant, use `0o`
|
||||
|
|
||||
17 | let fail_multi_zero = 0o123usize;
|
||||
| ^^^^^^^^^^
|
||||
@ -78,11 +78,11 @@ error: this is a decimal constant
|
||||
30 | let fail8 = 0123;
|
||||
| ^^^^
|
||||
|
|
||||
help: if you mean to use a decimal constant, remove the `0` to remove confusion:
|
||||
help: if you mean to use a decimal constant, remove the `0` to remove confusion
|
||||
|
|
||||
30 | let fail8 = 123;
|
||||
| ^^^
|
||||
help: if you mean to use an octal constant, use `0o`:
|
||||
help: if you mean to use an octal constant, use `0o`
|
||||
|
|
||||
30 | let fail8 = 0o123;
|
||||
| ^^^^^
|
||||
|
@ -504,7 +504,7 @@ error: single-character string constant used as pattern
|
||||
--> methods.rs:475:13
|
||||
|
|
||||
475 | x.split("x");
|
||||
| --------^^^- help: try using a char instead:: `x.split('x')`
|
||||
| --------^^^- help: try using a char instead: `x.split('x')`
|
||||
|
|
||||
= note: `-D single-char-pattern` implied by `-D warnings`
|
||||
|
||||
@ -512,97 +512,97 @@ error: single-character string constant used as pattern
|
||||
--> methods.rs:492:16
|
||||
|
|
||||
492 | x.contains("x");
|
||||
| -----------^^^- help: try using a char instead:: `x.contains('x')`
|
||||
| -----------^^^- help: try using a char instead: `x.contains('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:493:19
|
||||
|
|
||||
493 | x.starts_with("x");
|
||||
| --------------^^^- help: try using a char instead:: `x.starts_with('x')`
|
||||
| --------------^^^- help: try using a char instead: `x.starts_with('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:494:17
|
||||
|
|
||||
494 | x.ends_with("x");
|
||||
| ------------^^^- help: try using a char instead:: `x.ends_with('x')`
|
||||
| ------------^^^- help: try using a char instead: `x.ends_with('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:495:12
|
||||
|
|
||||
495 | x.find("x");
|
||||
| -------^^^- help: try using a char instead:: `x.find('x')`
|
||||
| -------^^^- help: try using a char instead: `x.find('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:496:13
|
||||
|
|
||||
496 | x.rfind("x");
|
||||
| --------^^^- help: try using a char instead:: `x.rfind('x')`
|
||||
| --------^^^- help: try using a char instead: `x.rfind('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:497:14
|
||||
|
|
||||
497 | x.rsplit("x");
|
||||
| ---------^^^- help: try using a char instead:: `x.rsplit('x')`
|
||||
| ---------^^^- help: try using a char instead: `x.rsplit('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:498:24
|
||||
|
|
||||
498 | x.split_terminator("x");
|
||||
| -------------------^^^- help: try using a char instead:: `x.split_terminator('x')`
|
||||
| -------------------^^^- help: try using a char instead: `x.split_terminator('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:499:25
|
||||
|
|
||||
499 | x.rsplit_terminator("x");
|
||||
| --------------------^^^- help: try using a char instead:: `x.rsplit_terminator('x')`
|
||||
| --------------------^^^- help: try using a char instead: `x.rsplit_terminator('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:500:17
|
||||
|
|
||||
500 | x.splitn(0, "x");
|
||||
| ------------^^^- help: try using a char instead:: `x.splitn(0, 'x')`
|
||||
| ------------^^^- help: try using a char instead: `x.splitn(0, 'x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:501:18
|
||||
|
|
||||
501 | x.rsplitn(0, "x");
|
||||
| -------------^^^- help: try using a char instead:: `x.rsplitn(0, 'x')`
|
||||
| -------------^^^- help: try using a char instead: `x.rsplitn(0, 'x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:502:15
|
||||
|
|
||||
502 | x.matches("x");
|
||||
| ----------^^^- help: try using a char instead:: `x.matches('x')`
|
||||
| ----------^^^- help: try using a char instead: `x.matches('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:503:16
|
||||
|
|
||||
503 | x.rmatches("x");
|
||||
| -----------^^^- help: try using a char instead:: `x.rmatches('x')`
|
||||
| -----------^^^- help: try using a char instead: `x.rmatches('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:504:21
|
||||
|
|
||||
504 | x.match_indices("x");
|
||||
| ----------------^^^- help: try using a char instead:: `x.match_indices('x')`
|
||||
| ----------------^^^- help: try using a char instead: `x.match_indices('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:505:22
|
||||
|
|
||||
505 | x.rmatch_indices("x");
|
||||
| -----------------^^^- help: try using a char instead:: `x.rmatch_indices('x')`
|
||||
| -----------------^^^- help: try using a char instead: `x.rmatch_indices('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:506:25
|
||||
|
|
||||
506 | x.trim_left_matches("x");
|
||||
| --------------------^^^- help: try using a char instead:: `x.trim_left_matches('x')`
|
||||
| --------------------^^^- help: try using a char instead: `x.trim_left_matches('x')`
|
||||
|
||||
error: single-character string constant used as pattern
|
||||
--> methods.rs:507:26
|
||||
|
|
||||
507 | x.trim_right_matches("x");
|
||||
| ---------------------^^^- help: try using a char instead:: `x.trim_right_matches('x')`
|
||||
| ---------------------^^^- help: try using a char instead: `x.trim_right_matches('x')`
|
||||
|
||||
error: you are getting the inner pointer of a temporary `CString`
|
||||
--> methods.rs:517:5
|
||||
|
@ -2,7 +2,7 @@ error: unneeded return statement
|
||||
--> needless_return.rs:11:5
|
||||
|
|
||||
11 | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
|
||||
= note: `-D needless-return` implied by `-D warnings`
|
||||
|
||||
@ -10,43 +10,43 @@ error: unneeded return statement
|
||||
--> needless_return.rs:15:5
|
||||
|
|
||||
15 | return true
|
||||
| ^^^^^^^^^^^ help: remove `return` as shown:: `true`
|
||||
| ^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> needless_return.rs:20:9
|
||||
|
|
||||
20 | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> needless_return.rs:22:9
|
||||
|
|
||||
22 | return false;
|
||||
| ^^^^^^^^^^^^^ help: remove `return` as shown:: `false`
|
||||
| ^^^^^^^^^^^^^ help: remove `return` as shown: `false`
|
||||
|
||||
error: unneeded return statement
|
||||
--> needless_return.rs:28:17
|
||||
|
|
||||
28 | true => return false,
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown:: `false`
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `false`
|
||||
|
||||
error: unneeded return statement
|
||||
--> needless_return.rs:30:13
|
||||
|
|
||||
30 | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> needless_return.rs:37:9
|
||||
|
|
||||
37 | return true;
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
|
||||
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: unneeded return statement
|
||||
--> needless_return.rs:39:16
|
||||
|
|
||||
39 | let _ = || return true;
|
||||
| ^^^^^^^^^^^ help: remove `return` as shown:: `true`
|
||||
| ^^^^^^^^^^^ help: remove `return` as shown: `true`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user