@@ -16,6 +16,7 @@ use std::intrinsics;
16
16
use crate :: ty:: { self , Ty , TyCtxt } ;
17
17
use crate :: ty:: subst:: SubstsRef ;
18
18
use crate :: mir:: interpret:: Allocation ;
19
+ use syntax_pos:: Span ;
19
20
20
21
/// The shorthand encoding uses an enum's variant index `usize`
21
22
/// and is offset by this value so it never matches a real variant.
@@ -92,16 +93,16 @@ pub fn encode_with_shorthand<E, T, M>(encoder: &mut E,
92
93
Ok ( ( ) )
93
94
}
94
95
95
- pub fn encode_predicates < ' tcx , E , C > ( encoder : & mut E ,
96
- predicates : & ty:: GenericPredicates < ' tcx > ,
97
- cache : C )
98
- -> Result < ( ) , E :: Error >
96
+ pub fn encode_spanned_predicates < ' tcx , E , C > (
97
+ encoder : & mut E ,
98
+ predicates : & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] ,
99
+ cache : C ,
100
+ ) -> Result < ( ) , E :: Error >
99
101
where E : TyEncoder ,
100
102
C : for < ' b > Fn ( & ' b mut E ) -> & ' b mut FxHashMap < ty:: Predicate < ' tcx > , usize > ,
101
103
{
102
- predicates. parent . encode ( encoder) ?;
103
- predicates. predicates . len ( ) . encode ( encoder) ?;
104
- for ( predicate, span) in & predicates. predicates {
104
+ predicates. len ( ) . encode ( encoder) ?;
105
+ for ( predicate, span) in predicates {
105
106
encode_with_shorthand ( encoder, predicate, & cache) ?;
106
107
span. encode ( encoder) ?;
107
108
}
@@ -182,13 +183,15 @@ where
182
183
}
183
184
184
185
#[ inline]
185
- pub fn decode_predicates < D > ( decoder : & mut D ) -> Result < ty:: GenericPredicates < ' tcx > , D :: Error >
186
+ pub fn decode_spanned_predicates < D > (
187
+ decoder : & mut D ,
188
+ ) -> Result < & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] , D :: Error >
186
189
where
187
190
D : TyDecoder < ' tcx > ,
188
191
{
189
- Ok ( ty :: GenericPredicates {
190
- parent : Decodable :: decode ( decoder ) ? ,
191
- predicates : ( 0 ..decoder. read_usize ( ) ?) . map ( |_| {
192
+ let tcx = decoder . tcx ( ) ;
193
+ Ok ( tcx . arena . alloc_from_iter (
194
+ ( 0 ..decoder. read_usize ( ) ?) . map ( |_| {
192
195
// Handle shorthands first, if we have an usize > 0x80.
193
196
let predicate = if decoder. positioned_at_shorthand ( ) {
194
197
let pos = decoder. read_usize ( ) ?;
@@ -202,7 +205,7 @@ where
202
205
Ok ( ( predicate, Decodable :: decode ( decoder) ?) )
203
206
} )
204
207
. collect :: < Result < Vec < _ > , _ > > ( ) ?,
205
- } )
208
+ ) )
206
209
}
207
210
208
211
#[ inline]
@@ -339,6 +342,8 @@ macro_rules! implement_ty_decoder {
339
342
use $crate:: ty:: subst:: SubstsRef ;
340
343
use $crate:: hir:: def_id:: { CrateNum } ;
341
344
345
+ use syntax_pos:: Span ;
346
+
342
347
use super :: $DecoderName;
343
348
344
349
impl <$( $typaram ) ,* > Decoder for $DecoderName<$( $typaram) ,* > {
@@ -393,11 +398,11 @@ macro_rules! implement_ty_decoder {
393
398
}
394
399
}
395
400
396
- impl <$( $typaram) ,* > SpecializedDecoder <ty:: GenericPredicates <' tcx>>
401
+ impl <$( $typaram) ,* > SpecializedDecoder <& ' tcx [ ( ty:: Predicate <' tcx>, Span ) ] >
397
402
for $DecoderName<$( $typaram) ,* > {
398
403
fn specialized_decode( & mut self )
399
- -> Result <ty:: GenericPredicates <' tcx>, Self :: Error > {
400
- decode_predicates ( self )
404
+ -> Result <& ' tcx [ ( ty:: Predicate <' tcx>, Span ) ] , Self :: Error > {
405
+ decode_spanned_predicates ( self )
401
406
}
402
407
}
403
408
0 commit comments