Skip to content

Commit cf3eb18

Browse files
committed
---
yaml --- r: 151229 b: refs/heads/try2 c: e93cb04 h: refs/heads/master i: 151227: f1e4ed8 v: v3
1 parent e59eba6 commit cf3eb18

File tree

2 files changed

+66
-63
lines changed

2 files changed

+66
-63
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7852625b8671211125564cba69d982dd4ee5db24
8+
refs/heads/try2: e93cb04c4b011088d3b13a17bdf4cb865730dd38
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,71 +2564,74 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
25642564
let tcx = fcx.ccx.tcx;
25652565
let id = expr.id;
25662566
match expr.node {
2567-
ast::ExprVstore(ev, vst) => {
2568-
let typ = match ev.node {
2569-
ast::ExprVec(ref args) => {
2570-
let mutability = match vst {
2571-
ast::ExprVstoreMutSlice => ast::MutMutable,
2572-
_ => ast::MutImmutable,
2573-
};
2574-
let mut any_error = false;
2575-
let mut any_bot = false;
2576-
let t: ty::t = fcx.infcx().next_ty_var();
2577-
for e in args.iter() {
2578-
check_expr_has_type(fcx, *e, t);
2579-
let arg_t = fcx.expr_ty(*e);
2580-
if ty::type_is_error(arg_t) {
2581-
any_error = true;
2567+
ast::ExprVstore(ev, vst) => {
2568+
let typ = match ev.node {
2569+
ast::ExprVec(ref args) => {
2570+
let mutability = match vst {
2571+
ast::ExprVstoreMutSlice => ast::MutMutable,
2572+
_ => ast::MutImmutable,
2573+
};
2574+
let mut any_error = false;
2575+
let mut any_bot = false;
2576+
let t: ty::t = fcx.infcx().next_ty_var();
2577+
for e in args.iter() {
2578+
check_expr_has_type(fcx, *e, t);
2579+
let arg_t = fcx.expr_ty(*e);
2580+
if ty::type_is_error(arg_t) {
2581+
any_error = true;
2582+
}
2583+
else if ty::type_is_bot(arg_t) {
2584+
any_bot = true;
2585+
}
2586+
}
2587+
if any_error {
2588+
ty::mk_err()
2589+
} else if any_bot {
2590+
ty::mk_bot()
2591+
} else {
2592+
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2593+
ty::mt{ ty: ty::mk_vec(tcx,
2594+
ty::mt {ty: t, mutbl: mutability},
2595+
None),
2596+
mutbl: mutability })
2597+
}
25822598
}
2583-
else if ty::type_is_bot(arg_t) {
2584-
any_bot = true;
2599+
ast::ExprRepeat(element, count_expr) => {
2600+
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
2601+
let _ = ty::eval_repeat_count(fcx, count_expr);
2602+
let mutability = match vst {
2603+
ast::ExprVstoreMutSlice => ast::MutMutable,
2604+
_ => ast::MutImmutable,
2605+
};
2606+
let t = fcx.infcx().next_ty_var();
2607+
check_expr_has_type(fcx, element, t);
2608+
let arg_t = fcx.expr_ty(element);
2609+
if ty::type_is_error(arg_t) {
2610+
ty::mk_err()
2611+
} else if ty::type_is_bot(arg_t) {
2612+
ty::mk_bot()
2613+
} else {
2614+
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2615+
ty::mt{ ty: ty::mk_vec(tcx,
2616+
ty::mt {ty: t, mutbl: mutability},
2617+
None),
2618+
mutbl: mutability})
2619+
}
25852620
}
2586-
}
2587-
if any_error {
2588-
ty::mk_err()
2589-
} else if any_bot {
2590-
ty::mk_bot()
2591-
} else {
2592-
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2593-
ty::mt{ ty: ty::mk_vec(tcx,
2594-
ty::mt {ty: t, mutbl: mutability},
2595-
None),
2596-
mutbl: mutability })
2597-
}
2598-
}
2599-
ast::ExprRepeat(element, count_expr) => {
2600-
check_expr_with_hint(fcx, count_expr, ty::mk_uint());
2601-
let _ = ty::eval_repeat_count(fcx, count_expr);
2602-
let mutability = match vst {
2603-
ast::ExprVstoreMutSlice => ast::MutMutable,
2604-
_ => ast::MutImmutable,
2621+
ast::ExprLit(_) => {
2622+
let error = if vst == ast::ExprVstoreSlice {
2623+
"`&\"string\"` has been removed; use `\"string\"` instead"
2624+
} else {
2625+
"`~\"string\"` has been removed; use `\"string\".to_owned()` instead"
2626+
};
2627+
tcx.sess.span_err(expr.span, error);
2628+
ty::mk_err()
2629+
}
2630+
_ => tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence"),
26052631
};
2606-
let t = fcx.infcx().next_ty_var();
2607-
check_expr_has_type(fcx, element, t);
2608-
let arg_t = fcx.expr_ty(element);
2609-
if ty::type_is_error(arg_t) {
2610-
ty::mk_err()
2611-
} else if ty::type_is_bot(arg_t) {
2612-
ty::mk_bot()
2613-
} else {
2614-
ast_expr_vstore_to_ty(fcx, ev, vst, ||
2615-
ty::mt{ ty: ty::mk_vec(tcx,
2616-
ty::mt {ty: t, mutbl: mutability},
2617-
None),
2618-
mutbl: mutability})
2619-
}
2620-
}
2621-
ast::ExprLit(_) => {
2622-
tcx.sess.span_err(expr.span,
2623-
"`~\"string\"` has been removed; use `\"string\".to_owned()` \
2624-
instead");
2625-
ty::mk_err()
2626-
}
2627-
_ => tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence"),
2628-
};
2629-
fcx.write_ty(ev.id, typ);
2630-
fcx.write_ty(id, typ);
2631-
}
2632+
fcx.write_ty(ev.id, typ);
2633+
fcx.write_ty(id, typ);
2634+
}
26322635

26332636
ast::ExprBox(place, subexpr) => {
26342637
check_expr(fcx, place);

0 commit comments

Comments
 (0)