} else {
"unnecessary closure used to substitute value for `Result::Err`"
};
+ let applicability = if body
+ .params
+ .iter()
+ // bindings are checked to be unused above
+ .all(|param| matches!(param.pat.kind, hir::PatKind::Binding(..) | hir::PatKind::Wild))
+ {
+ Applicability::MachineApplicable
+ } else {
+ // replacing the lambda may break type inference
+ Applicability::MaybeIncorrect
+ };
span_lint_and_sugg(
cx,
UNNECESSARY_LAZY_EVALUATIONS,
expr.span,
msg,
- &format!("Use `{}` instead", simplify_using),
+ &format!("use `{}` instead", simplify_using),
format!(
"{0}.{1}({2})",
snippet(cx, args[0].span, ".."),
simplify_using,
snippet(cx, body_expr.span, ".."),
),
- Applicability::MachineApplicable,
+ applicability,
);
}
}