@@ -8,7 +8,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
8
8
use crate :: utils:: paths:: { OPTION , OPTION_NONE } ;
9
9
use crate :: utils:: sugg:: Sugg ;
10
10
use 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 ,
12
12
} ;
13
13
14
14
declare_clippy_lint ! {
@@ -58,7 +58,7 @@ impl QuestionMark {
58
58
59
59
then {
60
60
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) ;
62
62
let mut replacement: Option <String > = None ;
63
63
if let Some ( else_) = else_ {
64
64
if_chain! {
@@ -77,19 +77,14 @@ impl QuestionMark {
77
77
}
78
78
79
79
if let Some ( replacement_str) = replacement {
80
- span_lint_and_then (
80
+ span_lint_and_sugg (
81
81
cx,
82
82
QUESTION_MARK ,
83
83
expr. span,
84
84
"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,
93
88
)
94
89
}
95
90
}
@@ -124,19 +119,14 @@ impl QuestionMark {
124
119
if by_ref { ".as_ref()" } else { "" } ,
125
120
) ;
126
121
127
- span_lint_and_then (
122
+ span_lint_and_sugg (
128
123
cx,
129
124
QUESTION_MARK ,
130
125
expr. span,
131
126
"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,
140
130
)
141
131
}
142
132
}
0 commit comments