@@ -21,7 +21,7 @@ use rustc_middle::mir::UserTypeProjection;
21
21
use rustc_middle:: mir:: { BorrowKind , Field , Mutability } ;
22
22
use rustc_middle:: thir:: { Ascription , BindingMode , FieldPat , Pat , PatKind , PatRange , PatTyProj } ;
23
23
use rustc_middle:: ty:: subst:: { GenericArg , SubstsRef } ;
24
- use rustc_middle:: ty:: { self , AdtDef , DefIdTree , Region , Ty , TyCtxt , UserType } ;
24
+ use rustc_middle:: ty:: { self , AdtDef , ConstKind , DefIdTree , Region , Ty , TyCtxt , UserType } ;
25
25
use rustc_span:: { Span , Symbol } ;
26
26
27
27
use std:: cmp:: Ordering ;
@@ -545,6 +545,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
545
545
hir:: ExprKind :: ConstBlock ( ref anon_const) => {
546
546
let anon_const_def_id = self . tcx . hir ( ) . local_def_id ( anon_const. hir_id ) ;
547
547
let value = ty:: Const :: from_anon_const ( self . tcx , anon_const_def_id) ;
548
+ if matches ! ( value. val, ConstKind :: Param ( _) ) {
549
+ let span = self . tcx . hir ( ) . span ( anon_const. hir_id ) ;
550
+ self . errors . push ( PatternError :: ConstParamInPattern ( span) ) ;
551
+ return PatKind :: Wild ;
552
+ }
548
553
return * self . const_to_pat ( value, expr. hir_id , expr. span , false ) . kind ;
549
554
}
550
555
hir:: ExprKind :: Lit ( ref lit) => ( lit, false ) ,
0 commit comments