@@ -5,10 +5,10 @@ use crate::rvalue_scopes;
5
5
use crate :: { BreakableCtxt , Diverges , Expectation , FnCtxt , LoweredTy } ;
6
6
use rustc_data_structures:: fx:: FxHashSet ;
7
7
use rustc_errors:: { Applicability , Diag , ErrorGuaranteed , MultiSpan , StashKey } ;
8
- use rustc_hir as hir;
9
8
use rustc_hir:: def:: { CtorOf , DefKind , Res } ;
10
9
use rustc_hir:: def_id:: DefId ;
11
10
use rustc_hir:: lang_items:: LangItem ;
11
+ use rustc_hir:: { self as hir, ConstArg , ConstArgKind } ;
12
12
use rustc_hir:: { ExprKind , GenericArg , HirId , Node , QPath } ;
13
13
use rustc_hir_analysis:: hir_ty_lowering:: errors:: GenericsArgsErrExtend ;
14
14
use rustc_hir_analysis:: hir_ty_lowering:: generics:: {
@@ -446,16 +446,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
446
446
}
447
447
}
448
448
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
+ }
459
467
}
460
468
461
469
// 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> {
1282
1290
self . fcx . lower_ty ( ty) . raw . into ( )
1283
1291
}
1284
1292
( 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 ( )
1286
1294
}
1287
1295
( GenericParamDefKind :: Type { .. } , GenericArg :: Infer ( inf) ) => {
1288
1296
self . fcx . ty_infer ( Some ( param) , inf. span ) . into ( )
0 commit comments