diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 822bae14ff91..556c6988d668 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1173,7 +1173,7 @@ fn lint_unnecessary_fold(cx: &LateContext, expr: &hir::Expr, fold_args: &[hir::E ".{replacement}(|{s}| {r})", replacement = replacement_method_name, s = second_arg_ident, - r = snippet(cx, right_expr.span, "EXPR") + r = snippet(cx, right_expr.span, "EXPR"), ) } else { format!( @@ -1186,10 +1186,10 @@ fn lint_unnecessary_fold(cx: &LateContext, expr: &hir::Expr, fold_args: &[hir::E cx, UNNECESSARY_FOLD, fold_span, - // TODO: don't suggest e.g. .any(|x| f(x)) if we can suggest .any(f) + // TODO #2371 don't suggest e.g. .any(|x| f(x)) if we can suggest .any(f) "this `.fold` can be written more succinctly using another method", "try", - sugg + sugg, ); } } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index d4f7539cea9e..4019321d7116 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -601,7 +601,7 @@ pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>( /// These suggestions can be parsed by rustfix to allow it to automatically fix your code. /// In the example below, `help` is `"try"` and `sugg` is the suggested replacement `".any(|x| x > 2)"`. /// -///
+/// ``` /// error: This `.fold` can be more succinctly expressed as `.any` /// --> $DIR/methods.rs:390:13 /// | @@ -609,7 +609,7 @@ pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>( /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` /// | /// = note: `-D fold-any` implied by `-D warnings` -///+/// ``` pub fn span_lint_and_sugg<'a, 'tcx: 'a, T: LintContext<'tcx>>( cx: &'a T, lint: &'static Lint, diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 57f073f00b04..254c7bf18950 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -499,7 +499,7 @@ error: this `.fold` can be written more succinctly using another method 391 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` | - = note: `-D fold-any` implied by `-D warnings` + = note: `-D unnecessary-fold` implied by `-D warnings` error: this `.fold` can be written more succinctly using another method --> $DIR/methods.rs:393:19