diff options
| author | rail <12975677+rail-rain@users.noreply.github.com> | 2020-08-27 10:23:21 +1200 |
|---|---|---|
| committer | rail <12975677+rail-rain@users.noreply.github.com> | 2020-08-27 10:24:16 +1200 |
| commit | edc05da57d4ad5ab19b5ca64e80e359e487ab2d0 (patch) | |
| tree | f94ab029373ae3d8b5f08a912aca8b6ab7d44364 | |
| parent | 64c4bb0d2bac5f7810d7d0fa6ad846417b3ca60a (diff) | |
| download | rust-edc05da57d4ad5ab19b5ca64e80e359e487ab2d0.tar.gz rust-edc05da57d4ad5ab19b5ca64e80e359e487ab2d0.zip | |
Fix the wrong use of `snippet_with_applicability`
This includes a workaround of the issue #5822, the cause of this little mistake.
| -rw-r--r-- | clippy_lints/src/write.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 5f88dcb188a..e653240d049 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -297,13 +297,14 @@ impl EarlyLintPass for Write { if let (Some(fmt_str), expr) = self.check_tts(cx, mac.args.inner_tokens(), true) { if fmt_str.symbol == Symbol::intern("") { let mut applicability = Applicability::MachineApplicable; - let suggestion = expr.map_or_else( - || { - applicability = Applicability::HasPlaceholders; - Cow::Borrowed("v") - }, - |e| snippet_with_applicability(cx, e.span, "v", &mut Applicability::MachineApplicable), - ); + // FIXME: remove this `#[allow(...)]` once the issue #5822 gets fixed + #[allow(clippy::option_if_let_else)] + let suggestion = if let Some(e) = expr { + snippet_with_applicability(cx, e.span, "v", &mut applicability) + } else { + applicability = Applicability::HasPlaceholders; + Cow::Borrowed("v") + }; span_lint_and_sugg( cx, |
