@@ -2437,6 +2437,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
24372437 ty
24382438 }
24392439
2440+ pub fn to_const ( & self , ast_c : & hir:: AnonConst , ty : Ty < ' tcx > ) -> & ' tcx ty:: LazyConst < ' tcx > {
2441+ AstConv :: ast_const_to_const ( self , ast_c, ty)
2442+ }
2443+
24402444 // If the type given by the user has free regions, save it for later, since
24412445 // NLL would like to enforce those. Also pass in types that involve
24422446 // projections, since those can resolve to `'static` bounds (modulo #54940,
@@ -5501,6 +5505,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
55015505 ( GenericParamDefKind :: Type { .. } , GenericArg :: Type ( ty) ) => {
55025506 self . to_ty ( ty) . into ( )
55035507 }
5508+ ( GenericParamDefKind :: Const , GenericArg :: Const ( ct) ) => {
5509+ self . to_const ( & ct. value , self . tcx . type_of ( param. def_id ) ) . into ( )
5510+ }
55045511 _ => unreachable ! ( ) ,
55055512 }
55065513 } ,
@@ -5528,6 +5535,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
55285535 self . var_for_def ( span, param)
55295536 }
55305537 }
5538+ GenericParamDefKind :: Const => {
5539+ // FIXME(const_generics:defaults)
5540+ // No const parameters were provided, we have to infer them.
5541+ self . var_for_def ( span, param)
5542+ }
55315543 }
55325544 } ,
55335545 ) ;
@@ -5685,11 +5697,19 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
56855697 generics : & ty:: Generics ,
56865698 ty : Ty < ' tcx > ) {
56875699 let own_counts = generics. own_counts ( ) ;
5688- debug ! ( "check_bounds_are_used(n_tps={}, ty={:?})" , own_counts. types, ty) ;
5700+ debug ! (
5701+ "check_bounds_are_used(n_tys={}, n_cts={}, ty={:?})" ,
5702+ own_counts. types,
5703+ own_counts. consts,
5704+ ty
5705+ ) ;
5706+
5707+ // FIXME(const_generics): we probably want to check the bounds for const parameters too.
56895708
56905709 if own_counts. types == 0 {
56915710 return ;
56925711 }
5712+
56935713 // Make a vector of booleans initially false, set to true when used.
56945714 let mut types_used = vec ! [ false ; own_counts. types] ;
56955715
0 commit comments