@@ -2448,19 +2448,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result {
2448
2448
}
2449
2449
ast:: def_self ( sid) {
2450
2450
let slf = alt copy cx. fcx . llself {
2451
- some ( s) {
2452
- alt option:: map ( ty:: ty_to_def_id ( s. t ) ) { |did|
2453
- ty:: ty_dtor ( cx. tcx ( ) , did) } {
2454
- some ( some ( _) ) {
2455
- /* self is a class with a dtor, which means we
2456
- have to select out the object itself
2457
- (If any other code does the same thing, that's
2458
- a bug */
2459
- GEPi ( cx, cast_self ( cx, s) , [ 0 u, 1 u] )
2460
- }
2461
- _ { cast_self( cx, s) }
2462
- }
2463
- }
2451
+ some ( s) { cast_self ( cx, s) }
2464
2452
none { cx. sess ( ) . bug ( "trans_local_var: reference to self \
2465
2453
out of context") ; }
2466
2454
} ;
@@ -2535,17 +2523,29 @@ fn trans_rec_field(bcx: block, base: @ast::expr,
2535
2523
2536
2524
fn trans_rec_field_inner ( bcx : block , val : ValueRef , ty : ty:: t ,
2537
2525
field : ast:: ident , sp : span ) -> lval_result {
2526
+ let mut deref = false ;
2538
2527
let fields = alt ty:: get ( ty) . struct {
2539
2528
ty:: ty_rec ( fs) { fs }
2540
2529
ty:: ty_class ( did, substs) {
2530
+ if option:: is_some ( ty:: ty_dtor ( bcx. tcx ( ) , did) ) {
2531
+ deref = true ;
2532
+ }
2541
2533
ty:: class_items_as_fields ( bcx. tcx ( ) , did, substs)
2542
2534
}
2543
2535
// Constraint?
2544
2536
_ { bcx. tcx ( ) . sess . span_bug ( sp, "trans_rec_field:\
2545
2537
base expr has non-record type") ; }
2546
2538
} ;
2547
2539
let ix = field_idx_strict ( bcx. tcx ( ) , sp, field, fields) ;
2548
- let val = GEPi ( bcx, val, [ 0 u, ix] ) ;
2540
+
2541
+ /* self is a class with a dtor, which means we
2542
+ have to select out the object itself
2543
+ (If any other code does the same thing, that's
2544
+ a bug */
2545
+ let val = if deref {
2546
+ GEPi ( bcx, GEPi ( bcx, val, [ 0 u, 1 u] ) , [ 0 u, ix] )
2547
+ }
2548
+ else { GEPi ( bcx, val, [ 0 u, ix] ) } ;
2549
2549
2550
2550
ret { bcx : bcx, val : val, kind : owned} ;
2551
2551
}
0 commit comments