Require parentheses to avoid confusions around labeled break and loop expressions
This commit is contained in:
parent
7069a8c2b7
commit
470cbc0e2e
6 changed files with 152 additions and 21 deletions
|
@ -750,6 +750,11 @@ pub trait LintContext: Sized {
|
|||
db.note(&format!("to ignore the value produced by the macro, add a semicolon after the invocation of `{name}`"));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Rewrap `db`, and pass control to the user.
|
||||
decorate(LintDiagnosticBuilder::new(db));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue