@@ -258,6 +258,72 @@ impl<'tcx> Stable<'tcx> for ty::AliasTy<'tcx> {
258258 }
259259}
260260
261+ impl < ' tcx > Stable < ' tcx > for ty:: DynKind {
262+ type T = stable_mir:: ty:: DynKind ;
263+
264+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
265+ use ty:: DynKind ;
266+ match self {
267+ DynKind :: Dyn => stable_mir:: ty:: DynKind :: Dyn ,
268+ DynKind :: DynStar => stable_mir:: ty:: DynKind :: DynStar ,
269+ }
270+ }
271+ }
272+
273+ impl < ' tcx > Stable < ' tcx > for ty:: ExistentialPredicate < ' tcx > {
274+ type T = stable_mir:: ty:: ExistentialPredicate ;
275+
276+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
277+ use stable_mir:: ty:: ExistentialPredicate :: * ;
278+ match self {
279+ ty:: ExistentialPredicate :: Trait ( existential_trait_ref) => {
280+ Trait ( existential_trait_ref. stable ( tables) )
281+ }
282+ ty:: ExistentialPredicate :: Projection ( existential_projection) => {
283+ Projection ( existential_projection. stable ( tables) )
284+ }
285+ ty:: ExistentialPredicate :: AutoTrait ( def_id) => AutoTrait ( tables. trait_def ( * def_id) ) ,
286+ }
287+ }
288+ }
289+
290+ impl < ' tcx > Stable < ' tcx > for ty:: ExistentialTraitRef < ' tcx > {
291+ type T = stable_mir:: ty:: ExistentialTraitRef ;
292+
293+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
294+ let ty:: ExistentialTraitRef { def_id, args } = self ;
295+ stable_mir:: ty:: ExistentialTraitRef {
296+ def_id : tables. trait_def ( * def_id) ,
297+ generic_args : args. stable ( tables) ,
298+ }
299+ }
300+ }
301+
302+ impl < ' tcx > Stable < ' tcx > for ty:: TermKind < ' tcx > {
303+ type T = stable_mir:: ty:: TermKind ;
304+
305+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
306+ use stable_mir:: ty:: TermKind ;
307+ match self {
308+ ty:: TermKind :: Ty ( ty) => TermKind :: Type ( tables. intern_ty ( * ty) ) ,
309+ ty:: TermKind :: Const ( const_) => TermKind :: Const ( opaque ( const_) ) ,
310+ }
311+ }
312+ }
313+
314+ impl < ' tcx > Stable < ' tcx > for ty:: ExistentialProjection < ' tcx > {
315+ type T = stable_mir:: ty:: ExistentialProjection ;
316+
317+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
318+ let ty:: ExistentialProjection { def_id, args, term } = self ;
319+ stable_mir:: ty:: ExistentialProjection {
320+ def_id : tables. trait_def ( * def_id) ,
321+ generic_args : args. stable ( tables) ,
322+ term : term. unpack ( ) . stable ( tables) ,
323+ }
324+ }
325+ }
326+
261327impl < ' tcx > Stable < ' tcx > for ty:: adjustment:: PointerCoercion {
262328 type T = stable_mir:: mir:: PointerCoercion ;
263329 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
@@ -525,13 +591,17 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
525591 }
526592}
527593
528- impl < ' tcx > Stable < ' tcx > for ty:: PolyFnSig < ' tcx > {
529- type T = stable_mir:: ty:: PolyFnSig ;
594+ impl < ' tcx , S , V > Stable < ' tcx > for ty:: Binder < ' tcx , S >
595+ where
596+ S : Stable < ' tcx , T = V > ,
597+ {
598+ type T = stable_mir:: ty:: Binder < V > ;
599+
530600 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
531601 use stable_mir:: ty:: Binder ;
532602
533603 Binder {
534- value : self . skip_binder ( ) . stable ( tables) ,
604+ value : self . as_ref ( ) . skip_binder ( ) . stable ( tables) ,
535605 bound_vars : self
536606 . bound_vars ( )
537607 . iter ( )
@@ -671,7 +741,16 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
671741 generic_args. stable ( tables) ,
672742 ) ) ,
673743 ty:: FnPtr ( poly_fn_sig) => TyKind :: RigidTy ( RigidTy :: FnPtr ( poly_fn_sig. stable ( tables) ) ) ,
674- ty:: Dynamic ( _, _, _) => todo ! ( ) ,
744+ ty:: Dynamic ( existential_predicates, region, dyn_kind) => {
745+ TyKind :: RigidTy ( RigidTy :: Dynamic (
746+ existential_predicates
747+ . iter ( )
748+ . map ( |existential_predicate| existential_predicate. stable ( tables) )
749+ . collect ( ) ,
750+ opaque ( region) ,
751+ dyn_kind. stable ( tables) ,
752+ ) )
753+ }
675754 ty:: Closure ( def_id, generic_args) => TyKind :: RigidTy ( RigidTy :: Closure (
676755 rustc_internal:: closure_def ( * def_id) ,
677756 generic_args. stable ( tables) ,
0 commit comments