@@ -134,14 +134,14 @@ impl<'a, 'tcx, T: Decodable> Lazy<T> {
134
134
}
135
135
}
136
136
137
- impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> LazySeq<T > {
137
+ impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> Lazy<[T] > {
138
138
pub fn decode<M: Metadata<'a, 'tcx>>(
139
139
self,
140
140
meta: M,
141
141
) -> impl ExactSizeIterator<Item = T> + Captures<'a> + Captures<'tcx> + 'x {
142
142
let mut dcx = meta.decoder(self.position);
143
143
dcx.lazy_state = LazyState::NodeStart(self.position);
144
- (0..self.len ).map(move |_| T::decode(&mut dcx).unwrap())
144
+ (0..self.meta ).map(move |_| T::decode(&mut dcx).unwrap())
145
145
}
146
146
}
147
147
@@ -154,18 +154,22 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
154
154
self.cdata.expect("missing CrateMetadata in DecodeContext")
155
155
}
156
156
157
- fn read_lazy_distance(&mut self, min_size: usize) -> Result<usize, <Self as Decoder>::Error> {
157
+ fn read_lazy_with_meta<T: ?Sized + LazyMeta>(
158
+ &mut self,
159
+ meta: T::Meta,
160
+ ) -> Result<Lazy<T>, <Self as Decoder>::Error> {
161
+ let min_size = T::min_size(meta);
158
162
let distance = self.read_usize()?;
159
163
let position = match self.lazy_state {
160
- LazyState::NoNode => bug!("read_lazy_distance : outside of a metadata node"),
164
+ LazyState::NoNode => bug!("read_lazy_with_meta : outside of a metadata node"),
161
165
LazyState::NodeStart(start) => {
162
166
assert!(distance + min_size <= start);
163
167
start - distance - min_size
164
168
}
165
169
LazyState::Previous(last_min_end) => last_min_end + distance,
166
170
};
167
171
self.lazy_state = LazyState::Previous(position + min_size);
168
- Ok(position)
172
+ Ok(Lazy::from_position_and_meta( position, meta) )
169
173
}
170
174
}
171
175
@@ -230,19 +234,18 @@ impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
230
234
231
235
impl<'a, 'tcx, T> SpecializedDecoder<Lazy<T>> for DecodeContext<'a, 'tcx> {
232
236
fn specialized_decode(&mut self) -> Result<Lazy<T>, Self::Error> {
233
- Ok(Lazy::with_position( self.read_lazy_distance(Lazy::<T>::min_size())? ))
237
+ self.read_lazy_with_meta(( ))
234
238
}
235
239
}
236
240
237
- impl<'a, 'tcx, T> SpecializedDecoder<LazySeq<T >> for DecodeContext<'a, 'tcx> {
238
- fn specialized_decode(&mut self) -> Result<LazySeq<T >, Self::Error> {
241
+ impl<'a, 'tcx, T> SpecializedDecoder<Lazy<[T] >> for DecodeContext<'a, 'tcx> {
242
+ fn specialized_decode(&mut self) -> Result<Lazy<[T] >, Self::Error> {
239
243
let len = self.read_usize()?;
240
- let position = if len == 0 {
241
- 0
244
+ if len == 0 {
245
+ Ok(Lazy::empty())
242
246
} else {
243
- self.read_lazy_distance(LazySeq::<T>::min_size(len))?
244
- };
245
- Ok(LazySeq::with_position_and_length(position, len))
247
+ self.read_lazy_with_meta(len)
248
+ }
246
249
}
247
250
}
248
251
@@ -378,7 +381,7 @@ impl<'tcx> MetadataBlob {
378
381
}
379
382
380
383
pub fn get_rustc_version(&self) -> String {
381
- Lazy::with_position (METADATA_HEADER.len() + 4).decode(self)
384
+ Lazy::<String>::from_position (METADATA_HEADER.len() + 4).decode(self)
382
385
}
383
386
384
387
pub fn get_root(&self) -> CrateRoot<'tcx> {
@@ -387,7 +390,7 @@ impl<'tcx> MetadataBlob {
387
390
let pos = (((slice[offset + 0] as u32) << 24) | ((slice[offset + 1] as u32) << 16) |
388
391
((slice[offset + 2] as u32) << 8) |
389
392
((slice[offset + 3] as u32) << 0)) as usize;
390
- Lazy::with_position (pos).decode(self)
393
+ Lazy::<CrateRoot<'tcx>>::from_position (pos).decode(self)
391
394
}
392
395
393
396
pub fn list_crate_metadata(&self,
@@ -1140,7 +1143,7 @@ impl<'a, 'tcx> CrateMetadata {
1140
1143
EntryKind::Fn(data) |
1141
1144
EntryKind::ForeignFn(data) => data.decode(self).arg_names,
1142
1145
EntryKind::Method(data) => data.decode(self).fn_data.arg_names,
1143
- _ => LazySeq ::empty(),
1146
+ _ => Lazy ::empty(),
1144
1147
};
1145
1148
arg_names.decode(self).collect()
1146
1149
}
0 commit comments