File tree 1 file changed +11
-2
lines changed
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> {
123
123
}
124
124
}
125
125
}
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
+ }
126
136
}
127
137
128
138
impl < ' a , ' tcx > Lift < ' tcx > for Kind < ' a > {
@@ -174,8 +184,7 @@ pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>;
174
184
175
185
impl < ' a , ' gcx , ' tcx > InternalSubsts < ' tcx > {
176
186
/// 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 > {
179
188
Self :: for_item ( tcx, def_id, |param, _| {
180
189
tcx. mk_param_from_def ( param)
181
190
} )
You can’t perform that action at this time.
0 commit comments