@@ -8,7 +8,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
88use crate :: utils:: paths:: { OPTION , OPTION_NONE } ;
99use crate :: utils:: sugg:: Sugg ;
1010use crate :: utils:: {
11- higher, match_def_path, match_qpath, match_type, snippet_with_applicability, span_lint_and_then , SpanlessEq ,
11+ higher, match_def_path, match_qpath, match_type, snippet_with_applicability, span_lint_and_sugg , SpanlessEq ,
1212} ;
1313
1414declare_clippy_lint ! {
@@ -58,7 +58,7 @@ impl QuestionMark {
5858
5959 then {
6060 let mut applicability = Applicability :: MachineApplicable ;
61- let receiver_str = snippet_with_applicability ( cx, subject. span , ".." , & mut applicability) ;
61+ let receiver_str = & Sugg :: hir_with_applicability ( cx, subject, ".." , & mut applicability) ;
6262 let mut replacement: Option <String > = None ;
6363 if let Some ( else_) = else_ {
6464 if_chain! {
@@ -77,19 +77,14 @@ impl QuestionMark {
7777 }
7878
7979 if let Some ( replacement_str) = replacement {
80- span_lint_and_then (
80+ span_lint_and_sugg (
8181 cx,
8282 QUESTION_MARK ,
8383 expr. span,
8484 "this block may be rewritten with the `?` operator" ,
85- |db| {
86- db. span_suggestion(
87- expr. span,
88- "replace it with" ,
89- replacement_str,
90- applicability,
91- ) ;
92- }
85+ "replace it with" ,
86+ replacement_str,
87+ applicability,
9388 )
9489 }
9590 }
@@ -124,19 +119,14 @@ impl QuestionMark {
124119 if by_ref { ".as_ref()" } else { "" } ,
125120 ) ;
126121
127- span_lint_and_then (
122+ span_lint_and_sugg (
128123 cx,
129124 QUESTION_MARK ,
130125 expr. span,
131126 "this if-let-else may be rewritten with the `?` operator" ,
132- |db| {
133- db. span_suggestion(
134- expr. span,
135- "replace it with" ,
136- replacement,
137- applicability,
138- ) ;
139- }
127+ "replace it with" ,
128+ replacement,
129+ applicability,
140130 )
141131 }
142132 }
0 commit comments