@@ -41,6 +41,21 @@ impl<'tcx> Context for Tables<'tcx> {
41
41
fn entry_fn ( & mut self ) -> Option < stable_mir:: CrateItem > {
42
42
Some ( self . crate_item ( self . tcx . entry_fn ( ( ) ) ?. 0 ) )
43
43
}
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
+
44
59
fn mir_body ( & mut self , item : & stable_mir:: CrateItem ) -> stable_mir:: mir:: Body {
45
60
let def_id = self . item_def_id ( item) ;
46
61
let mir = self . tcx . optimized_mir ( def_id) ;
@@ -515,7 +530,7 @@ impl<'tcx> Stable<'tcx> for mir::RetagKind {
515
530
}
516
531
}
517
532
518
- impl < ' tcx > Stable < ' tcx > for rustc_middle :: ty:: UserTypeAnnotationIndex {
533
+ impl < ' tcx > Stable < ' tcx > for ty:: UserTypeAnnotationIndex {
519
534
type T = usize ;
520
535
fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
521
536
self . as_usize ( )
@@ -826,7 +841,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
826
841
type T = stable_mir:: ty:: FnSig ;
827
842
fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
828
843
use rustc_target:: spec:: abi;
829
- use stable_mir:: ty:: { Abi , FnSig , Unsafety } ;
844
+ use stable_mir:: ty:: { Abi , FnSig } ;
830
845
831
846
FnSig {
832
847
inputs_and_output : self
@@ -835,10 +850,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
835
850
. map ( |ty| tables. intern_ty ( ty) )
836
851
. collect ( ) ,
837
852
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) ,
842
854
abi : match self . abi {
843
855
abi:: Abi :: Rust => Abi :: Rust ,
844
856
abi:: Abi :: C { unwind } => Abi :: C { unwind } ,
@@ -1048,15 +1060,15 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
1048
1060
}
1049
1061
}
1050
1062
1051
- impl < ' tcx > Stable < ' tcx > for rustc_middle :: ty:: ParamTy {
1063
+ impl < ' tcx > Stable < ' tcx > for ty:: ParamTy {
1052
1064
type T = stable_mir:: ty:: ParamTy ;
1053
1065
fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1054
1066
use stable_mir:: ty:: ParamTy ;
1055
1067
ParamTy { index : self . index , name : self . name . to_string ( ) }
1056
1068
}
1057
1069
}
1058
1070
1059
- impl < ' tcx > Stable < ' tcx > for rustc_middle :: ty:: BoundTy {
1071
+ impl < ' tcx > Stable < ' tcx > for ty:: BoundTy {
1060
1072
type T = stable_mir:: ty:: BoundTy ;
1061
1073
fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
1062
1074
use stable_mir:: ty:: BoundTy ;
@@ -1094,3 +1106,42 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
1094
1106
}
1095
1107
}
1096
1108
}
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