Skip to content

Commit ae65af1

Browse files
committed
---
yaml --- r: 11847 b: refs/heads/master c: e702d20 h: refs/heads/master i: 11845: f7f55a9 11843: 2325ec8 11839: e810458 v: v3
1 parent 52ee598 commit ae65af1

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6b35875dca67e5dd1e8f986c8528ffbf973fdcbb
2+
refs/heads/master: e702d2019131a51630ee5f46ccff4a3bd31e178a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/mk/target.mk

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
# runtime rather than the runtime from the working directory.
1010
USE_SNAPSHOT_RUNTIME=0
1111

12+
# Do not use --enforce-mut-vars in stage0, for now, as the snapshot
13+
# has an older version of the check.
14+
ENFORCE_MUT_VARS_0=
15+
ENFORCE_MUT_VARS_1=--enforce-mut-vars
16+
ENFORCE_MUT_VARS_2=--enforce-mut-vars
17+
ENFORCE_MUT_VARS_3=--enforce-mut-vars
18+
1219
define TARGET_STAGE_N
1320

1421
$$(TLIB$(1)_T_$(2)_H_$(3))/intrinsics.ll: \
@@ -38,7 +45,8 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
3845
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
3946
$$(TSREQ$(1)_T_$(2)_H_$(3))
4047
@$$(call E, compile_and_link: $$@)
41-
$$(STAGE$(1)_T_$(2)_H_$(3)) --enforce-mut-vars -o $$@ $$< && touch $$@
48+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(ENFORCE_MUT_VARS_$(1)) \
49+
-o $$@ $$< && touch $$@
4250

4351
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM): \
4452
rustllvm/$(2)/$$(CFG_RUSTLLVM)

trunk/src/libstd/uv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn async_init (
339339
lp: uv_loop,
340340
async_cb: fn~(uv_handle),
341341
after_cb: fn~(uv_handle)) {
342-
let mut msg = msg_async_init(async_cb, after_cb);
342+
let msg = msg_async_init(async_cb, after_cb);
343343
let loop_chan = get_loop_chan_from_uv_loop(lp);
344344
comm::send(loop_chan, msg);
345345
}
@@ -363,7 +363,7 @@ fn close(h: uv_handle, cb: fn~()) {
363363
}
364364

365365
fn timer_init(lp: uv_loop, after_cb: fn~(uv_handle)) {
366-
let mut msg = msg_timer_init(after_cb);
366+
let msg = msg_timer_init(after_cb);
367367
let loop_chan = get_loop_chan_from_uv_loop(lp);
368368
comm::send(loop_chan, msg);
369369
}
@@ -372,7 +372,7 @@ fn timer_start(the_timer: uv_handle, timeout: u32, repeat:u32,
372372
timer_cb: fn~(uv_handle)) {
373373
alt the_timer {
374374
uv_timer(id, lp) {
375-
let mut msg = msg_timer_start(id, timeout, repeat, timer_cb);
375+
let msg = msg_timer_start(id, timeout, repeat, timer_cb);
376376
let loop_chan = get_loop_chan_from_uv_loop(lp);
377377
comm::send(loop_chan, msg);
378378
}
@@ -387,7 +387,7 @@ fn timer_stop(the_timer: uv_handle, after_cb: fn~(uv_handle)) {
387387
alt the_timer {
388388
uv_timer(id, lp) {
389389
let loop_chan = get_loop_chan_from_uv_loop(lp);
390-
let mut msg = msg_timer_stop(id, after_cb);
390+
let msg = msg_timer_stop(id, after_cb);
391391
comm::send(loop_chan, msg);
392392
}
393393
_ {

trunk/src/rustc/middle/mutbl.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn visit_expr(cx: @ctx, ex: @expr, &&e: (), v: visit::vt<()>) {
176176
expr_fn(_, _, _, cap) {
177177
for moved in cap.moves {
178178
let def = cx.tcx.def_map.get(moved.id);
179-
alt is_immutable_def(cx, def) {
179+
alt is_illegal_to_modify_def(cx, def, msg_move_out) {
180180
some(name) { mk_err(cx, moved.span, msg_move_out, moved.name); }
181181
_ { }
182182
}
@@ -192,7 +192,7 @@ fn check_lval(cx: @ctx, dest: @expr, msg: msg) {
192192
alt dest.node {
193193
expr_path(p) {
194194
let def = cx.tcx.def_map.get(dest.id);
195-
alt is_immutable_def(cx, def) {
195+
alt is_illegal_to_modify_def(cx, def, msg) {
196196
some(name) { mk_err(cx, dest.span, msg, name); }
197197
_ { }
198198
}
@@ -278,7 +278,9 @@ fn check_bind(cx: @ctx, f: @expr, args: [option<@expr>]) {
278278
}
279279
}
280280

281-
fn is_immutable_def(cx: @ctx, def: def) -> option<str> {
281+
// returns some if the def cannot be modified. the kind of modification is
282+
// indicated by `msg`.
283+
fn is_illegal_to_modify_def(cx: @ctx, def: def, msg: msg) -> option<str> {
282284
alt def {
283285
def_fn(_, _) | def_mod(_) | def_native_mod(_) | def_const(_) |
284286
def_use(_) {
@@ -295,15 +297,20 @@ fn is_immutable_def(cx: @ctx, def: def) -> option<str> {
295297
let ty = ty::node_id_to_type(cx.tcx, node_id);
296298
let proto = ty::ty_fn_proto(ty);
297299
ret alt proto {
298-
proto_any | proto_block { is_immutable_def(cx, *inner) }
299-
_ { some("upvar") }
300+
proto_any | proto_block {
301+
is_illegal_to_modify_def(cx, *inner, msg)
302+
}
303+
proto_bare | proto_uniq | proto_box {
304+
some("upvar")
305+
}
300306
};
301307
}
302308

303309
// Note: we should *always* allow all local variables to be assigned
304310
// here and then guarantee in the typestate pass that immutable local
305311
// variables are assigned at most once. But this requires a new kind of
306312
// propagation (def. not assigned), so I didn't do that.
313+
def_local(_, false) if msg == msg_move_out { none }
307314
def_local(_, false) if cx.tcx.sess.opts.enforce_mut_vars {
308315
some("immutable local variable")
309316
}

0 commit comments

Comments
 (0)