Skip to content

Commit f682b99

Browse files
committed
generate correct constraints for assignments
1 parent 76d0a13 commit f682b99

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/rustc/middle/typeck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,8 +2414,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
24142414
// A generic function for checking assignment expressions
24152415
fn check_assignment(fcx: @fn_ctxt, _sp: span, lhs: @ast::expr,
24162416
rhs: @ast::expr, id: ast::node_id) -> bool {
2417-
let t = next_ty_var(fcx);
2418-
let bot = check_expr_with(fcx, lhs, t) | check_expr_with(fcx, rhs, t);
2417+
let mut bot = check_expr(fcx, lhs);
2418+
bot |= check_expr_with(fcx, rhs, expr_ty(fcx.ccx.tcx, lhs));
24192419
write_ty(fcx.ccx.tcx, id, ty::mk_nil(fcx.ccx.tcx));
24202420
ret bot;
24212421
}

src/test/compile-fail/assign-super.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
let mut x: [mut int] = [mut 3];
3+
let y: [int] = [3];
4+
x = y; //! ERROR values differ in mutability
5+
}

0 commit comments

Comments
 (0)