@@ -12,6 +12,7 @@ use crate::ty::subst::{Subst, InternalSubsts, SubstsRef, UnpackedKind};
1212use crate :: ty:: query:: TyCtxtAt ;
1313use crate :: ty:: TyKind :: * ;
1414use crate :: ty:: layout:: { Integer , IntegerExt } ;
15+ use crate :: mir:: interpret:: ConstValue ;
1516use crate :: util:: common:: ErrorReported ;
1617use crate :: middle:: lang_items;
1718
@@ -495,8 +496,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
495496 } ) => {
496497 !impl_generics. type_param ( pt, self ) . pure_wrt_drop
497498 }
498- UnpackedKind :: Lifetime ( _) | UnpackedKind :: Type ( _) => {
499- // not a type or region param - this should be reported
499+ UnpackedKind :: Const ( & ty:: LazyConst :: Evaluated ( ty:: Const {
500+ val : ConstValue :: Param ( ref pc) ,
501+ ..
502+ } ) ) => {
503+ !impl_generics. const_param ( pc, self ) . pure_wrt_drop
504+ }
505+ UnpackedKind :: Lifetime ( _) |
506+ UnpackedKind :: Type ( _) |
507+ UnpackedKind :: Const ( _) => {
508+ // Not a type, const or region param: this should be reported
500509 // as an error.
501510 false
502511 }
@@ -587,15 +596,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
587596 Some ( ty:: Binder :: bind ( env_ty) )
588597 }
589598
590- /// Given the `DefId` of some item that has no type parameters, make
599+ /// Given the `DefId` of some item that has no type or const parameters, make
591600 /// a suitable "empty substs" for it.
592601 pub fn empty_substs_for_def_id ( self , item_def_id : DefId ) -> SubstsRef < ' tcx > {
593602 InternalSubsts :: for_item ( self , item_def_id, |param, _| {
594603 match param. kind {
595604 GenericParamDefKind :: Lifetime => self . types . re_erased . into ( ) ,
596- GenericParamDefKind :: Type { .. } => {
605+ GenericParamDefKind :: Type { .. } => {
597606 bug ! ( "empty_substs_for_def_id: {:?} has type parameters" , item_def_id)
598607 }
608+ GenericParamDefKind :: Const { .. } => {
609+ bug ! ( "empty_substs_for_def_id: {:?} has const parameters" , item_def_id)
610+ }
599611 }
600612 } )
601613 }
0 commit comments