@@ -5,10 +5,10 @@ use crate::rvalue_scopes;
55use crate :: { BreakableCtxt , Diverges , Expectation , FnCtxt , LoweredTy } ;
66use rustc_data_structures:: fx:: FxHashSet ;
77use rustc_errors:: { Applicability , Diag , ErrorGuaranteed , MultiSpan , StashKey } ;
8- use rustc_hir as hir;
98use rustc_hir:: def:: { CtorOf , DefKind , Res } ;
109use rustc_hir:: def_id:: DefId ;
1110use rustc_hir:: lang_items:: LangItem ;
11+ use rustc_hir:: { self as hir, ConstArg , ConstArgKind } ;
1212use rustc_hir:: { ExprKind , GenericArg , HirId , Node , QPath } ;
1313use rustc_hir_analysis:: hir_ty_lowering:: errors:: GenericsArgsErrExtend ;
1414use rustc_hir_analysis:: hir_ty_lowering:: generics:: {
@@ -446,16 +446,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
446446 }
447447 }
448448
449- pub fn lower_const_arg ( & self , hir_ct : & hir:: AnonConst , param_def_id : DefId ) -> ty:: Const < ' tcx > {
450- let did = hir_ct. def_id ;
451- self . tcx . feed_anon_const_type ( did, self . tcx . type_of ( param_def_id) ) ;
452- let ct = ty:: Const :: from_anon_const ( self . tcx , did) ;
453- self . register_wf_obligation (
454- ct. into ( ) ,
455- self . tcx . hir ( ) . span ( hir_ct. hir_id ) ,
456- ObligationCauseCode :: WellFormed ( None ) ,
457- ) ;
458- ct
449+ pub fn lower_const_arg (
450+ & self ,
451+ const_arg : & ConstArg < ' tcx > ,
452+ param_def_id : DefId ,
453+ ) -> ty:: Const < ' tcx > {
454+ match & const_arg. kind {
455+ ConstArgKind :: Anon ( anon) => {
456+ let did = anon. def_id ;
457+ self . tcx . feed_anon_const_type ( did, self . tcx . type_of ( param_def_id) ) ;
458+ let ct = ty:: Const :: from_anon_const ( self . tcx , did) ;
459+ self . register_wf_obligation (
460+ ct. into ( ) ,
461+ self . tcx . hir ( ) . span ( anon. hir_id ) ,
462+ ObligationCauseCode :: WellFormed ( None ) ,
463+ ) ;
464+ ct
465+ }
466+ }
459467 }
460468
461469 // If the type given by the user has free regions, save it for later, since
@@ -1282,7 +1290,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12821290 self . fcx . lower_ty ( ty) . raw . into ( )
12831291 }
12841292 ( GenericParamDefKind :: Const { .. } , GenericArg :: Const ( ct) ) => {
1285- self . fcx . lower_const_arg ( & ct . value , param. def_id ) . into ( )
1293+ self . fcx . lower_const_arg ( ct , param. def_id ) . into ( )
12861294 }
12871295 ( GenericParamDefKind :: Type { .. } , GenericArg :: Infer ( inf) ) => {
12881296 self . fcx . ty_infer ( Some ( param) , inf. span ) . into ( )
0 commit comments