@@ -467,10 +467,6 @@ fn trans_datum_unadjusted<'a>(bcx: &'a Block<'a>,
467467
468468 trans_binary ( bcx, expr, op, lhs, rhs)
469469 }
470- ast:: ExprUnary ( ast:: UnDeref , base) => {
471- let basedatum = unpack_datum ! ( bcx, trans( bcx, base) ) ;
472- deref_once ( bcx, expr, basedatum, 0 )
473- }
474470 ast:: ExprUnary ( op, x) => {
475471 trans_unary_datum ( bcx, expr, op, x)
476472 }
@@ -782,12 +778,7 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
782778 closure:: trans_expr_fn ( bcx, sigil, decl, body, expr. id , dest)
783779 }
784780 ast:: ExprCall ( f, ref args) => {
785- callee:: trans_call ( bcx,
786- expr,
787- f,
788- callee:: ArgExprs ( args. as_slice ( ) ) ,
789- expr. id ,
790- dest)
781+ callee:: trans_call ( bcx, expr, f, callee:: ArgExprs ( args. as_slice ( ) ) , dest)
791782 }
792783 ast:: ExprMethodCall ( _, _, ref args) => {
793784 callee:: trans_method_call ( bcx,
@@ -798,18 +789,15 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
798789 }
799790 ast:: ExprBinary ( _, lhs, rhs) => {
800791 // if not overloaded, would be RvalueDatumExpr
801- trans_overloaded_op ( bcx, expr, lhs,
802- Some ( & * rhs) , expr_ty ( bcx, expr) , dest)
792+ trans_overloaded_op ( bcx, expr, lhs, Some ( & * rhs) , Some ( dest) ) . bcx
803793 }
804794 ast:: ExprUnary ( _, subexpr) => {
805795 // if not overloaded, would be RvalueDatumExpr
806- trans_overloaded_op ( bcx, expr, subexpr,
807- None , expr_ty ( bcx, expr) , dest)
796+ trans_overloaded_op ( bcx, expr, subexpr, None , Some ( dest) ) . bcx
808797 }
809798 ast:: ExprIndex ( base, idx) => {
810799 // if not overloaded, would be RvalueDatumExpr
811- trans_overloaded_op ( bcx, expr, base,
812- Some ( & * idx) , expr_ty ( bcx, expr) , dest)
800+ trans_overloaded_op ( bcx, expr, base, Some ( & * idx) , Some ( dest) ) . bcx
813801 }
814802 ast:: ExprCast ( val, _) => {
815803 // DPS output mode means this is a trait cast:
@@ -1185,17 +1173,14 @@ fn trans_unary_datum<'a>(
11851173 let mut bcx = bcx;
11861174 let _icx = push_ctxt ( "trans_unary_datum" ) ;
11871175
1188- // if deref, would be LvalueExpr
1189- assert ! ( op != ast:: UnDeref ) ;
1190-
1191- // if overloaded, would be RvalueDpsExpr
1192- {
1176+ let overloaded = {
11931177 let method_map = bcx. ccx ( ) . maps . method_map . borrow ( ) ;
1194- assert ! ( !method_map. get( ) . contains_key( & un_expr. id) ) ;
1195- }
1178+ method_map. get ( ) . contains_key ( & un_expr. id )
1179+ } ;
1180+ // if overloaded, would be RvalueDpsExpr
1181+ assert ! ( !overloaded || op == ast:: UnDeref ) ;
11961182
11971183 let un_ty = expr_ty ( bcx, un_expr) ;
1198- let sub_ty = expr_ty ( bcx, sub_expr) ;
11991184
12001185 return match op {
12011186 ast:: UnNot => {
@@ -1226,15 +1211,19 @@ fn trans_unary_datum<'a>(
12261211 immediate_rvalue_bcx ( bcx, llneg, un_ty) . to_expr_datumblock ( )
12271212 }
12281213 ast:: UnBox => {
1229- trans_boxed_expr ( bcx, un_ty, sub_expr, sub_ty , heap_managed)
1214+ trans_boxed_expr ( bcx, un_ty, sub_expr, expr_ty ( bcx , sub_expr ) , heap_managed)
12301215 }
12311216 ast:: UnUniq => {
1232- trans_boxed_expr ( bcx, un_ty, sub_expr, sub_ty , heap_exchange)
1217+ trans_boxed_expr ( bcx, un_ty, sub_expr, expr_ty ( bcx , sub_expr ) , heap_exchange)
12331218 }
12341219 ast:: UnDeref => {
1235- bcx. sess ( ) . bug ( "deref expressions should have been \
1236- translated using trans_lvalue(), not \
1237- trans_unary_datum()")
1220+ if overloaded {
1221+ let r = trans_overloaded_op ( bcx, un_expr, sub_expr, None , None ) ;
1222+ DatumBlock ( r. bcx , Datum ( r. val , un_ty, LvalueExpr ) )
1223+ } else {
1224+ let datum = unpack_datum ! ( bcx, trans( bcx, sub_expr) ) ;
1225+ deref_once ( bcx, un_expr, datum, 0 )
1226+ }
12381227 }
12391228 } ;
12401229}
@@ -1506,22 +1495,20 @@ fn trans_overloaded_op<'a, 'b>(
15061495 expr : & ast:: Expr ,
15071496 rcvr : & ' b ast:: Expr ,
15081497 arg : Option < & ' b ast:: Expr > ,
1509- ret_ty : ty:: t ,
1510- dest : Dest )
1511- -> & ' a Block < ' a > {
1498+ dest : Option < Dest > )
1499+ -> Result < ' a > {
15121500 let method_ty = bcx. ccx ( ) . maps . method_map . borrow ( ) . get ( ) . get ( & expr. id ) . ty ;
15131501 callee:: trans_call_inner ( bcx,
15141502 Some ( expr_info ( expr) ) ,
15151503 monomorphize_type ( bcx, method_ty) ,
1516- ret_ty,
15171504 |bcx, arg_cleanup_scope| {
15181505 meth:: trans_method_callee ( bcx,
15191506 expr. id ,
15201507 rcvr,
15211508 arg_cleanup_scope)
15221509 } ,
15231510 callee:: ArgAutorefSecond ( rcvr, arg) ,
1524- Some ( dest) ) . bcx
1511+ dest)
15251512}
15261513
15271514fn int_cast ( bcx : & Block ,
0 commit comments