summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2025-04-19 14:01:36 +0000
committerGitHub <noreply@github.com>2025-04-19 14:01:36 +0000
commitdb98b72e34c82e18c96b76e166acda95f4b0e43c (patch)
tree184d38d26a4af24b67f3696dbafc41adca3fe195 /compiler/rustc_parse/src/parser/expr.rs
parenta7c39b68616668a45f0afd62849a1da7c8ad2516 (diff)
parent3fe0b3d4d04dd86cbe22770217f3b42a8856d382 (diff)
downloadrust-db98b72e34c82e18c96b76e166acda95f4b0e43c.tar.gz
rust-db98b72e34c82e18c96b76e166acda95f4b0e43c.zip
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
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index df44b3cc23c..71cc814cb50 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -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,