redundant_closure_call - pr review
This commit is contained in:
parent
9603d9652b
commit
1ac8b85c9f
|
@ -77,13 +77,13 @@ impl EarlyLintPass for RedundantClosureCall {
|
|||
cx,
|
||||
REDUNDANT_CLOSURE_CALL,
|
||||
expr.span,
|
||||
"Try not to call a closure in the expression where it is declared.",
|
||||
"try not to call a closure in the expression where it is declared.",
|
||||
|diag| {
|
||||
if decl.inputs.is_empty() {
|
||||
let mut app = Applicability::MachineApplicable;
|
||||
let hint =
|
||||
snippet_with_applicability(cx, block.span, "..", &mut app).into_owned();
|
||||
diag.span_suggestion(expr.span, "Try doing something like: ", hint, app);
|
||||
diag.span_suggestion(expr.span, "try doing something like", hint, app);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
@ -136,13 +136,13 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
|
|||
if let hir::ExprKind::Call(ref closure, _) = call.kind;
|
||||
if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = closure.kind;
|
||||
if ident == path.segments[0].ident;
|
||||
if count_closure_usage(block, path) == 1;
|
||||
if count_closure_usage(block, path) == 1;
|
||||
then {
|
||||
span_lint(
|
||||
cx,
|
||||
REDUNDANT_CLOSURE_CALL,
|
||||
second.span,
|
||||
"Closure called just once immediately after it was declared",
|
||||
"closure called just once immediately after it was declared",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: Try not to call a closure in the expression where it is declared.
|
||||
error: try not to call a closure in the expression where it is declared.
|
||||
--> $DIR/redundant_closure_call_early.rs:9:17
|
||||
|
|
||||
LL | let mut k = (|m| m + 1)(i);
|
||||
|
@ -6,7 +6,7 @@ LL | let mut k = (|m| m + 1)(i);
|
|||
|
|
||||
= note: `-D clippy::redundant-closure-call` implied by `-D warnings`
|
||||
|
||||
error: Try not to call a closure in the expression where it is declared.
|
||||
error: try not to call a closure in the expression where it is declared.
|
||||
--> $DIR/redundant_closure_call_early.rs:12:9
|
||||
|
|
||||
LL | k = (|a, b| a * b)(1, 5);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error: Try not to call a closure in the expression where it is declared.
|
||||
error: try not to call a closure in the expression where it is declared.
|
||||
--> $DIR/redundant_closure_call_fixable.rs:7:13
|
||||
|
|
||||
LL | let a = (|| 42)();
|
||||
| ^^^^^^^^^ help: Try doing something like: : `42`
|
||||
| ^^^^^^^^^ help: try doing something like: `42`
|
||||
|
|
||||
= note: `-D clippy::redundant-closure-call` implied by `-D warnings`
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: Closure called just once immediately after it was declared
|
||||
error: closure called just once immediately after it was declared
|
||||
--> $DIR/redundant_closure_call_late.rs:15:5
|
||||
|
|
||||
LL | i = redun_closure();
|
||||
|
@ -6,13 +6,13 @@ LL | i = redun_closure();
|
|||
|
|
||||
= note: `-D clippy::redundant-closure-call` implied by `-D warnings`
|
||||
|
||||
error: Closure called just once immediately after it was declared
|
||||
error: closure called just once immediately after it was declared
|
||||
--> $DIR/redundant_closure_call_late.rs:19:5
|
||||
|
|
||||
LL | i = shadowed_closure();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: Closure called just once immediately after it was declared
|
||||
error: closure called just once immediately after it was declared
|
||||
--> $DIR/redundant_closure_call_late.rs:21:5
|
||||
|
|
||||
LL | i = shadowed_closure();
|
||||
|
|
Loading…
Reference in a new issue