@@ -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:: {
@@ -466,16 +466,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
466466 }
467467 }
468468
469- pub fn lower_const_arg ( & self , hir_ct : & hir:: AnonConst , param_def_id : DefId ) -> ty:: Const < ' tcx > {
470- let did = hir_ct. def_id ;
471- self . tcx . feed_anon_const_type ( did, self . tcx . type_of ( param_def_id) ) ;
472- let ct = ty:: Const :: from_anon_const ( self . tcx , did) ;
473- self . register_wf_obligation (
474- ct. into ( ) ,
475- self . tcx . hir ( ) . span ( hir_ct. hir_id ) ,
476- ObligationCauseCode :: WellFormed ( None ) ,
477- ) ;
478- ct
469+ pub fn lower_const_arg (
470+ & self ,
471+ const_arg : & ConstArg < ' tcx > ,
472+ param_def_id : DefId ,
473+ ) -> ty:: Const < ' tcx > {
474+ match & const_arg. kind {
475+ ConstArgKind :: Anon ( anon) => {
476+ let did = anon. def_id ;
477+ self . tcx . feed_anon_const_type ( did, self . tcx . type_of ( param_def_id) ) ;
478+ let ct = ty:: Const :: from_anon_const ( self . tcx , did) ;
479+ self . register_wf_obligation (
480+ ct. into ( ) ,
481+ self . tcx . hir ( ) . span ( anon. hir_id ) ,
482+ ObligationCauseCode :: WellFormed ( None ) ,
483+ ) ;
484+ ct
485+ }
486+ }
479487 }
480488
481489 // If the type given by the user has free regions, save it for later, since
@@ -1298,7 +1306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12981306 self . fcx . lower_ty ( ty) . raw . into ( )
12991307 }
13001308 ( GenericParamDefKind :: Const { .. } , GenericArg :: Const ( ct) ) => {
1301- self . fcx . lower_const_arg ( & ct . value , param. def_id ) . into ( )
1309+ self . fcx . lower_const_arg ( ct , param. def_id ) . into ( )
13021310 }
13031311 ( GenericParamDefKind :: Type { .. } , GenericArg :: Infer ( inf) ) => {
13041312 self . fcx . ty_infer ( Some ( param) , inf. span ) . into ( )
0 commit comments