about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/expr.rs
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2023-12-12 13:33:39 +0100
committerNadrieril <nadrieril+git@gmail.com>2023-12-12 14:42:04 +0100
commite274372689928972e4e78a24d615f6c4d375f7d4 (patch)
tree714874e1b0e365fd84bb3d2d86edc2ebb986ae76 /compiler/rustc_ast_lowering/src/expr.rs
parent21cce21d8c012f14cf74d5afddd795d324600dac (diff)
downloadrust-e274372689928972e4e78a24d615f6c4d375f7d4.tar.gz
rust-e274372689928972e4e78a24d615f6c4d375f7d4.zip
Correctly gate the parsing of match arms without body
Diffstat (limited to 'compiler/rustc_ast_lowering/src/expr.rs')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index e9f88d50937..a44b408feec 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -581,8 +581,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
         } else {
             // Either `body.is_none()` or `is_never_pattern` here.
             if !is_never_pattern {
-                let suggestion = span.shrink_to_hi();
-                self.tcx.sess.emit_err(MatchArmWithNoBody { span, suggestion });
+                if self.tcx.features().never_patterns {
+                    // If the feature is off we already emitted the error after parsing.
+                    let suggestion = span.shrink_to_hi();
+                    self.tcx.sess.emit_err(MatchArmWithNoBody { span, suggestion });
+                }
             } else if let Some(body) = &arm.body {
                 self.tcx.sess.emit_err(NeverPatternWithBody { span: body.span });
                 guard = None;