@@ -2,7 +2,7 @@ use super::errors::{
22 AsyncCoroutinesNotSupported , AsyncNonMoveClosureNotSupported , AwaitOnlyInAsyncFnAndBlocks ,
33 BaseExpressionDoubleDot , ClosureCannotBeStatic , CoroutineTooManyParameters ,
44 FunctionalRecordUpdateDestructuringAssignment , InclusiveRangeWithNoEnd , MatchArmWithNoBody ,
5- NotSupportedForLifetimeBinderAsyncClosure , UnderscoreExprLhsAssign ,
5+ NeverPatternWithGuard , NotSupportedForLifetimeBinderAsyncClosure , UnderscoreExprLhsAssign ,
66} ;
77use super :: ResolverAstLoweringExt ;
88use super :: { ImplTraitContext , LoweringContext , ParamMode , ParenthesizedGenericArgs } ;
@@ -550,7 +550,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
550550
551551 fn lower_arm ( & mut self , arm : & Arm ) -> hir:: Arm < ' hir > {
552552 let pat = self . lower_pat ( & arm. pat ) ;
553- let guard = arm. guard . as_ref ( ) . map ( |cond| {
553+ let mut guard = arm. guard . as_ref ( ) . map ( |cond| {
554554 if let ExprKind :: Let ( pat, scrutinee, span, is_recovered) = & cond. kind {
555555 hir:: Guard :: IfLet ( self . arena . alloc ( hir:: Let {
556556 hir_id : self . next_id ( ) ,
@@ -575,6 +575,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
575575 self . tcx
576576 . sess
577577 . emit_err ( MatchArmWithNoBody { span, suggestion : span. shrink_to_hi ( ) } ) ;
578+ } else if let Some ( g) = & arm. guard {
579+ self . tcx . sess . emit_err ( NeverPatternWithGuard { span : g. span } ) ;
580+ guard = None ;
578581 }
579582
580583 // An arm without a body, meant for never patterns.
0 commit comments