Rollup merge of #137454 - mu001999-contrib:fix-137414, r=wesleywiser

not lint break with label and unsafe block

fixes #137414

we can't label unsafe blocks, so that we can do not lint them
This commit is contained in:
Chris Denton 2025-04-19 14:01:36 +00:00 committed by GitHub
commit db98b72e34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 6 deletions

View file

@ -1884,13 +1884,15 @@ impl<'a> Parser<'a> {
let mut expr = self.parse_expr_opt()?;
if let Some(expr) = &mut expr {
if label.is_some()
&& matches!(
expr.kind,
&& match &expr.kind {
ExprKind::While(_, _, None)
| ExprKind::ForLoop { label: None, .. }
| ExprKind::Loop(_, None, _)
| ExprKind::Block(_, None)
)
| ExprKind::ForLoop { label: None, .. }
| ExprKind::Loop(_, None, _) => true,
ExprKind::Block(block, None) => {
matches!(block.rules, BlockCheckMode::Default)
}
_ => false,
}
{
self.psess.buffer_lint(
BREAK_WITH_LABEL_AND_LOOP,