1
Fork 0

Use a multipart suggestion for the parentheses

This commit is contained in:
Fabian Wolff 2021-08-03 21:23:29 +02:00
parent 470cbc0e2e
commit 7c81132a60
2 changed files with 11 additions and 6 deletions

View file

@ -751,9 +751,12 @@ pub trait LintContext: Sized {
}
}
BuiltinLintDiagnostics::BreakWithLabelAndLoop(span) => {
if let Ok(code) = sess.source_map().span_to_snippet(span) {
db.span_suggestion(span, "wrap this expression in parentheses", format!("({})", &code), Applicability::MachineApplicable);
}
db.multipart_suggestion(
"wrap this expression in parentheses",
vec![(span.shrink_to_lo(), "(".to_string()),
(span.shrink_to_hi(), ")".to_string())],
Applicability::MachineApplicable
);
}
}
// Rewrap `db`, and pass control to the user.