Skip to content

Commit e45c59e

Browse files
committed
Auto merge of #5968 - rail-rain:fix_use_snippet_with_applicability, r=flip1995
Fix the wrong use of `snippet_with_applicability` For the context, please see rust-lang/rust-clippy#5822 (comment) and rust-lang/rust-clippy#5822 (comment). --- changelog: none
2 parents 64c4bb0 + edc05da commit e45c59e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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)