@@ -2591,15 +2591,9 @@ fn trans_unary(@block_ctxt cx, ast.unop op,
2591
2591
ret res( sub. bcx, box) ;
2592
2592
}
2593
2593
case ( ast. deref) {
2594
- auto val = sub. bcx. build. GEP ( sub. val,
2595
- vec( C_int ( 0 ) ,
2596
- C_int ( abi. box_rc_field_body) ) ) ;
2597
- auto e_ty = node_ann_type( sub. bcx. fcx. ccx, a) ;
2598
- if ( ty. type_is_scalar( e_ty) ||
2599
- ty. type_is_nil( e_ty) ) {
2600
- val = sub. bcx. build. Load ( val) ;
2601
- }
2602
- ret res( sub. bcx, val) ;
2594
+ log "deref expressions should have been translated using " +
2595
+ "trans_lval( ) , not trans_unary( ) ";
2596
+ fail;
2603
2597
}
2604
2598
}
2605
2599
fail;
@@ -3908,6 +3902,15 @@ fn trans_lval(@block_ctxt cx, @ast.expr e) -> lval_result {
3908
3902
case ( ast. expr_index( ?base, ?idx, ?ann) ) {
3909
3903
ret trans_index( cx, e. span, base, idx, ann) ;
3910
3904
}
3905
+ case ( ast. expr_unary( ?unop, ?base, ?ann) ) {
3906
+ check ( unop == ast. deref) ;
3907
+
3908
+ auto sub = trans_expr( cx, base) ;
3909
+ auto val = sub. bcx. build. GEP ( sub. val,
3910
+ vec( C_int ( 0 ) ,
3911
+ C_int ( abi. box_rc_field_body) ) ) ;
3912
+ ret lval_mem( sub. bcx, val) ;
3913
+ }
3911
3914
3912
3915
// Kind of bizarre to pass an *entire* self-call here...but let's try
3913
3916
// it
@@ -3925,7 +3928,9 @@ fn trans_lval(@block_ctxt cx, @ast.expr e) -> lval_result {
3925
3928
3926
3929
}
3927
3930
}
3928
- case ( _) { cx. fcx. ccx. sess. unimpl( "expr variant in trans_lval") ; }
3931
+ case ( _) {
3932
+ cx. fcx. ccx. sess. span_unimpl( e. span, "expr variant in trans_lval") ;
3933
+ }
3929
3934
}
3930
3935
fail;
3931
3936
}
@@ -4685,7 +4690,9 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
4685
4690
}
4686
4691
4687
4692
case ( ast. expr_unary( ?op, ?x, ?ann) ) {
4688
- ret trans_unary( cx, op, x, ann) ;
4693
+ if ( op != ast. deref) {
4694
+ ret trans_unary( cx, op, x, ann) ;
4695
+ }
4689
4696
}
4690
4697
4691
4698
case ( ast. expr_binary( ?op, ?x, ?y, _) ) {
@@ -4832,18 +4839,17 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
4832
4839
ret trans_recv( cx, lhs, rhs, ann) ;
4833
4840
}
4834
4841
4835
- // lval cases fall through to trans_lval and then
4836
- // possibly load the result (if it's non-structural).
4837
-
4838
4842
case ( _) {
4839
- auto t = ty. expr_ty( e) ;
4840
- auto sub = trans_lval( cx, e) ;
4841
- ret res( sub. res. bcx,
4842
- load_scalar_or_boxed( sub. res. bcx, sub. res. val, t) ) ;
4843
+ // The expression is an lvalue. Fall through.
4843
4844
}
4844
4845
}
4845
- cx. fcx. ccx. sess. unimpl( "expr variant in trans_expr") ;
4846
- fail;
4846
+
4847
+ // lval cases fall through to trans_lval and then
4848
+ // possibly load the result (if it's non-structural).
4849
+
4850
+ auto t = ty. expr_ty( e) ;
4851
+ auto sub = trans_lval( cx, e) ;
4852
+ ret res( sub. res. bcx, load_scalar_or_boxed( sub. res. bcx, sub. res. val, t) ) ;
4847
4853
}
4848
4854
4849
4855
// We pass structural values around the compiler "by pointer" and
0 commit comments