From 71a788cbd788963cb3bc91d99c56e76cf85062f5 Mon Sep 17 00:00:00 2001 From: Peter Gerber Date: Sat, 1 Apr 2017 15:49:55 +0200 Subject: [PATCH] correct error message for `option_map_unwrap_or_else` lint Remove erroneous "with " in suggested alternative call. --- clippy_lints/src/methods.rs | 2 +- tests/ui/methods.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index b6f7e2fca1c..3d5ba695d4b 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1101,7 +1101,7 @@ fn lint_map_unwrap_or_else(cx: &LateContext, expr: &hir::Expr, map_args: &[hir:: expr.span, msg, expr.span, - &format!("replace `map({0}).unwrap_or_else({1})` with `with map_or_else({1}, {0})`", + &format!("replace `map({0}).unwrap_or_else({1})` with `map_or_else({1}, {0})`", map_snippet, unwrap_snippet)); } else if same_span && multiline { diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 425a29bb79e..17bf4f9081a 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -117,7 +117,7 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^^^^^^^^^^ - = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `with map_or_else(|| 0, |x| x + 1)` + = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)` error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead --> $DIR/methods.rs:120:13