mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Fix the wrong use of snippet_with_applicability
This includes a workaround of the issue #5822, the cause of this little mistake.
This commit is contained in:
parent
64c4bb0d2b
commit
edc05da57d
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 let (Some(fmt_str), expr) = self.check_tts(cx, mac.args.inner_tokens(), true) {
|
||||||
if fmt_str.symbol == Symbol::intern("") {
|
if fmt_str.symbol == Symbol::intern("") {
|
||||||
let mut applicability = Applicability::MachineApplicable;
|
let mut applicability = Applicability::MachineApplicable;
|
||||||
let suggestion = expr.map_or_else(
|
// FIXME: remove this `#[allow(...)]` once the issue #5822 gets fixed
|
||||||
|| {
|
#[allow(clippy::option_if_let_else)]
|
||||||
applicability = Applicability::HasPlaceholders;
|
let suggestion = if let Some(e) = expr {
|
||||||
Cow::Borrowed("v")
|
snippet_with_applicability(cx, e.span, "v", &mut applicability)
|
||||||
},
|
} else {
|
||||||
|e| snippet_with_applicability(cx, e.span, "v", &mut Applicability::MachineApplicable),
|
applicability = Applicability::HasPlaceholders;
|
||||||
);
|
Cow::Borrowed("v")
|
||||||
|
};
|
||||||
|
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
|
|
Loading…
Add table
Reference in a new issue