@@ -41,6 +41,21 @@ impl<'tcx> Context for Tables<'tcx> {
4141 fn entry_fn ( & mut self ) -> Option < stable_mir:: CrateItem > {
4242 Some ( self . crate_item ( self . tcx . entry_fn ( ( ) ) ?. 0 ) )
4343 }
44+
45+ fn all_trait_decls ( & mut self ) -> stable_mir:: TraitDecls {
46+ self . tcx
47+ . traits ( LOCAL_CRATE )
48+ . iter ( )
49+ . map ( |trait_def_id| self . trait_def ( * trait_def_id) )
50+ . collect ( )
51+ }
52+
53+ fn trait_decl ( & mut self , trait_def : & stable_mir:: ty:: TraitDef ) -> stable_mir:: ty:: TraitDecl {
54+ let def_id = self . trait_def_id ( trait_def) ;
55+ let trait_def = self . tcx . trait_def ( def_id) ;
56+ trait_def. stable ( self )
57+ }
58+
4459 fn mir_body ( & mut self , item : & stable_mir:: CrateItem ) -> stable_mir:: mir:: Body {
4560 let def_id = self . item_def_id ( item) ;
4661 let mir = self . tcx . optimized_mir ( def_id) ;
@@ -515,7 +530,7 @@ impl<'tcx> Stable<'tcx> for mir::RetagKind {
515530 }
516531}
517532
518- impl < ' tcx > Stable < ' tcx > for rustc_middle :: ty:: UserTypeAnnotationIndex {
533+ impl < ' tcx > Stable < ' tcx > for ty:: UserTypeAnnotationIndex {
519534 type T = usize ;
520535 fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
521536 self . as_usize ( )
@@ -826,7 +841,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
826841 type T = stable_mir:: ty:: FnSig ;
827842 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
828843 use rustc_target:: spec:: abi;
829- use stable_mir:: ty:: { Abi , FnSig , Unsafety } ;
844+ use stable_mir:: ty:: { Abi , FnSig } ;
830845
831846 FnSig {
832847 inputs_and_output : self
@@ -835,10 +850,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
835850 . map ( |ty| tables. intern_ty ( ty) )
836851 . collect ( ) ,
837852 c_variadic : self . c_variadic ,
838- unsafety : match self . unsafety {
839- hir:: Unsafety :: Normal => Unsafety :: Normal ,
840- hir:: Unsafety :: Unsafe => Unsafety :: Unsafe ,
841- } ,
853+ unsafety : self . unsafety . stable ( tables) ,
842854 abi : match self . abi {
843855 abi:: Abi :: Rust => Abi :: Rust ,
844856 abi:: Abi :: C { unwind } => Abi :: C { unwind } ,
@@ -1048,15 +1060,15 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
10481060 }
10491061}
10501062
1051- impl < ' tcx > Stable < ' tcx > for rustc_middle :: ty:: ParamTy {
1063+ impl < ' tcx > Stable < ' tcx > for ty:: ParamTy {
10521064 type T = stable_mir:: ty:: ParamTy ;
10531065 fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
10541066 use stable_mir:: ty:: ParamTy ;
10551067 ParamTy { index : self . index , name : self . name . to_string ( ) }
10561068 }
10571069}
10581070
1059- impl < ' tcx > Stable < ' tcx > for rustc_middle :: ty:: BoundTy {
1071+ impl < ' tcx > Stable < ' tcx > for ty:: BoundTy {
10601072 type T = stable_mir:: ty:: BoundTy ;
10611073 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
10621074 use stable_mir:: ty:: BoundTy ;
@@ -1094,3 +1106,42 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
10941106 }
10951107 }
10961108}
1109+
1110+ impl < ' tcx > Stable < ' tcx > for ty:: trait_def:: TraitSpecializationKind {
1111+ type T = stable_mir:: ty:: TraitSpecializationKind ;
1112+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1113+ use stable_mir:: ty:: TraitSpecializationKind ;
1114+
1115+ match self {
1116+ ty:: trait_def:: TraitSpecializationKind :: None => TraitSpecializationKind :: None ,
1117+ ty:: trait_def:: TraitSpecializationKind :: Marker => TraitSpecializationKind :: Marker ,
1118+ ty:: trait_def:: TraitSpecializationKind :: AlwaysApplicable => {
1119+ TraitSpecializationKind :: AlwaysApplicable
1120+ }
1121+ }
1122+ }
1123+ }
1124+
1125+ impl < ' tcx > Stable < ' tcx > for ty:: TraitDef {
1126+ type T = stable_mir:: ty:: TraitDecl ;
1127+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1128+ use stable_mir:: ty:: TraitDecl ;
1129+
1130+ TraitDecl {
1131+ def_id : rustc_internal:: trait_def ( self . def_id ) ,
1132+ unsafety : self . unsafety . stable ( tables) ,
1133+ paren_sugar : self . paren_sugar ,
1134+ has_auto_impl : self . has_auto_impl ,
1135+ is_marker : self . is_marker ,
1136+ is_coinductive : self . is_coinductive ,
1137+ skip_array_during_method_dispatch : self . skip_array_during_method_dispatch ,
1138+ specialization_kind : self . specialization_kind . stable ( tables) ,
1139+ must_implement_one_of : self
1140+ . must_implement_one_of
1141+ . as_ref ( )
1142+ . map ( |idents| idents. iter ( ) . map ( |ident| opaque ( ident) ) . collect ( ) ) ,
1143+ implement_via_object : self . implement_via_object ,
1144+ deny_explicit_impl : self . deny_explicit_impl ,
1145+ }
1146+ }
1147+ }
0 commit comments