@@ -147,7 +147,7 @@ macro_rules! make_value_visitor {
147
147
{
148
148
Ok ( ( ) )
149
149
}
150
- /// Visits this vale as an aggregate, you are even getting an iterator yielding
150
+ /// Visits this value as an aggregate, you are getting an iterator yielding
151
151
/// all the fields (still in an `EvalResult`, you have to do error handling yourself).
152
152
/// Recurses into the fields.
153
153
#[ inline( always) ]
@@ -160,7 +160,8 @@ macro_rules! make_value_visitor {
160
160
}
161
161
162
162
/// Called each time we recurse down to a field of a "product-like" aggregate
163
- /// (structs, tuples, arrays and the like, but not enums), passing in old and new value.
163
+ /// (structs, tuples, arrays and the like, but not enums), passing in old (outer)
164
+ /// and new (inner) value.
164
165
/// This gives the visitor the chance to track the stack of nested fields that
165
166
/// we are descending through.
166
167
#[ inline( always) ]
@@ -173,18 +174,6 @@ macro_rules! make_value_visitor {
173
174
self . visit_value( new_val)
174
175
}
175
176
176
- /// Called for recursing into the field of a generator. These are not known to be
177
- /// initialized, so we treat them like unions.
178
- #[ inline( always) ]
179
- fn visit_generator_field(
180
- & mut self ,
181
- _old_val: Self :: V ,
182
- _field: usize ,
183
- new_val: Self :: V ,
184
- ) -> EvalResult <' tcx> {
185
- self . visit_union( new_val)
186
- }
187
-
188
177
/// Called when recursing into an enum variant.
189
178
#[ inline( always) ]
190
179
fn visit_variant(
@@ -238,7 +227,7 @@ macro_rules! make_value_visitor {
238
227
fn walk_value( & mut self , v: Self :: V ) -> EvalResult <' tcx>
239
228
{
240
229
trace!( "walk_value: type: {}" , v. layout( ) . ty) ;
241
- // If this is a multi-variant layout, we have find the right one and proceed with
230
+ // If this is a multi-variant layout, we have to find the right one and proceed with
242
231
// that.
243
232
match v. layout( ) . variants {
244
233
layout:: Variants :: Multiple { .. } => {
@@ -263,6 +252,13 @@ macro_rules! make_value_visitor {
263
252
// recurse with the inner type
264
253
return self . visit_field( v, 0 , Value :: from_mem_place( inner) ) ;
265
254
} ,
255
+ ty:: Generator ( ..) => {
256
+ // FIXME: Generator layout is lying: it claims a whole bunch of fields exist
257
+ // when really many of them can be uninitialized.
258
+ // Just treat them as a union for now, until hopefully the layout
259
+ // computation is fixed.
260
+ return self . visit_union( v) ;
261
+ }
266
262
_ => { } ,
267
263
} ;
268
264
@@ -304,34 +300,18 @@ macro_rules! make_value_visitor {
304
300
// Empty unions are not accepted by rustc. That's great, it means we can
305
301
// use that as an unambiguous signal for detecting primitives. Make sure
306
302
// we did not miss any primitive.
307
- debug_assert !( fields > 0 ) ;
303
+ assert !( fields > 0 ) ;
308
304
self . visit_union( v)
309
305
} ,
310
306
layout:: FieldPlacement :: Arbitrary { ref offsets, .. } => {
311
- // Special handling needed for generators: All but the first field
312
- // (which is the state) are actually implicitly `MaybeUninit`, i.e.,
313
- // they may or may not be initialized, so we cannot visit them.
314
- match v. layout( ) . ty. sty {
315
- ty:: Generator ( ..) => {
316
- let field = v. project_field( self . ecx( ) , 0 ) ?;
317
- self . visit_aggregate( v, std:: iter:: once( Ok ( field) ) ) ?;
318
- for i in 1 ..offsets. len( ) {
319
- let field = v. project_field( self . ecx( ) , i as u64 ) ?;
320
- self . visit_generator_field( v, i, field) ?;
321
- }
322
- Ok ( ( ) )
323
- }
324
- _ => {
325
- // FIXME: We collect in a vec because otherwise there are lifetime
326
- // errors: Projecting to a field needs access to `ecx`.
327
- let fields: Vec <EvalResult <' tcx, Self :: V >> =
328
- ( 0 ..offsets. len( ) ) . map( |i| {
329
- v. project_field( self . ecx( ) , i as u64 )
330
- } )
331
- . collect( ) ;
332
- self . visit_aggregate( v, fields. into_iter( ) )
333
- }
334
- }
307
+ // FIXME: We collect in a vec because otherwise there are lifetime
308
+ // errors: Projecting to a field needs access to `ecx`.
309
+ let fields: Vec <EvalResult <' tcx, Self :: V >> =
310
+ ( 0 ..offsets. len( ) ) . map( |i| {
311
+ v. project_field( self . ecx( ) , i as u64 )
312
+ } )
313
+ . collect( ) ;
314
+ self . visit_aggregate( v, fields. into_iter( ) )
335
315
} ,
336
316
layout:: FieldPlacement :: Array { .. } => {
337
317
// Let's get an mplace first.
0 commit comments