@@ -830,6 +830,8 @@ trait rbml_writer_helpers<'tcx> {
830
830
fn emit_tys < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > , tys : & [ Ty < ' tcx > ] ) ;
831
831
fn emit_type_param_def < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > ,
832
832
type_param_def : & ty:: TypeParameterDef < ' tcx > ) ;
833
+ fn emit_predicate < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > ,
834
+ predicate : & ty:: Predicate < ' tcx > ) ;
833
835
fn emit_trait_ref < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > ,
834
836
ty : & ty:: TraitRef < ' tcx > ) ;
835
837
fn emit_polytype < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > ,
@@ -936,6 +938,15 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
936
938
} ) ;
937
939
}
938
940
941
+ fn emit_predicate < ' a > ( & mut self , ecx : & e:: EncodeContext < ' a , ' tcx > ,
942
+ predicate : & ty:: Predicate < ' tcx > ) {
943
+ self . emit_opaque ( |this| {
944
+ Ok ( tyencode:: enc_predicate ( this. writer ,
945
+ & ecx. ty_str_ctxt ( ) ,
946
+ predicate) )
947
+ } ) ;
948
+ }
949
+
939
950
fn emit_polytype < ' a > ( & mut self ,
940
951
ecx : & e:: EncodeContext < ' a , ' tcx > ,
941
952
pty : ty:: Polytype < ' tcx > ) {
@@ -953,6 +964,11 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
953
964
Ok ( encode_vec_per_param_space (
954
965
this, & pty. generics . regions ,
955
966
|this, def| def. encode ( this) . unwrap ( ) ) )
967
+ } ) ;
968
+ this. emit_struct_field ( "predicates" , 2 , |this| {
969
+ Ok ( encode_vec_per_param_space (
970
+ this, & pty. generics . predicates ,
971
+ |this, def| this. emit_predicate ( ecx, def) ) )
956
972
} )
957
973
} )
958
974
} ) ;
@@ -1336,6 +1352,8 @@ trait rbml_decoder_decoder_helpers<'tcx> {
1336
1352
-> Rc < ty:: TraitRef < ' tcx > > ;
1337
1353
fn read_type_param_def < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1338
1354
-> ty:: TypeParameterDef < ' tcx > ;
1355
+ fn read_predicate < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1356
+ -> ty:: Predicate < ' tcx > ;
1339
1357
fn read_polytype < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1340
1358
-> ty:: Polytype < ' tcx > ;
1341
1359
fn read_existential_bounds < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
@@ -1536,6 +1554,15 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
1536
1554
} ) . unwrap ( )
1537
1555
}
1538
1556
1557
+ fn read_predicate < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1558
+ -> ty:: Predicate < ' tcx >
1559
+ {
1560
+ self . read_opaque ( |this, doc| {
1561
+ Ok ( tydecode:: parse_predicate_data ( doc. data , doc. start , dcx. cdata . cnum , dcx. tcx ,
1562
+ |s, a| this. convert_def_id ( dcx, s, a) ) )
1563
+ } ) . unwrap ( )
1564
+ }
1565
+
1539
1566
fn read_polytype < ' a , ' b > ( & mut self , dcx : & DecodeContext < ' a , ' b , ' tcx > )
1540
1567
-> ty:: Polytype < ' tcx > {
1541
1568
self . read_struct ( "Polytype" , 2 , |this| {
@@ -1556,7 +1583,10 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
1556
1583
} ) . unwrap ( ) ,
1557
1584
1558
1585
predicates :
1559
- subst:: VecPerParamSpace :: empty ( ) , // TODO fix in later commit
1586
+ this. read_struct_field ( "predicates" , 2 , |this| {
1587
+ Ok ( this. read_vec_per_param_space (
1588
+ |this| this. read_predicate ( dcx) ) )
1589
+ } ) . unwrap ( ) ,
1560
1590
} )
1561
1591
} )
1562
1592
} ) . unwrap ( ) ,
0 commit comments