Make all moves explicit in libsyntax

This commit is contained in:
Tim Chevalier 2012-09-10 18:28:00 -07:00
parent 6957af770b
commit f8b3eaae82
13 changed files with 42 additions and 39 deletions

View File

@ -181,7 +181,7 @@ mod ct {
let rest = copy next.flags;
let j = next.next;
let curr: ~[flag] = ~[f];
return {flags: vec::append(curr, rest), next: j};
return {flags: vec::append(move curr, rest), next: j};
}
let more = |x, copy s| more_(x, copy s, i, lim);
let f = s[i];
@ -195,7 +195,7 @@ mod ct {
more(flag_sign_always)
} else if f == '#' as u8 {
more(flag_alternate)
} else { {flags: noflags, next: i} };
} else { {flags: move noflags, next: i} };
}
fn parse_count(s: ~str, i: uint, lim: uint)
-> {count: count, next: uint} {

View File

@ -34,7 +34,7 @@ fn unwrap<T>(+m: Mut<T>) -> T {
// Borrowck should prevent us from calling unwrap while the value
// is in use, as that would be a move from a borrowed value.
assert (m.mode as uint) == (ReadOnly as uint);
let Data {value, mode: _} = m;
let Data {value, mode: _} <- m;
return move value;
}

View File

@ -2,15 +2,15 @@ use codemap::span;
use ast::*;
pure fn spanned<T>(lo: uint, hi: uint, +t: T) -> spanned<T> {
respan(mk_sp(lo, hi), t)
respan(mk_sp(lo, hi), move t)
}
pure fn respan<T>(sp: span, +t: T) -> spanned<T> {
{node: t, span: sp}
{node: move t, span: sp}
}
pure fn dummy_spanned<T>(+t: T) -> spanned<T> {
respan(dummy_sp(), t)
respan(dummy_sp(), move t)
}
/* assuming that we're not in macro expansion */

View File

@ -282,7 +282,7 @@ fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] {
// This is sort of stupid here, converting to a vec of mutables and back
let v: ~[mut @ast::meta_item] = vec::to_mut(items);
std::sort::quick_sort(lteq, v);
return vec::from_mut(v);
vec::from_mut(move v)
}
fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) ->

View File

@ -222,14 +222,14 @@ fn mk_ctxt(parse_sess: parse::parse_sess,
self.parse_sess.interner.intern(@st)
}
}
let imp : ctxt_repr = {
let imp: ctxt_repr = {
parse_sess: parse_sess,
cfg: cfg,
mut backtrace: None,
mut mod_path: ~[],
mut trace_mac: false
};
return imp as ext_ctxt
move (imp as ext_ctxt)
}
fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str {

View File

@ -39,7 +39,7 @@ fn analyze(proto: protocol, _cx: ext_ctxt) {
for state.reachable |s| {
bv.set(s.id, true);
}
bv
move bv
};
let mut i = 0;

View File

@ -188,7 +188,7 @@ impl protocol {
span: self.span,
dir: dir,
ty_params: ty_params,
messages: messages,
messages: move messages,
proto: self
});

View File

@ -143,7 +143,7 @@ fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
return Some(leaf(m));
}
p_t_s_rec(cx, match_expr(e), trivial_selector, res);
return res;
move res
}

View File

