Skip to content

Commit 86e0255

Browse files
committed
Make moves in arguments explicit in libsyntax and rustc
1 parent 320331f commit 86e0255

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

src/libsyntax/ext/auto_serialize.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -365,19 +365,19 @@ fn ser_variant(cx: ext_ctxt,
365365
let arg_blk =
366366
cx.blk(
367367
span,
368-
ser_ty(cx, tps, tys[i], cx.clone(s), v));
368+
ser_ty(cx, tps, tys[i], cx.clone(s), move v));
369369
cx.stmt(argfn(cx.clone(s), i, arg_blk))
370370
};
371371

372372
let body_blk = cx.blk(span, stmts);
373-
let body = cx.blk(span, ~[cx.stmt(bodyfn(s, body_blk))]);
373+
let body = cx.blk(span, ~[cx.stmt(bodyfn(move s, body_blk))]);
374374

375375
{pats: ~[pat], guard: None, body: body}
376376
}
377377

378378
fn ser_lambda(cx: ext_ctxt, tps: ser_tps_map, ty: @ast::ty,
379379
-s: @ast::expr, -v: @ast::expr) -> @ast::expr {
380-
cx.lambda(cx.blk(ty.span, ser_ty(cx, tps, ty, s, v)))
380+
cx.lambda(cx.blk(ty.span, ser_ty(cx, tps, ty, move s, move v)))
381381
}
382382

383383
fn is_vec_or_str(ty: @ast::ty) -> bool {
@@ -415,7 +415,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
415415

416416
// For unique evecs/estrs, just pass through to underlying vec or str
417417
ast::ty_uniq(mt) if is_vec_or_str(mt.ty) => {
418-
ser_ty(cx, tps, mt.ty, s, v)
418+
ser_ty(cx, tps, mt.ty, move s, move v)
419419
}
420420

421421
ast::ty_uniq(mt) => {
@@ -439,7 +439,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
439439
let f = cx.lit_str(fld.span, cx.parse_sess().interner.get(
440440
fld.node.ident));
441441
let i = cx.lit_uint(fld.span, fidx);
442-
let l = ser_lambda(cx, tps, fld.node.mt.ty, cx.clone(s), vf);
442+
let l = ser_lambda(cx, tps, fld.node.mt.ty, cx.clone(s), move vf);
443443
#ast[stmt]{$(s).emit_rec_field($(f), $(i), $(l));}
444444
};
445445
let fld_lambda = cx.lambda(cx.blk(ty.span, fld_stmts));
@@ -463,7 +463,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
463463
let arms = ~[
464464
ser_variant(
465465

466-
cx, tps, tys, ty.span, s,
466+
cx, tps, tys, ty.span, move s,
467467

468468
// Generate pattern (v1, v2, v3)
469469
|pats| ast::pat_tup(pats),
@@ -482,20 +482,19 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
482482
#ast{ $(s).emit_tup_elt($(idx), $(body)) }
483483
})
484484
];
485-
~[cx.alt_stmt(arms, ty.span, v)]
485+
~[cx.alt_stmt(arms, ty.span, move v)]
486486
}
487487

