mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
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 https://github.com/rust-lang/rust-clippy/issues/5822#issuecomment-680749728 and https://github.com/rust-lang/rust-clippy/issues/5822#issuecomment-680783381. --- changelog: none
This commit is contained in:
commit
e45c59e922
1 changed files with 8 additions and 7 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue