@@ -194,8 +194,10 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
194
194
}
195
195
Some ( adj) => { adj }
196
196
} ;
197
- debug ! ( "unadjusted datum for expr {}: {}" ,
198
- expr. id, datum. to_string( bcx. ccx( ) ) ) ;
197
+ debug ! ( "unadjusted datum for expr {}: {}, adjustment={}" ,
198
+ expr. repr( bcx. tcx( ) ) ,
199
+ datum. to_string( bcx. ccx( ) ) ,
200
+ adjustment. repr( bcx. tcx( ) ) ) ;
199
201
match adjustment {
200
202
AdjustAddEnv ( ..) => {
201
203
datum = unpack_datum ! ( bcx, add_env( bcx, expr, datum) ) ;
@@ -265,9 +267,10 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
265
267
& AutoPtr ( _, _, ref a) | & AutoUnsafe ( _, ref a) => {
266
268
debug ! ( " AutoPtr" ) ;
267
269
match a {
268
- & Some ( box ref a) => datum = unpack_datum ! ( bcx,
269
- apply_autoref( a, bcx, expr, datum) ) ,
270
- _ => { }
270
+ & Some ( box ref a) => {
271
+ datum = unpack_datum ! ( bcx, apply_autoref( a, bcx, expr, datum) ) ;
272
+ }
273
+ & None => { }
271
274
}
272
275
unpack_datum ! ( bcx, ref_ptr( bcx, expr, datum) )
273
276
}
@@ -293,6 +296,10 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
293
296
expr : & ast:: Expr ,
294
297
datum : Datum < ' tcx , Expr > )
295
298
-> DatumBlock < ' blk , ' tcx , Expr > {
299
+ debug ! ( "ref_ptr(expr={}, datum={})" ,
300
+ expr. repr( bcx. tcx( ) ) ,
301
+ datum. to_string( bcx. ccx( ) ) ) ;
302
+
296
303
if !ty:: type_is_sized ( bcx. tcx ( ) , datum. ty ) {
297
304
debug ! ( "Taking address of unsized type {}" ,
298
305
bcx. ty_to_string( datum. ty) ) ;
@@ -307,34 +314,36 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
307
314
// Retrieve the information we are losing (making dynamic) in an unsizing
308
315
// adjustment.
309
316
// When making a dtor, we need to do different things depending on the
310
- // ownership of the object.. mk_ty is a function for turning unsized_type
317
+ // ownership of the object.. mk_ty is a function for turning `unadjusted_ty`
311
318
// into a type to be destructed. If we want to end up with a Box pointer,
312
319
// then mk_ty should make a Box pointer (T -> Box<T>), if we want a
313
320
// borrowed reference then it should be T -> &T.
314
321
fn unsized_info < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
315
322
kind : & ty:: UnsizeKind < ' tcx > ,
316
323
id : ast:: NodeId ,
317
- unsized_ty : Ty < ' tcx > ,
324
+ unadjusted_ty : Ty < ' tcx > ,
318
325
mk_ty: |Ty < ' tcx > | -> Ty < ' tcx > ) -> ValueRef {
326
+ debug!( "unsized_info(kind={}, id={}, unadjusted_ty={})" ,
327
+ kind, id, unadjusted_ty. repr( bcx. tcx( ) ) ) ;
319
328
match kind {
320
329
& ty:: UnsizeLength ( len ) => C_uint ( bcx. ccx ( ) , len ) ,
321
- & ty:: UnsizeStruct ( box ref k , tp_index ) => match unsized_ty . sty {
330
+ & ty:: UnsizeStruct ( box ref k , tp_index ) => match unadjusted_ty . sty {
322
331
ty : : ty_struct( _, ref substs) => {
323
332
let ty_substs = substs. types. get_slice( subst:: TypeSpace ) ;
324
333
// The dtor for a field treats it like a value, so mk_ty
325
334
// should just be the identity function.
326
335
unsized_info( bcx, k, id, ty_substs[ tp_index] , |t| t)
327
336
}
328
337
_ => bcx. sess ( ) . bug( format ! ( "UnsizeStruct with bad sty: {}" ,
329
- bcx. ty_to_string( unsized_ty ) ) . as_slice( ) )
338
+ bcx. ty_to_string( unadjusted_ty ) ) . as_slice( ) )
330
339
} ,
331
340
& ty:: UnsizeVtable ( ty:: TyTrait { ref principal, .. } , _) => {
332
- let substs = principal. substs. with_self_ty( unsized_ty ) . erase_regions( ) ;
341
+ let substs = principal. substs. with_self_ty( unadjusted_ty ) . erase_regions( ) ;
333
342
let trait_ref =
334
343
Rc :: new( ty:: TraitRef { def_id : principal. def_id,
335
344
substs : substs } ) ;
336
345
let trait_ref = trait_ref. subst( bcx. tcx( ) , bcx. fcx. param_substs) ;
337
- let box_ty = mk_ty( unsized_ty ) ;
346
+ let box_ty = mk_ty( unadjusted_ty ) ;
338
347
PointerCast ( bcx,
339
348
meth:: get_vtable( bcx, box_ty, trait_ref) ,
340
349
Type :: vtable_ptr( bcx. ccx( ) ) )
@@ -350,7 +359,9 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
350
359
let tcx = bcx. tcx ( ) ;
351
360
let datum_ty = datum. ty ;
352
361
let unsized_ty = ty:: unsize_ty ( tcx, datum_ty, k, expr. span ) ;
362
+ debug ! ( "unsized_ty={}" , unsized_ty. repr( bcx. tcx( ) ) ) ;
353
363
let dest_ty = ty:: mk_open ( tcx, unsized_ty) ;
364
+ debug ! ( "dest_ty={}" , unsized_ty. repr( bcx. tcx( ) ) ) ;
354
365
// Closures for extracting and manipulating the data and payload parts of
355
366
// the fat pointer.
356
367
let base = match k {
@@ -366,7 +377,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
366
377
let info = |bcx, _val| unsized_info ( bcx,
367
378
k,
368
379
expr. id ,
369
- ty :: deref_or_dont ( datum_ty) ,
380
+ datum_ty,
370
381
|t| ty:: mk_rptr ( tcx,
371
382
ty:: ReStatic ,
372
383
ty:: mt {
0 commit comments