488488
ast::ty_path(path, _) => {
489-
if vec::len(path.idents) == 1u &&
490-
vec::is_empty(path.types) {
489+
if path.idents.len() == 1 && path.types.is_empty() {
491490
let ident = path.idents[0];
492491

493492
match tps.find(ident) {
494493
Some(f) => f(v),
495-
None => ser_path(cx, tps, path, s, v)
494+
None => ser_path(cx, tps, path, move s, move v)
496495
}
497496
} else {
498-
ser_path(cx, tps, path, s, v)
497+
ser_path(cx, tps, path, move s, move v)
499498
}
500499
}
501500

@@ -634,7 +633,7 @@ fn deser_path(cx: ext_ctxt, tps: deser_tps_map, path: @ast::path,
634633

635634
fn deser_lambda(cx: ext_ctxt, tps: deser_tps_map, ty: @ast::ty,
636635
-d: @ast::expr) -> @ast::expr {
637-
cx.lambda(cx.expr_blk(deser_ty(cx, tps, ty, d)))
636+
cx.lambda(cx.expr_blk(deser_ty(cx, tps, ty, move d)))
638637
}
639638

640639
fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
@@ -658,7 +657,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
658657

659658
// For unique evecs/estrs, just pass through to underlying vec or str
660659
ast::ty_uniq(mt) if is_vec_or_str(mt.ty) => {
661-
deser_ty(cx, tps, mt.ty, d)
660+
deser_ty(cx, tps, mt.ty, move d)
662661
}
663662

664663
ast::ty_uniq(mt) => {
@@ -719,10 +718,10 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
719718

720719
match tps.find(ident) {
721720
Some(f) => f(),
722-
None => deser_path(cx, tps, path, d)
721+
None => deser_path(cx, tps, path, move d)
723722
}
724723
} else {
725-
deser_path(cx, tps, path, d)
724+
deser_path(cx, tps, path, move d)
726725
}
727726
}
728727

@@ -822,8 +821,9 @@ fn ty_fns(cx: ext_ctxt, name: ast::ident,
822821

823822
let span = ty.span;
824823
~[
825-
mk_ser_fn(cx, span, name, tps, |a,b,c,d| ser_ty(a, b, ty, c, d)),
826-
mk_deser_fn(cx, span, name, tps, |a,b,c| deser_ty(a, b, ty, c))
824+
mk_ser_fn(cx, span, name, tps, |a,b,c,d| ser_ty(a, b, ty, move c,
825+
move d)),
826+
mk_deser_fn(cx, span, name, tps, |a,b,c| deser_ty(a, b, ty, move c))
827827
]
828828
}
829829

@@ -881,7 +881,7 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident,
881881
fail ~"struct variants unimplemented for auto serialize"
882882
}
883883
};
884-
let lam = cx.lambda(cx.blk(e_span, ~[cx.alt_stmt(arms, e_span, v)]));
884+
let lam = cx.lambda(cx.blk(e_span, ~[cx.alt_stmt(arms, e_span, move v)]));
885885
let e_name = cx.lit_str(e_span, @cx.str_of(e_name));
886886
~[#ast[stmt]{ $(s).emit_enum($(e_name), $(lam)) }]
887887
}
@@ -954,8 +954,9 @@ fn enum_fns(cx: ext_ctxt, e_name: ast::ident, e_span: span,
954954
-> ~[@ast::item] {
955955
~[
956956
mk_ser_fn(cx, e_span, e_name, tps,
957-
|a,b,c,d| ser_enum(a, b, e_name, e_span, variants, c, d)),
957+
|a,b,c,d| ser_enum(a, b, e_name, e_span, variants, move c,
958+
move d)),
958959
mk_deser_fn(cx, e_span, e_name, tps,
959-
|a,b,c| deser_enum(a, b, e_name, e_span, variants, c))
960+
|a,b,c| deser_enum(a, b, e_name, e_span, variants, move c))
960961
]
961962
}

src/rustc/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ mod jit {
9696
code: ptr,
9797
env: ptr::null()
9898
};
99-
let func: fn(~[~str]) = unsafe::transmute(closure);
99+
let func: fn(~[~str]) = unsafe::transmute(move closure);
100100

101101
func(~[sess.opts.binary]);
102102
}

src/rustc/driver/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
228228
let p = comm::Port();
229229
let ch = comm::Chan(p);
230230
231-
match do task::try {
231+
match do task::try |move f| {
232232
233233
// The 'diagnostics emitter'. Every error, warning, etc. should
234234
// go through this function.

src/rustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ fn new_block(cx: fn_ctxt, parent: Option<block>, +kind: block_kind,
10461046
let llbb: BasicBlockRef = str::as_c_str(cx.ccx.sess.str_of(s), |buf| {
10471047
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
10481048
});
1049-
let bcx = mk_block(llbb, parent, kind, is_lpad, opt_node_info, cx);
1049+
let bcx = mk_block(llbb, parent, move kind, is_lpad, opt_node_info, cx);
10501050
do option::iter(parent) |cx| {
10511051
if cx.unreachable { Unreachable(bcx); }
10521052
};

src/rustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ enum block = @block_;
527527
fn mk_block(llbb: BasicBlockRef, parent: Option<block>, -kind: block_kind,
528528
is_lpad: bool, node_info: Option<node_info>, fcx: fn_ctxt)
529529
-> block {
530-
block(@block_(llbb, parent, kind, is_lpad, node_info, fcx))
530+
block(@block_(llbb, parent, move kind, is_lpad, node_info, fcx))
531531
}
532532

533533
// First two args are retptr, env

src/rustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ enum debug_metadata {
131131

132132
fn cast_safely<T: Copy, U>(val: T) -> U unsafe {
133133
let val2 = val;
134-
return unsafe::transmute(val2);
134+
return unsafe::transmute(move val2);
135135
}
136136

137137
fn md_from_metadata<T>(val: debug_metadata) -> T unsafe {

src/rustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ type t = *t_opaque;
383383
pure fn get(t: t) -> t_box unsafe {
384384
let t2 = unsafe::reinterpret_cast::<t, t_box>(&t);
385385
let t3 = t2;
386-
unsafe::forget(t2);
386+
unsafe::forget(move t2);
387387
t3
388388
}
389389

0 commit comments

Comments
 (0)