@ -255,8 +255,8 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
sp.hi)));
}
new_pos.idx += 1u;
vec::push(cur_eis, new_pos);
new_pos.idx += 1;
vec::push(cur_eis, move new_pos);
}
// can we go around again?
@ -266,18 +266,18 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
Some(t) if idx == len => { // we need a separator
if tok == t { //pass the separator
let ei_t <- ei;
ei_t.idx += 1u;
vec::push(next_eis, ei_t);
ei_t.idx += 1;
vec::push(next_eis, move ei_t);
}
}
_ => { // we don't need a separator
let ei_t <- ei;
ei_t.idx = 0u;
vec::push(cur_eis, ei_t);
ei_t.idx = 0;
vec::push(cur_eis, move ei_t);
}
}
} else {
vec::push(eof_eis, ei);
vec::push(eof_eis, move ei);
}
} else {
match copy ei.elts[idx].node {
@ -292,7 +292,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
new_ei.matches[idx].push(@matched_seq(~[], sp));
}
vec::push(cur_eis, new_ei);
vec::push(cur_eis, move new_ei);
}
let matches = vec::map(ei.matches, // fresh, same size:
@ -300,16 +300,19 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
let ei_t <- ei;
vec::push(cur_eis, ~{
elts: matchers, sep: sep, mut idx: 0u,
mut up: matcher_pos_up(Some(ei_t)),
matches: matches,
mut up: matcher_pos_up(Some(move ei_t)),
matches: move matches,
match_lo: match_idx_lo, match_hi: match_idx_hi,
sp_lo: sp.lo
});
}
match_nonterminal(_,_,_) => { vec::push(bb_eis, ei) }
match_nonterminal(_,_,_) => { vec::push(bb_eis, move ei) }
match_tok(t) => {
let ei_t <- ei;
if t == tok { ei_t.idx += 1u; vec::push(next_eis, ei_t)}
if t == tok {
ei_t.idx += 1;
vec::push(next_eis, move ei_t);
}
}
}
}
@ -362,7 +365,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
}
_ => fail
}
vec::push(cur_eis,ei);
vec::push(cur_eis, move ei);
/* this would fail if zero-length tokens existed */
while rdr.peek().sp.lo < rust_parser.span.lo {

View File

@ -157,7 +157,7 @@ fn parse_from_source_str<T>(f: fn (p: parser) -> T,
p.abort_if_errors();
sess.chpos = rdr.chpos;
sess.byte_pos = sess.byte_pos + rdr.pos;
return r;
move r
}
fn next_node_id(sess: parse_sess) -> node_id {
@ -184,7 +184,7 @@ fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
+name: ~str, +ss: codemap::file_substr,
source: @~str) -> parser {
let (p, _) = new_parser_etc_from_source_str(sess, cfg, name, ss, source);
return p;
move p
}
@ -208,7 +208,7 @@ fn new_parser_etc_from_file(sess: parse_sess, cfg: ast::crate_cfg,
fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: &Path,
ftype: parser::file_type) -> parser {
let (p, _) = new_parser_etc_from_file(sess, cfg, path, ftype);
return p;
move p
}
fn new_parser_from_tt(sess: parse_sess, cfg: ast::crate_cfg,

View File

@ -3578,8 +3578,8 @@ impl parser {
}
{attrs_remaining: attrs,
view_items: vec::from_mut(dvec::unwrap(view_items)),
items: vec::from_mut(dvec::unwrap(items))}
view_items: vec::from_mut(dvec::unwrap(move view_items)),
items: vec::from_mut(dvec::unwrap(move items))}
}
// Parses a source module as a crate

View File

@ -124,7 +124,7 @@ const size_infinity: int = 0xffff;
fn mk_printer(out: io::Writer, linewidth: uint) -> printer {
// Yes 3, it makes the ring buffers big enough to never
// fall behind.
let n: uint = 3u * linewidth;
let n: uint = 3 * linewidth;
debug!("mk_printer %u", linewidth);
let token: ~[mut token] = vec::to_mut(vec::from_elem(n, EOF));
let size: ~[mut int] = vec::to_mut(vec::from_elem(n, 0));
@ -133,16 +133,16 @@ fn mk_printer(out: io::Writer, linewidth: uint) -> printer {
buf_len: n,
mut margin: linewidth as int,
mut space: linewidth as int,
mut left: 0u,
mut right: 0u,
token: token,
size: size,
mut left: 0,
mut right: 0,
token: move token,
size: move size,
mut left_total: 0,
mut right_total: 0,
mut scan_stack: scan_stack,
mut scan_stack: move scan_stack,
mut scan_stack_empty: true,
mut top: 0u,
mut bottom: 0u,
mut top: 0,
mut bottom: 0,
print_stack: DVec(),
mut pending_indentation: 0,
mut token_tree_last_was_ident: false})

View File

@ -16,7 +16,7 @@ fn mk<T:Eq IterBytes Hash Const Copy>() -> interner<T> {
let m = map::HashMap::<T, uint>();
let hi: hash_interner<T> =
{map: m, vect: DVec()};
return hi as interner::<T>;
move (hi as interner::<T>)
}
fn mk_prefill<T:Eq IterBytes Hash Const Copy>(init: ~[T]) -> interner<T> {