Skip to content

Commit edc05da

Browse files
committed
Fix the wrong use of snippet_with_applicability
This includes a workaround of the issue rust-lang#5822, the cause of this little mistake.
1 parent 64c4bb0 commit edc05da

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: clippy_lints/src/write.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,14 @@ impl EarlyLintPass for Write {
297297
if let (Some(fmt_str), expr) = self.check_tts(cx, mac.args.inner_tokens(), true) {
298298
if fmt_str.symbol == Symbol::intern("") {
299299
let mut applicability = Applicability::MachineApplicable;
300-
let suggestion = expr.map_or_else(
301-
|| {
302-
applicability = Applicability::HasPlaceholders;
303-
Cow::Borrowed("v")
304-
},
305-
|e| snippet_with_applicability(cx, e.span, "v", &mut Applicability::MachineApplicable),
306-
);
300+
// FIXME: remove this `#[allow(...)]` once the issue #5822 gets fixed
301+
#[allow(clippy::option_if_let_else)]
302+
let suggestion = if let Some(e) = expr {
303+
snippet_with_applicability(cx, e.span, "v", &mut applicability)
304+
} else {
305+
applicability = Applicability::HasPlaceholders;
306+
Cow::Borrowed("v")
307+
};
307308

308309
span_lint_and_sugg(
309310
cx,

0 commit comments

Comments
 (0)