Skip to content

Commit eeda0f4

Browse files
committed
Don't unbox types in ty::is_binopable, do it on typeck side instead
Closes issue #631 Removes ty::strip_boxes entirely, since unboxing is now more complicated anyway.
1 parent 381505f commit eeda0f4

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/comp/middle/ty.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -2897,20 +2897,6 @@ fn ret_ty_of_fn(ctxt cx, ast::node_id id) -> t {
28972897
ret ret_ty_of_fn_ty(cx, node_id_to_type(cx, id));
28982898
}
28992899

2900-
2901-
// NB: This function requires that the given type has no variables. So, inside
2902-
// typeck, you should use typeck::do_autoderef() instead.
2903-
fn strip_boxes(&ctxt cx, &ty::t t) -> ty::t {
2904-
auto t1 = t;
2905-
while (true) {
2906-
alt (struct(cx, t1)) {
2907-
case (ty::ty_box(?inner)) { t1 = inner.ty; }
2908-
case (_) { ret t1; }
2909-
}
2910-
}
2911-
fail;
2912-
}
2913-
29142900
fn is_binopable(&ctxt cx, t ty, ast::binop op) -> bool {
29152901

29162902
const int tycat_other = 0;
@@ -2955,7 +2941,7 @@ fn is_binopable(&ctxt cx, t ty, ast::binop op) -> bool {
29552941
}
29562942

29572943
fn tycat(&ctxt cx, t ty) -> int {
2958-
alt (struct(cx, strip_boxes(cx, ty))) {
2944+
alt (struct(cx, ty)) {
29592945
case (ty_bool) { tycat_bool }
29602946
case (ty_int) { tycat_int }
29612947
case (ty_uint) { tycat_int }

src/comp/middle/typeck.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,8 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
16201620
auto rhs_t = expr_ty(fcx.ccx.tcx, rhs);
16211621

16221622
demand::autoderef(fcx, rhs.span, lhs_t, rhs_t, AUTODEREF_OK);
1623-
check_binop_type_compat(fcx, expr.span, lhs_t, binop);
1623+
auto deref_t = do_autoderef(fcx, expr.span, lhs_t);
1624+
check_binop_type_compat(fcx, expr.span, deref_t, binop);
16241625

16251626
auto t = alt (binop) {
16261627
case (ast::eq) { ty::mk_bool(fcx.ccx.tcx) }
@@ -1629,7 +1630,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
16291630
case (ast::ne) { ty::mk_bool(fcx.ccx.tcx) }
16301631
case (ast::ge) { ty::mk_bool(fcx.ccx.tcx) }
16311632
case (ast::gt) { ty::mk_bool(fcx.ccx.tcx) }
1632-
case (_) { do_autoderef(fcx, expr.span, lhs_t) }
1633+
case (_) { deref_t }
16331634
};
16341635
write::ty_only_fixup(fcx, id, t);
16351636
}

0 commit comments

Comments
 (0)