@@ -21,7 +21,7 @@ use rustc_middle::mir::UserTypeProjection;
2121use rustc_middle:: mir:: { BorrowKind , Field , Mutability } ;
2222use rustc_middle:: thir:: { Ascription , BindingMode , FieldPat , Pat , PatKind , PatRange , PatTyProj } ;
2323use 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 } ;
2525use rustc_span:: { Span , Symbol } ;
2626
2727use std:: cmp:: Ordering ;
@@ -545,6 +545,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
545545 hir:: ExprKind :: ConstBlock ( ref anon_const) => {
546546 let anon_const_def_id = self . tcx . hir ( ) . local_def_id ( anon_const. hir_id ) ;
547547 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+ }
548553 return * self . const_to_pat ( value, expr. hir_id , expr. span , false ) . kind ;
549554 }
550555 hir:: ExprKind :: Lit ( ref lit) => ( lit, false ) ,
0 commit comments