@@ -2,7 +2,7 @@ use super::errors::{
2
2
AsyncCoroutinesNotSupported , AsyncNonMoveClosureNotSupported , AwaitOnlyInAsyncFnAndBlocks ,
3
3
BaseExpressionDoubleDot , ClosureCannotBeStatic , CoroutineTooManyParameters ,
4
4
FunctionalRecordUpdateDestructuringAssignment , InclusiveRangeWithNoEnd , MatchArmWithNoBody ,
5
- NotSupportedForLifetimeBinderAsyncClosure , UnderscoreExprLhsAssign ,
5
+ NeverPatternWithGuard , NotSupportedForLifetimeBinderAsyncClosure , UnderscoreExprLhsAssign ,
6
6
} ;
7
7
use super :: ResolverAstLoweringExt ;
8
8
use super :: { ImplTraitContext , LoweringContext , ParamMode , ParenthesizedGenericArgs } ;
@@ -550,7 +550,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
550
550
551
551
fn lower_arm ( & mut self , arm : & Arm ) -> hir:: Arm < ' hir > {
552
552
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| {
554
554
if let ExprKind :: Let ( pat, scrutinee, span, is_recovered) = & cond. kind {
555
555
hir:: Guard :: IfLet ( self . arena . alloc ( hir:: Let {
556
556
hir_id : self . next_id ( ) ,
@@ -575,6 +575,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
575
575
self . tcx
576
576
. sess
577
577
. 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 ;
578
581
}
579
582
580
583
// An arm without a body, meant for never patterns.
0 commit comments