File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,16 @@ impl<'tcx> Kind<'tcx> {
123123 }
124124 }
125125 }
126+
127+ /// Unpack the `Kind` as a type when it is known certainly to be a type.
128+ /// This is true in cases where `Substs` is used in places where the kinds are known
129+ /// to be limited (e.g. in tuples, where the only parameters are type parameters).
130+ pub fn expect_ty ( self ) -> Ty < ' tcx > {
131+ match self . unpack ( ) {
132+ UnpackedKind :: Type ( ty) => ty,
133+ _ => bug ! ( "expected a type, but found another kind" ) ,
134+ }
135+ }
126136}
127137
128138impl < ' a , ' tcx > Lift < ' tcx > for Kind < ' a > {
@@ -174,8 +184,7 @@ pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>;
174184
175185impl < ' a , ' gcx , ' tcx > InternalSubsts < ' tcx > {
176186 /// Creates a `InternalSubsts` that maps each generic parameter to itself.
177- pub fn identity_for_item ( tcx : TyCtxt < ' a , ' gcx , ' tcx > , def_id : DefId )
178- -> SubstsRef < ' tcx > {
187+ pub fn identity_for_item ( tcx : TyCtxt < ' a , ' gcx , ' tcx > , def_id : DefId ) -> SubstsRef < ' tcx > {
179188 Self :: for_item ( tcx, def_id, |param, _| {
180189 tcx. mk_param_from_def ( param)
181190 } )
You can’t perform that action at this time.
0 commit comments