From ac6891c07be7933b26d98241d9d39b13c6af1648 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Wed, 4 Mar 2020 12:59:58 +0000 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Philipp Krones --- clippy_lints/src/question_mark.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 3b030f95dc92..b8c8762432fd 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -58,7 +58,7 @@ impl QuestionMark { then { let mut applicability = Applicability::MachineApplicable; - let receiver_str = snippet_with_applicability(cx, subject.span, "..", &mut applicability); + let receiver_str = &Sugg::hir_with_applicability(cx, subject, "..", &mut applicability); let mut replacement: Option = None; if let Some(else_) = else_ { if_chain! { @@ -124,19 +124,14 @@ impl QuestionMark { if by_ref { ".as_ref()" } else { "" }, ); - span_lint_and_then( + span_lint_and_sugg( cx, QUESTION_MARK, expr.span, "this if-let-else may be rewritten with the `?` operator", - |db| { - db.span_suggestion( - expr.span, - "replace it with", - replacement, - applicability, - ); - } + "replace it with", + replacement, + applicability, ) } }