@@ -108,6 +108,23 @@ impl<'tcx> Context for Tables<'tcx> {
108
108
let generic_def = self . tcx . generics_of ( def_id) ;
109
109
generic_def. stable ( self )
110
110
}
111
+
112
+ fn predicates_of (
113
+ & mut self ,
114
+ trait_def : & stable_mir:: ty:: TraitDef ,
115
+ ) -> stable_mir:: GenericPredicates {
116
+ let trait_def_id = self . trait_def_id ( trait_def) ;
117
+ let ty:: GenericPredicates { parent, predicates } = self . tcx . predicates_of ( trait_def_id) ;
118
+ stable_mir:: GenericPredicates {
119
+ parent : parent. map ( |did| self . trait_def ( did) ) ,
120
+ predicates : predicates
121
+ . iter ( )
122
+ . map ( |( clause, span) | {
123
+ ( clause. as_predicate ( ) . kind ( ) . skip_binder ( ) . stable ( self ) , span. stable ( self ) )
124
+ } )
125
+ . collect ( ) ,
126
+ }
127
+ }
111
128
}
112
129
113
130
pub struct Tables < ' tcx > {
@@ -947,12 +964,12 @@ impl<'tcx> Stable<'tcx> for ty::BoundTyKind {
947
964
impl < ' tcx > Stable < ' tcx > for ty:: BoundRegionKind {
948
965
type T = stable_mir:: ty:: BoundRegionKind ;
949
966
950
- fn stable ( & self , _ : & mut Tables < ' tcx > ) -> Self :: T {
967
+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
951
968
use stable_mir:: ty:: BoundRegionKind ;
952
969
953
970
match self {
954
971
ty:: BoundRegionKind :: BrAnon ( option_span) => {
955
- BoundRegionKind :: BrAnon ( option_span. map ( |span| opaque ( & span) ) )
972
+ BoundRegionKind :: BrAnon ( option_span. map ( |span| span. stable ( tables ) ) )
956
973
}
957
974
ty:: BoundRegionKind :: BrNamed ( def_id, symbol) => {
958
975
BoundRegionKind :: BrNamed ( rustc_internal:: br_named_def ( * def_id) , symbol. to_string ( ) )
@@ -1242,14 +1259,6 @@ impl<'tcx> Stable<'tcx> for ty::Generics {
1242
1259
}
1243
1260
}
1244
1261
1245
- impl < ' tcx > Stable < ' tcx > for rustc_span:: Span {
1246
- type T = stable_mir:: ty:: Span ;
1247
-
1248
- fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1249
- opaque ( self )
1250
- }
1251
- }
1252
-
1253
1262
impl < ' tcx > Stable < ' tcx > for rustc_middle:: ty:: GenericParamDefKind {
1254
1263
type T = stable_mir:: ty:: GenericParamDefKind ;
1255
1264
@@ -1456,3 +1465,12 @@ impl<'tcx> Stable<'tcx> for ty::Region<'tcx> {
1456
1465
opaque ( self )
1457
1466
}
1458
1467
}
1468
+
1469
+ impl < ' tcx > Stable < ' tcx > for rustc_span:: Span {
1470
+ type T = stable_mir:: ty:: Span ;
1471
+
1472
+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
1473
+ // FIXME: add a real implementation of stable spans
1474
+ opaque ( self )
1475
+ }
1476
+ }
0 commit comments