1
Fork 0

libsyntax: remove vecs_implicitly_copyable from the syntax extensions

This commit is contained in:
Erick Tryzelaar 2013-02-24 21:27:51 -08:00
parent 5f1652f34f
commit 5271464cc0
17 changed files with 151 additions and 124 deletions

View file

@ -143,8 +143,8 @@ pub fn expand_auto_encode(
cx, cx,
item.span, item.span,
item.ident, item.ident,
*enum_def, copy *enum_def,
*tps copy *tps
); );
~[filter_attrs(*item), ser_impl] ~[filter_attrs(*item), ser_impl]
@ -188,7 +188,7 @@ pub fn expand_auto_decode(
item.span, item.span,
item.ident, item.ident,
struct_def.fields, struct_def.fields,
*tps copy *tps
); );
~[filter_attrs(*item), deser_impl] ~[filter_attrs(*item), deser_impl]
@ -198,8 +198,8 @@ pub fn expand_auto_decode(
cx, cx,
item.span, item.span,
item.ident, item.ident,
*enum_def, copy *enum_def,
*tps copy *tps
); );
~[filter_attrs(*item), deser_impl] ~[filter_attrs(*item), deser_impl]
@ -346,7 +346,7 @@ priv impl ext_ctxt {
fn lambda(+blk: ast::blk) -> @ast::expr { fn lambda(+blk: ast::blk) -> @ast::expr {
let ext_cx = self; let ext_cx = self;
let blk_e = self.expr(blk.span, ast::expr_block(blk)); let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
quote_expr!( || $blk_e ) quote_expr!( || $blk_e )
} }
@ -840,14 +840,14 @@ fn mk_enum_ser_impl(
cx: ext_ctxt, cx: ext_ctxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
enum_def: ast::enum_def, +enum_def: ast::enum_def,
tps: ~[ast::ty_param] tps: ~[ast::ty_param]
) -> @ast::item { ) -> @ast::item {
let body = mk_enum_ser_body( let body = mk_enum_ser_body(
cx, cx,
span, span,
ident, ident,
enum_def.variants copy enum_def.variants
); );
mk_ser_impl(cx, span, ident, tps, body) mk_ser_impl(cx, span, ident, tps, body)
@ -857,7 +857,7 @@ fn mk_enum_deser_impl(
cx: ext_ctxt, cx: ext_ctxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
enum_def: ast::enum_def, +enum_def: ast::enum_def,
tps: ~[ast::ty_param] tps: ~[ast::ty_param]
) -> @ast::item { ) -> @ast::item {
let body = mk_enum_deser_body( let body = mk_enum_deser_body(
@ -960,8 +960,14 @@ fn mk_enum_ser_body(
) -> @ast::expr { ) -> @ast::expr {
let arms = do variants.mapi |v_idx, variant| { let arms = do variants.mapi |v_idx, variant| {
match variant.node.kind { match variant.node.kind {
ast::tuple_variant_kind(args) => ast::tuple_variant_kind(ref args) =>
ser_variant(cx, span, variant.node.name, v_idx, args), ser_variant(
cx,
span,
variant.node.name,
v_idx,
/*bad*/ copy *args
),
ast::struct_variant_kind(*) => ast::struct_variant_kind(*) =>
fail!(~"struct variants unimplemented"), fail!(~"struct variants unimplemented"),
ast::enum_variant_kind(*) => ast::enum_variant_kind(*) =>
@ -1041,7 +1047,7 @@ fn mk_enum_deser_body(
) -> @ast::expr { ) -> @ast::expr {
let mut arms = do variants.mapi |v_idx, variant| { let mut arms = do variants.mapi |v_idx, variant| {
let body = match variant.node.kind { let body = match variant.node.kind {
ast::tuple_variant_kind(args) => { ast::tuple_variant_kind(ref args) => {
if args.is_empty() { if args.is_empty() {
// for a nullary variant v, do "v" // for a nullary variant v, do "v"
ext_cx.expr_path(span, ~[variant.node.name]) ext_cx.expr_path(span, ~[variant.node.name])
@ -1051,7 +1057,7 @@ fn mk_enum_deser_body(
ext_cx, ext_cx,
span, span,
variant.node.name, variant.node.name,
args copy *args
) )
} }
}, },
@ -1074,7 +1080,7 @@ fn mk_enum_deser_body(
} }
}; };
let quoted_expr = quote_expr!( let quoted_expr = copy quote_expr!(
::core::sys::begin_unwind(~"explicit failure", ~"empty", 1); ::core::sys::begin_unwind(~"explicit failure", ~"empty", 1);
).node; ).node;

View file

@ -192,7 +192,7 @@ pub trait ext_ctxt {
} }
pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
cfg: ast::crate_cfg) -> ext_ctxt { +cfg: ast::crate_cfg) -> ext_ctxt {
struct CtxtRepr { struct CtxtRepr {
parse_sess: @mut parse::ParseSess, parse_sess: @mut parse::ParseSess,
cfg: ast::crate_cfg, cfg: ast::crate_cfg,
@ -203,7 +203,7 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
impl ext_ctxt for CtxtRepr { impl ext_ctxt for CtxtRepr {
fn codemap(@mut self) -> @CodeMap { self.parse_sess.cm } fn codemap(@mut self) -> @CodeMap { self.parse_sess.cm }
fn parse_sess(@mut self) -> @mut parse::ParseSess { self.parse_sess } fn parse_sess(@mut self) -> @mut parse::ParseSess { self.parse_sess }
fn cfg(@mut self) -> ast::crate_cfg { self.cfg } fn cfg(@mut self) -> ast::crate_cfg { copy self.cfg }
fn call_site(@mut self) -> span { fn call_site(@mut self) -> span {
match *self.backtrace { match *self.backtrace {
Some(@ExpandedFrom(CallInfo {call_site: cs, _})) => cs, Some(@ExpandedFrom(CallInfo {call_site: cs, _})) => cs,
@ -214,7 +214,7 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
fn backtrace(@mut self) -> Option<@ExpnInfo> { *self.backtrace } fn backtrace(@mut self) -> Option<@ExpnInfo> { *self.backtrace }
fn mod_push(@mut self, i: ast::ident) { self.mod_path.push(i); } fn mod_push(@mut self, i: ast::ident) { self.mod_path.push(i); }
fn mod_pop(@mut self) { self.mod_path.pop(); } fn mod_pop(@mut self) { self.mod_path.pop(); }
fn mod_path(@mut self) -> ~[ast::ident] { return self.mod_path; } fn mod_path(@mut self) -> ~[ast::ident] { copy self.mod_path }
fn bt_push(@mut self, ei: codemap::ExpnInfo) { fn bt_push(@mut self, ei: codemap::ExpnInfo) {
match ei { match ei {
ExpandedFrom(CallInfo {call_site: cs, callee: ref callee}) => { ExpandedFrom(CallInfo {call_site: cs, callee: ref callee}) => {
@ -222,7 +222,7 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
Some(@ExpandedFrom(CallInfo { Some(@ExpandedFrom(CallInfo {
call_site: span {lo: cs.lo, hi: cs.hi, call_site: span {lo: cs.lo, hi: cs.hi,
expn_info: *self.backtrace}, expn_info: *self.backtrace},
callee: (*callee)})); callee: copy *callee}));
} }
} }
} }
@ -269,12 +269,11 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
fn set_trace_macros(@mut self, x: bool) { fn set_trace_macros(@mut self, x: bool) {
self.trace_mac = x self.trace_mac = x
} }
fn str_of(@mut self, id: ast::ident) -> ~str { fn str_of(@mut self, id: ast::ident) -> ~str {
*self.parse_sess.interner.get(id) copy *self.parse_sess.interner.get(id)
} }
fn ident_of(@mut self, st: ~str) -> ast::ident { fn ident_of(@mut self, st: ~str) -> ast::ident {
self.parse_sess.interner.intern(@st) self.parse_sess.interner.intern(@/*bad*/ copy st)
} }
} }
let imp: @mut CtxtRepr = @mut CtxtRepr { let imp: @mut CtxtRepr = @mut CtxtRepr {
@ -290,7 +289,7 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
pub fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str { pub fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
match expr.node { match expr.node {
ast::expr_lit(l) => match l.node { ast::expr_lit(l) => match l.node {
ast::lit_str(s) => return *s, ast::lit_str(s) => copy *s,
_ => cx.span_fatal(l.span, err_msg) _ => cx.span_fatal(l.span, err_msg)
}, },
_ => cx.span_fatal(expr.span, err_msg) _ => cx.span_fatal(expr.span, err_msg)

View file

@ -26,7 +26,7 @@ pub struct Field {
pub fn mk_expr(cx: ext_ctxt, pub fn mk_expr(cx: ext_ctxt,
sp: codemap::span, sp: codemap::span,
expr: ast::expr_) +expr: ast::expr_)
-> @ast::expr { -> @ast::expr {
@ast::expr { @ast::expr {
id: cx.next_id(), id: cx.next_id(),
@ -62,7 +62,7 @@ pub fn mk_unary(cx: ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
cx.next_id(); // see ast_util::op_expr_callee_id cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_unary(op, e)) mk_expr(cx, sp, ast::expr_unary(op, e))
} }
pub fn mk_raw_path(sp: span, idents: ~[ast::ident]) -> @ast::path { pub fn mk_raw_path(sp: span, +idents: ~[ast::ident]) -> @ast::path {
let p = @ast::path { span: sp, let p = @ast::path { span: sp,
global: false, global: false,
idents: idents, idents: idents,
@ -71,7 +71,7 @@ pub fn mk_raw_path(sp: span, idents: ~[ast::ident]) -> @ast::path {
return p; return p;
} }
pub fn mk_raw_path_(sp: span, pub fn mk_raw_path_(sp: span,
idents: ~[ast::ident], +idents: ~[ast::ident],
+types: ~[@ast::Ty]) +types: ~[@ast::Ty])
-> @ast::path { -> @ast::path {
@ast::path { span: sp, @ast::path { span: sp,
@ -80,17 +80,17 @@ pub fn mk_raw_path_(sp: span,
rp: None, rp: None,
types: types } types: types }
} }
pub fn mk_raw_path_global(sp: span, idents: ~[ast::ident]) -> @ast::path { pub fn mk_raw_path_global(sp: span, +idents: ~[ast::ident]) -> @ast::path {
@ast::path { span: sp, @ast::path { span: sp,
global: true, global: true,
idents: idents, idents: idents,
rp: None, rp: None,
types: ~[] } types: ~[] }
} }
pub fn mk_path(cx: ext_ctxt, sp: span, idents: ~[ast::ident]) -> @ast::expr { pub fn mk_path(cx: ext_ctxt, sp: span, +idents: ~[ast::ident]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents))) mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents)))
} }
pub fn mk_path_global(cx: ext_ctxt, sp: span, idents: ~[ast::ident]) pub fn mk_path_global(cx: ext_ctxt, sp: span, +idents: ~[ast::ident])
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, ast::expr_path(mk_raw_path_global(sp, idents))) mk_expr(cx, sp, ast::expr_path(mk_raw_path_global(sp, idents)))
} }
@ -98,7 +98,7 @@ pub fn mk_access_(cx: ext_ctxt, sp: span, p: @ast::expr, m: ast::ident)
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, ast::expr_field(p, m, ~[])) mk_expr(cx, sp, ast::expr_field(p, m, ~[]))
} }
pub fn mk_access(cx: ext_ctxt, sp: span, p: ~[ast::ident], m: ast::ident) pub fn mk_access(cx: ext_ctxt, sp: span, +p: ~[ast::ident], m: ast::ident)
-> @ast::expr { -> @ast::expr {
let pathexpr = mk_path(cx, sp, p); let pathexpr = mk_path(cx, sp, p);
return mk_access_(cx, sp, pathexpr, m); return mk_access_(cx, sp, pathexpr, m);
@ -107,21 +107,21 @@ pub fn mk_addr_of(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
return mk_expr(cx, sp, ast::expr_addr_of(ast::m_imm, e)); return mk_expr(cx, sp, ast::expr_addr_of(ast::m_imm, e));
} }
pub fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr, pub fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr,
args: ~[@ast::expr]) -> @ast::expr { +args: ~[@ast::expr]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar)) mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar))
} }
pub fn mk_call(cx: ext_ctxt, sp: span, fn_path: ~[ast::ident], pub fn mk_call(cx: ext_ctxt, sp: span, +fn_path: ~[ast::ident],
args: ~[@ast::expr]) -> @ast::expr { +args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path(cx, sp, fn_path); let pathexpr = mk_path(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args); return mk_call_(cx, sp, pathexpr, args);
} }
pub fn mk_call_global(cx: ext_ctxt, sp: span, fn_path: ~[ast::ident], pub fn mk_call_global(cx: ext_ctxt, sp: span, +fn_path: ~[ast::ident],
args: ~[@ast::expr]) -> @ast::expr { +args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path_global(cx, sp, fn_path); let pathexpr = mk_path_global(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args); return mk_call_(cx, sp, pathexpr, args);
} }
// e = expr, t = type // e = expr, t = type
pub fn mk_base_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) pub fn mk_base_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
let vecexpr = ast::expr_vec(exprs, ast::m_imm); let vecexpr = ast::expr_vec(exprs, ast::m_imm);
mk_expr(cx, sp, vecexpr) mk_expr(cx, sp, vecexpr)
@ -131,25 +131,25 @@ pub fn mk_vstore_e(cx: ext_ctxt, sp: span, expr: @ast::expr,
@ast::expr { @ast::expr {
mk_expr(cx, sp, ast::expr_vstore(expr, vst)) mk_expr(cx, sp, ast::expr_vstore(expr, vst))
} }
pub fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) pub fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::expr_vstore_uniq) mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::expr_vstore_uniq)
} }
pub fn mk_slice_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) pub fn mk_slice_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs),
ast::expr_vstore_slice) ast::expr_vstore_slice)
} }
pub fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) pub fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs),
ast::expr_vstore_fixed(None)) ast::expr_vstore_fixed(None))
} }
pub fn mk_base_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { pub fn mk_base_str(cx: ext_ctxt, sp: span, +s: ~str) -> @ast::expr {
let lit = ast::lit_str(@s); let lit = ast::lit_str(@s);
return mk_lit(cx, sp, lit); return mk_lit(cx, sp, lit);
} }
pub fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { pub fn mk_uniq_str(cx: ext_ctxt, sp: span, +s: ~str) -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::expr_vstore_uniq) mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::expr_vstore_uniq)
} }
pub fn mk_field(sp: span, f: &Field) -> ast::field { pub fn mk_field(sp: span, f: &Field) -> ast::field {
@ -161,28 +161,36 @@ pub fn mk_field(sp: span, f: &Field) -> ast::field {
pub fn mk_fields(sp: span, fields: ~[Field]) -> ~[ast::field] { pub fn mk_fields(sp: span, fields: ~[Field]) -> ~[ast::field] {
fields.map(|f| mk_field(sp, f)) fields.map(|f| mk_field(sp, f))
} }
pub fn mk_rec_e(cx: ext_ctxt, sp: span, fields: ~[Field]) -> @ast::expr { pub fn mk_rec_e(cx: ext_ctxt,
sp: span,
+fields: ~[Field])
-> @ast::expr {
mk_expr(cx, sp, ast::expr_rec(mk_fields(sp, fields), mk_expr(cx, sp, ast::expr_rec(mk_fields(sp, fields),
option::None::<@ast::expr>)) option::None::<@ast::expr>))
} }
pub fn mk_struct_e(cx: ext_ctxt, sp: span, ctor_path: ~[ast::ident], pub fn mk_struct_e(cx: ext_ctxt,
fields: ~[Field]) -> @ast::expr { sp: span,
+ctor_path: ~[ast::ident],
+fields: ~[Field])
-> @ast::expr {
mk_expr(cx, sp, mk_expr(cx, sp,
ast::expr_struct(mk_raw_path(sp, ctor_path), ast::expr_struct(mk_raw_path(sp, ctor_path),
mk_fields(sp, fields), mk_fields(sp, fields),
option::None::<@ast::expr>)) option::None::<@ast::expr>))
} }
pub fn mk_global_struct_e(cx: ext_ctxt, sp: span, pub fn mk_global_struct_e(cx: ext_ctxt,
ctor_path: ~[ast::ident], sp: span,
fields: ~[Field]) +ctor_path: ~[ast::ident],
+fields: ~[Field])
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, mk_expr(cx, sp,
ast::expr_struct(mk_raw_path_global(sp, ctor_path), ast::expr_struct(mk_raw_path_global(sp, ctor_path),
mk_fields(sp, fields), mk_fields(sp, fields),
option::None::<@ast::expr>)) option::None::<@ast::expr>))
} }
pub fn mk_glob_use(cx: ext_ctxt, sp: span, path: ~[ast::ident]) pub fn mk_glob_use(cx: ext_ctxt,
-> @ast::view_item { sp: span,
+path: ~[ast::ident]) -> @ast::view_item {
let glob = @codemap::spanned { let glob = @codemap::spanned {
node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()), node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()),
span: sp, span: sp,
@ -218,8 +226,8 @@ pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool,
@codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp } @codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp }
} }
pub fn mk_block(cx: ext_ctxt, span: span, pub fn mk_block(cx: ext_ctxt, span: span,
view_items: ~[@ast::view_item], +view_items: ~[@ast::view_item],
stmts: ~[@ast::stmt], +stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> @ast::expr { expr: Option<@ast::expr>) -> @ast::expr {
let blk = codemap::spanned { let blk = codemap::spanned {
node: ast::blk_ { node: ast::blk_ {
@ -313,7 +321,7 @@ pub fn mk_stmt(cx: ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt {
} }
pub fn mk_ty_path(cx: ext_ctxt, pub fn mk_ty_path(cx: ext_ctxt,
span: span, span: span,
idents: ~[ ast::ident ]) +idents: ~[ ast::ident ])
-> @ast::Ty { -> @ast::Ty {
let ty = build::mk_raw_path(span, idents); let ty = build::mk_raw_path(span, idents);
let ty = ast::ty_path(ty, cx.next_id()); let ty = ast::ty_path(ty, cx.next_id());
@ -322,7 +330,7 @@ pub fn mk_ty_path(cx: ext_ctxt,
} }
pub fn mk_ty_path_global(cx: ext_ctxt, pub fn mk_ty_path_global(cx: ext_ctxt,
span: span, span: span,
idents: ~[ ast::ident ]) +idents: ~[ ast::ident ])
-> @ast::Ty { -> @ast::Ty {
let ty = build::mk_raw_path_global(span, idents); let ty = build::mk_raw_path_global(span, idents);
let ty = ast::ty_path(ty, cx.next_id()); let ty = ast::ty_path(ty, cx.next_id());

View file

@ -472,8 +472,8 @@ fn call_substructure_iter_bytes_method(cx: ext_ctxt,
fn variant_arg_count(cx: ext_ctxt, span: span, variant: &variant) -> uint { fn variant_arg_count(cx: ext_ctxt, span: span, variant: &variant) -> uint {
match variant.node.kind { match variant.node.kind {
tuple_variant_kind(args) => args.len(), tuple_variant_kind(ref args) => args.len(),
struct_variant_kind(struct_def) => struct_def.fields.len(), struct_variant_kind(ref struct_def) => struct_def.fields.len(),
enum_variant_kind(*) => { enum_variant_kind(*) => {
cx.span_bug(span, ~"variant_arg_count: enum variants deprecated") cx.span_bug(span, ~"variant_arg_count: enum variants deprecated")
} }

View file

@ -31,8 +31,8 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
// Option<str> rather than just an maybe-empty string. // Option<str> rather than just an maybe-empty string.
let e = match os::getenv(var) { let e = match os::getenv(var) {
option::None => mk_uniq_str(cx, sp, ~""), None => mk_uniq_str(cx, sp, ~""),
option::Some(ref s) => mk_uniq_str(cx, sp, (*s)) Some(ref s) => mk_uniq_str(cx, sp, copy *s)
}; };
MRExpr(e) MRExpr(e)
} }

View file

@ -52,7 +52,7 @@ pub fn expand_expr(exts: SyntaxExtensions, cx: ext_ctxt,
cx.bt_push(ExpandedFrom(CallInfo { cx.bt_push(ExpandedFrom(CallInfo {
call_site: s, call_site: s,
callee: NameAndSpan { callee: NameAndSpan {
name: *extname, name: copy *extname,
span: exp_sp, span: exp_sp,
}, },
})); }));
@ -72,7 +72,8 @@ pub fn expand_expr(exts: SyntaxExtensions, cx: ext_ctxt,
}; };
//keep going, outside-in //keep going, outside-in
let fully_expanded = fld.fold_expr(expanded).node; let fully_expanded =
copy fld.fold_expr(expanded).node;
cx.bt_pop(); cx.bt_pop();
(fully_expanded, s) (fully_expanded, s)
@ -169,7 +170,7 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
let (pth, tts) = match it.node { let (pth, tts) = match it.node {
item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => { item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => {
(pth, (*tts)) (pth, copy *tts)
} }
_ => cx.span_bug(it.span, ~"invalid item macro invocation") _ => cx.span_bug(it.span, ~"invalid item macro invocation")
}; };
@ -189,8 +190,8 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
cx.bt_push(ExpandedFrom(CallInfo { cx.bt_push(ExpandedFrom(CallInfo {
call_site: it.span, call_site: it.span,
callee: NameAndSpan { callee: NameAndSpan {
name: *extname, name: copy *extname,
span: (*expand).span span: expand.span
} }
})); }));
((*expand).expander)(cx, it.span, tts) ((*expand).expander)(cx, it.span, tts)
@ -204,8 +205,8 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
cx.bt_push(ExpandedFrom(CallInfo { cx.bt_push(ExpandedFrom(CallInfo {
call_site: it.span, call_site: it.span,
callee: NameAndSpan { callee: NameAndSpan {
name: *extname, name: copy *extname,
span: (*expand).span span: expand.span
} }
})); }));
((*expand).expander)(cx, it.span, it.ident, tts) ((*expand).expander)(cx, it.span, it.ident, tts)
@ -238,7 +239,9 @@ pub fn expand_stmt(exts: SyntaxExtensions, cx: ext_ctxt,
let (mac, pth, tts, semi) = match *s { let (mac, pth, tts, semi) = match *s {
stmt_mac(ref mac, semi) => { stmt_mac(ref mac, semi) => {
match mac.node { match mac.node {
mac_invoc_tt(pth, ref tts) => ((*mac), pth, (*tts), semi) mac_invoc_tt(pth, ref tts) => {
(copy *mac, pth, copy *tts, semi)
}
} }
} }
_ => return orig(s, sp, fld) _ => return orig(s, sp, fld)
@ -254,7 +257,7 @@ pub fn expand_stmt(exts: SyntaxExtensions, cx: ext_ctxt,
SyntaxExpanderTT{expander: exp, span: exp_sp})) => { SyntaxExpanderTT{expander: exp, span: exp_sp})) => {
cx.bt_push(ExpandedFrom(CallInfo { cx.bt_push(ExpandedFrom(CallInfo {
call_site: sp, call_site: sp,
callee: NameAndSpan { name: *extname, span: exp_sp } callee: NameAndSpan { name: copy *extname, span: exp_sp }
})); }));
let expanded = match exp(cx, mac.span, tts) { let expanded = match exp(cx, mac.span, tts) {
MRExpr(e) => MRExpr(e) =>
@ -267,7 +270,7 @@ pub fn expand_stmt(exts: SyntaxExtensions, cx: ext_ctxt,
}; };
//keep going, outside-in //keep going, outside-in
let fully_expanded = fld.fold_stmt(expanded).node; let fully_expanded = copy fld.fold_stmt(expanded).node;
cx.bt_pop(); cx.bt_pop();
(fully_expanded, sp) (fully_expanded, sp)
@ -351,7 +354,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
cfg: ast::crate_cfg, c: @crate) -> @crate { cfg: ast::crate_cfg, c: @crate) -> @crate {
let exts = syntax_expander_table(); let exts = syntax_expander_table();
let afp = default_ast_fold(); let afp = default_ast_fold();
let cx: ext_ctxt = mk_ctxt(parse_sess, cfg); let cx: ext_ctxt = mk_ctxt(parse_sess, copy cfg);
let f_pre = @AstFoldFns { let f_pre = @AstFoldFns {
fold_expr: |a,b,c| expand_expr(exts, cx, a, b, c, afp.fold_expr), fold_expr: |a,b,c| expand_expr(exts, cx, a, b, c, afp.fold_expr),
fold_mod: |a,b| expand_mod_items(exts, cx, a, b, afp.fold_mod), fold_mod: |a,b| expand_mod_items(exts, cx, a, b, afp.fold_mod),
@ -362,7 +365,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
let f = make_fold(f_pre); let f = make_fold(f_pre);
let cm = parse_expr_from_source_str(~"<core-macros>", let cm = parse_expr_from_source_str(~"<core-macros>",
@core_macros(), @core_macros(),
cfg, copy cfg,
parse_sess); parse_sess);
// This is run for its side-effects on the expander env, // This is run for its side-effects on the expander env,

View file

@ -276,9 +276,9 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
for pieces.each |pc| { for pieces.each |pc| {
match *pc { match *pc {
PieceString(ref s) => { PieceString(ref s) => {
piece_exprs.push(mk_uniq_str(cx, fmt_sp, (*s))) piece_exprs.push(mk_uniq_str(cx, fmt_sp, copy *s))
} }
PieceConv(conv) => { PieceConv(ref conv) => {
n += 1u; n += 1u;
if n >= nargs { if n >= nargs {
cx.span_fatal(sp, cx.span_fatal(sp,
@ -286,9 +286,14 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
~"for the given format string"); ~"for the given format string");
} }
debug!("Building conversion:"); debug!("Building conversion:");
log_conv(conv); log_conv(/*bad*/ copy *conv);
let arg_expr = args[n]; let arg_expr = args[n];
let c_expr = make_new_conv(cx, fmt_sp, conv, arg_expr); let c_expr = make_new_conv(
cx,
fmt_sp,
/*bad*/ copy *conv,
arg_expr
);
piece_exprs.push(c_expr); piece_exprs.push(c_expr);
} }
} }

View file

@ -58,14 +58,14 @@ pub impl append_types for @ast::path {
fn add_ty(&self, ty: @ast::Ty) -> @ast::path { fn add_ty(&self, ty: @ast::Ty) -> @ast::path {
@ast::path { @ast::path {
types: vec::append_one(copy self.types, ty), types: vec::append_one(copy self.types, ty),
.. **self .. copy **self
} }
} }
fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::path { fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::path {
@ast::path { @ast::path {
types: vec::append(copy self.types, tys), types: vec::append(copy self.types, tys),
.. **self .. copy **self
} }
} }
} }
@ -97,12 +97,12 @@ pub trait ext_ctxt_ast_builder {
+enum_definition: ast::enum_def) -> @ast::item; +enum_definition: ast::enum_def) -> @ast::item;
fn item_struct_poly(&self, fn item_struct_poly(&self,
name: ident, span: span, name: ident, span: span,
struct_def: ast::struct_def, +struct_def: ast::struct_def,
+ty_params: ~[ast::ty_param]) -> @ast::item; +ty_params: ~[ast::ty_param]) -> @ast::item;
fn item_struct(&self, name: ident, span: span, fn item_struct(&self, name: ident, span: span,
struct_def: ast::struct_def) -> @ast::item; +struct_def: ast::struct_def) -> @ast::item;
fn struct_expr(&self, path: @ast::path, fn struct_expr(&self, path: @ast::path,
fields: ~[ast::field]) -> @ast::expr; +fields: ~[ast::field]) -> @ast::expr;
fn variant(&self, name: ident, span: span, fn variant(&self, name: ident, span: span,
+tys: ~[@ast::Ty]) -> ast::variant; +tys: ~[@ast::Ty]) -> ast::variant;
fn item_mod(&self, name: ident, span: span, fn item_mod(&self, name: ident, span: span,
@ -284,18 +284,18 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
} }
fn item_struct(&self, name: ident, span: span, fn item_struct(&self, name: ident, span: span,
struct_def: ast::struct_def) -> @ast::item { +struct_def: ast::struct_def) -> @ast::item {
self.item_struct_poly(name, span, struct_def, ~[]) self.item_struct_poly(name, span, struct_def, ~[])
} }
fn item_struct_poly(&self, name: ident, span: span, fn item_struct_poly(&self, name: ident, span: span,
struct_def: ast::struct_def, +struct_def: ast::struct_def,
+ty_params: ~[ast::ty_param]) -> @ast::item { +ty_params: ~[ast::ty_param]) -> @ast::item {
self.item(name, span, ast::item_struct(@struct_def, ty_params)) self.item(name, span, ast::item_struct(@struct_def, ty_params))
} }
fn struct_expr(&self, path: @ast::path, fn struct_expr(&self, path: @ast::path,
fields: ~[ast::field]) -> @ast::expr { +fields: ~[ast::field]) -> @ast::expr {
@ast::expr { @ast::expr {
id: self.next_id(), id: self.next_id(),
callee_id: self.next_id(), callee_id: self.next_id(),

View file

@ -88,7 +88,7 @@ pub fn analyze(proto: protocol, _cx: ext_ctxt) {
} }
if self_live.len() > 0 { if self_live.len() > 0 {
let states = str::connect(self_live.map(|s| s.name), ~" "); let states = str::connect(self_live.map(|s| copy s.name), ~" ");
debug!("protocol %s is unbounded due to loops involving: %s", debug!("protocol %s is unbounded due to loops involving: %s",
proto.name, states); proto.name, states);

View file

@ -65,11 +65,11 @@ pub mod liveness;
pub fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident, pub fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident,
tt: ~[ast::token_tree]) -> base::MacResult { tt: ~[ast::token_tree]) -> base::MacResult {
let sess = cx.parse_sess(); let sess = cx.parse_sess();
let cfg = cx.cfg(); let cfg = cx.cfg();
let tt_rdr = new_tt_reader(copy cx.parse_sess().span_diagnostic, let tt_rdr = new_tt_reader(copy cx.parse_sess().span_diagnostic,
cx.parse_sess().interner, None, tt); cx.parse_sess().interner, None, copy tt);
let rdr = tt_rdr as reader; let rdr = tt_rdr as reader;
let rust_parser = Parser(sess, cfg, rdr.dup()); let rust_parser = Parser(sess, cfg, rdr.dup());

View file

@ -18,13 +18,13 @@ use parse::token;
use core::prelude::*; use core::prelude::*;
pub trait proto_parser { pub trait proto_parser {
fn parse_proto(&self, id: ~str) -> protocol; fn parse_proto(&self, +id: ~str) -> protocol;
fn parse_state(&self, proto: protocol); fn parse_state(&self, proto: protocol);
fn parse_message(&self, state: state); fn parse_message(&self, state: state);
} }
pub impl proto_parser for parser::Parser { pub impl proto_parser for parser::Parser {
fn parse_proto(&self, id: ~str) -> protocol { fn parse_proto(&self, +id: ~str) -> protocol {
let proto = protocol(id, *self.span); let proto = protocol(id, *self.span);
self.parse_seq_to_before_end( self.parse_seq_to_before_end(
@ -41,7 +41,7 @@ pub impl proto_parser for parser::Parser {
fn parse_state(&self, proto: protocol) { fn parse_state(&self, proto: protocol) {
let id = self.parse_ident(); let id = self.parse_ident();
let name = *self.interner.get(id); let name = copy *self.interner.get(id);
self.expect(&token::COLON); self.expect(&token::COLON);
let dir = match copy *self.token { let dir = match copy *self.token {
@ -76,7 +76,7 @@ pub impl proto_parser for parser::Parser {
} }
fn parse_message(&self, state: state) { fn parse_message(&self, state: state) {
let mname = *self.interner.get(self.parse_ident()); let mname = copy *self.interner.get(self.parse_ident());
let args = if *self.token == token::LPAREN { let args = if *self.token == token::LPAREN {
self.parse_unspanned_seq( self.parse_unspanned_seq(
@ -95,7 +95,7 @@ pub impl proto_parser for parser::Parser {
let next = match *self.token { let next = match *self.token {
token::IDENT(_, _) => { token::IDENT(_, _) => {
let name = *self.interner.get(self.parse_ident()); let name = copy *self.interner.get(self.parse_ident());
let ntys = if *self.token == token::LT { let ntys = if *self.token == token::LT {
self.parse_unspanned_seq( self.parse_unspanned_seq(
&token::LT, &token::LT,

View file

@ -118,7 +118,7 @@ pub impl gen_send for message {
let mut rty = cx.ty_path_ast_builder(path(~[next.data_name()], let mut rty = cx.ty_path_ast_builder(path(~[next.data_name()],
span) span)
.add_tys(next_state.tys)); .add_tys(copy next_state.tys));
if try { if try {
rty = cx.ty_option(rty); rty = cx.ty_option(rty);
} }
@ -152,7 +152,7 @@ pub impl gen_send for message {
~"" ~""
} }
else { else {
~"(" + str::connect(arg_names.map(|x| *x), ~"(" + str::connect(arg_names.map(|x| copy *x),
~", ") + ~")" ~", ") + ~")"
}; };
@ -209,7 +209,7 @@ pub impl to_type_decls for state {
let mut items_msg = ~[]; let mut items_msg = ~[];
for self.messages.each |m| { for self.messages.each |m| {
let message(name, span, tys, this, next) = *m; let message(name, span, tys, this, next) = copy *m;
let tys = match next { let tys = match next {
Some(ref next_state) => { Some(ref next_state) => {
@ -225,7 +225,7 @@ pub impl to_type_decls for state {
cx.ty_path_ast_builder( cx.ty_path_ast_builder(
path(~[cx.ident_of(dir), path(~[cx.ident_of(dir),
cx.ident_of(next_name)], span) cx.ident_of(next_name)], span)
.add_tys(next_state.tys))) .add_tys(copy next_state.tys)))
} }
None => tys None => tys
}; };

View file

@ -50,7 +50,7 @@ pub struct message(~str, span, ~[@ast::Ty], state, Option<next_state>);
pub impl message { pub impl message {
fn name(&mut self) -> ~str { fn name(&mut self) -> ~str {
match *self { match *self {
message(ref id, _, _, _, _) => (*id) message(ref id, _, _, _, _) => copy *id
} }
} }
@ -63,7 +63,7 @@ pub impl message {
/// Return the type parameters actually used by this message /// Return the type parameters actually used by this message
fn get_params(&mut self) -> ~[ast::ty_param] { fn get_params(&mut self) -> ~[ast::ty_param] {
match *self { match *self {
message(_, _, _, this, _) => this.ty_params message(_, _, _, this, _) => copy this.ty_params
} }
} }
} }
@ -82,8 +82,8 @@ pub struct state_ {
} }
pub impl state_ { pub impl state_ {
fn add_message(@self, name: ~str, span: span, fn add_message(@self, +name: ~str, span: span,
+data: ~[@ast::Ty], next: Option<next_state>) { +data: ~[@ast::Ty], +next: Option<next_state>) {
self.messages.push(message(name, span, data, self, self.messages.push(message(name, span, data, self,
next)); next));
} }

View file

@ -262,10 +262,10 @@ pub fn expand_quote_stmt(cx: ext_ctxt,
} }
fn ids_ext(cx: ext_ctxt, strs: ~[~str]) -> ~[ast::ident] { fn ids_ext(cx: ext_ctxt, strs: ~[~str]) -> ~[ast::ident] {
strs.map(|str| cx.parse_sess().interner.intern(@*str)) strs.map(|str| cx.parse_sess().interner.intern(@copy *str))
} }
fn id_ext(cx: ext_ctxt, str: ~str) -> ast::ident { fn id_ext(cx: ext_ctxt, +str: ~str) -> ast::ident {
cx.parse_sess().interner.intern(@str) cx.parse_sess().interner.intern(@str)
} }
@ -580,8 +580,8 @@ fn expand_tts(cx: ext_ctxt,
fn expand_parse_call(cx: ext_ctxt, fn expand_parse_call(cx: ext_ctxt,
sp: span, sp: span,
parse_method: ~str, +parse_method: ~str,
arg_exprs: ~[@ast::expr], +arg_exprs: ~[@ast::expr],
tts: &[ast::token_tree]) -> @ast::expr { tts: &[ast::token_tree]) -> @ast::expr {
let tts_expr = expand_tts(cx, sp, tts); let tts_expr = expand_tts(cx, sp, tts);

View file

@ -138,10 +138,10 @@ pub fn count_names(ms: &[matcher]) -> uint {
} }
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos) pub fn initial_matcher_pos(+ms: ~[matcher], sep: Option<Token>, lo: BytePos)
-> ~MatcherPos { -> ~MatcherPos {
let mut match_idx_hi = 0u; let mut match_idx_hi = 0u;
for ms.each() |elt| { for ms.each |elt| {
match elt.node { match elt.node {
match_tok(_) => (), match_tok(_) => (),
match_seq(_,_,_,_,hi) => { match_seq(_,_,_,_,hi) => {
@ -152,12 +152,13 @@ pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos)
} }
} }
} }
let matches = vec::from_fn(count_names(ms), |_i| dvec::DVec());
~MatcherPos { ~MatcherPos {
elts: ms, elts: ms,
sep: sep, sep: sep,
idx: 0u, idx: 0u,
up: matcher_pos_up(None), up: matcher_pos_up(None),
matches: copy vec::from_fn(count_names(ms), |_i| dvec::DVec()), matches: matches,
match_lo: 0u, match_lo: 0u,
match_hi: match_idx_hi, match_hi: match_idx_hi,
sp_lo: lo sp_lo: lo
@ -238,7 +239,7 @@ pub fn parse(sess: @mut ParseSess,
ms: ~[matcher]) ms: ~[matcher])
-> parse_result { -> parse_result {
let mut cur_eis = ~[]; let mut cur_eis = ~[];
cur_eis.push(initial_matcher_pos(ms, None, rdr.peek().sp.lo)); cur_eis.push(initial_matcher_pos(copy ms, None, rdr.peek().sp.lo));
loop { loop {
let mut bb_eis = ~[]; // black-box parsed by parser.rs let mut bb_eis = ~[]; // black-box parsed by parser.rs
@ -329,8 +330,8 @@ pub fn parse(sess: @mut ParseSess,
|_m| DVec::<@named_match>()); |_m| DVec::<@named_match>());
let ei_t = ei; let ei_t = ei;
cur_eis.push(~MatcherPos { cur_eis.push(~MatcherPos {
elts: (*matchers), elts: copy *matchers,
sep: (*sep), sep: copy *sep,
idx: 0u, idx: 0u,
up: matcher_pos_up(Some(ei_t)), up: matcher_pos_up(Some(ei_t)),
matches: matches, matches: matches,

View file

@ -54,7 +54,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
// Parse the macro_rules! invocation (`none` is for no interpolations): // Parse the macro_rules! invocation (`none` is for no interpolations):
let arg_reader = new_tt_reader(copy cx.parse_sess().span_diagnostic, let arg_reader = new_tt_reader(copy cx.parse_sess().span_diagnostic,
cx.parse_sess().interner, None, arg); cx.parse_sess().interner, None, copy arg);
let argument_map = parse_or_else(cx.parse_sess(), cx.cfg(), let argument_map = parse_or_else(cx.parse_sess(), cx.cfg(),
arg_reader as reader, argument_gram); arg_reader as reader, argument_gram);
@ -130,7 +130,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
} }
failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo { failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo {
best_fail_spot = sp; best_fail_spot = sp;
best_fail_msg = (*msg); best_fail_msg = copy *msg;
}, },
error(sp, ref msg) => cx.span_fatal(sp, (*msg)) error(sp, ref msg) => cx.span_fatal(sp, (*msg))
} }
@ -145,7 +145,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
|cx, sp, arg| generic_extension(cx, sp, name, arg, lhses, rhses); |cx, sp, arg| generic_extension(cx, sp, name, arg, lhses, rhses);
return MRDef(MacroDef{ return MRDef(MacroDef{
name: *cx.parse_sess().interner.get(name), name: copy *cx.parse_sess().interner.get(name),
ext: NormalTT(base::SyntaxExpanderTT{expander: exp, span: Some(sp)}) ext: NormalTT(base::SyntaxExpanderTT{expander: exp, span: Some(sp)})
}); });
} }

View file

@ -54,7 +54,7 @@ pub struct TtReader {
pub fn new_tt_reader(sp_diag: span_handler, pub fn new_tt_reader(sp_diag: span_handler,
itr: @ident_interner, itr: @ident_interner,
interp: Option<std::oldmap::HashMap<ident,@named_match>>, interp: Option<std::oldmap::HashMap<ident,@named_match>>,
src: ~[ast::token_tree]) +src: ~[ast::token_tree])
-> @mut TtReader { -> @mut TtReader {
let r = @mut TtReader { let r = @mut TtReader {
sp_diag: sp_diag, sp_diag: sp_diag,
@ -101,7 +101,7 @@ pub pure fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader {
interpolations: r.interpolations, interpolations: r.interpolations,
repeat_idx: copy r.repeat_idx, repeat_idx: copy r.repeat_idx,
repeat_len: copy r.repeat_len, repeat_len: copy r.repeat_len,
cur_tok: r.cur_tok, cur_tok: copy r.cur_tok,
cur_span: r.cur_span cur_span: r.cur_span
} }
} }
@ -115,7 +115,7 @@ pure fn lookup_cur_matched_by_matched(r: @mut TtReader,
// end of the line; duplicate henceforth // end of the line; duplicate henceforth
ad ad
} }
matched_seq(ads, _) => ads[*idx] matched_seq(ref ads, _) => ads[*idx]
} }
} }
vec::foldl(start, r.repeat_idx, red) vec::foldl(start, r.repeat_idx, red)
@ -131,15 +131,15 @@ enum lis {
fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis {
fn lis_merge(lhs: lis, rhs: lis, r: @mut TtReader) -> lis { fn lis_merge(lhs: lis, rhs: lis, r: @mut TtReader) -> lis {
match lhs { match lhs {
lis_unconstrained => rhs, lis_unconstrained => copy rhs,
lis_contradiction(_) => lhs, lis_contradiction(_) => copy lhs,
lis_constraint(l_len, l_id) => match rhs { lis_constraint(l_len, l_id) => match rhs {
lis_unconstrained => lhs, lis_unconstrained => copy lhs,
lis_contradiction(_) => rhs, lis_contradiction(_) => copy rhs,
lis_constraint(r_len, _) if l_len == r_len => lhs, lis_constraint(r_len, _) if l_len == r_len => copy lhs,
lis_constraint(r_len, r_id) => { lis_constraint(r_len, r_id) => {
let l_n = *r.interner.get(l_id); let l_n = copy *r.interner.get(l_id);
let r_n = *r.interner.get(r_id); let r_n = copy *r.interner.get(r_id);
lis_contradiction(fmt!("Inconsistent lockstep iteration: \ lis_contradiction(fmt!("Inconsistent lockstep iteration: \
'%s' has %u items, but '%s' has %u", '%s' has %u items, but '%s' has %u",
l_n, l_len, r_n, r_len)) l_n, l_len, r_n, r_len))
@ -155,14 +155,17 @@ fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis {
tt_tok(*) => lis_unconstrained, tt_tok(*) => lis_unconstrained,
tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) { tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) {
matched_nonterminal(_) => lis_unconstrained, matched_nonterminal(_) => lis_unconstrained,
matched_seq(ads, _) => lis_constraint(ads.len(), name) matched_seq(ref ads, _) => lis_constraint(ads.len(), name)
} }
} }
} }
pub fn tt_next_token(r: @mut TtReader) -> TokenAndSpan { pub fn tt_next_token(r: @mut TtReader) -> TokenAndSpan {
let ret_val = TokenAndSpan { tok: r.cur_tok, sp: r.cur_span }; let ret_val = TokenAndSpan {
tok: copy r.cur_tok,
sp: r.cur_span,
};
while r.cur.idx >= r.cur.readme.len() { while r.cur.idx >= r.cur.readme.len() {
/* done with this set; pop or repeat? */ /* done with this set; pop or repeat? */
if ! r.cur.dotdotdoted if ! r.cur.dotdotdoted
@ -210,12 +213,13 @@ pub fn tt_next_token(r: @mut TtReader) -> TokenAndSpan {
// if this could be 0-length, we'd need to potentially recur here // if this could be 0-length, we'd need to potentially recur here
} }
tt_tok(sp, copy tok) => { tt_tok(sp, copy tok) => {
r.cur_span = sp; r.cur_tok = tok; r.cur_span = sp;
r.cur_tok = tok;
r.cur.idx += 1u; r.cur.idx += 1u;
return ret_val; return ret_val;
} }
tt_seq(sp, copy tts, copy sep, zerok) => { tt_seq(sp, copy tts, copy sep, zerok) => {
match lockstep_iter_size(tt_seq(sp, tts, sep, zerok), r) { match lockstep_iter_size(tt_seq(sp, copy tts, sep, zerok), r) {
lis_unconstrained => { lis_unconstrained => {
r.sp_diag.span_fatal( r.sp_diag.span_fatal(
sp, /* blame macro writer */ sp, /* blame macro writer */
@ -264,7 +268,8 @@ pub fn tt_next_token(r: @mut TtReader) -> TokenAndSpan {
return ret_val; return ret_val;
} }
matched_nonterminal(ref other_whole_nt) => { matched_nonterminal(ref other_whole_nt) => {
r.cur_span = sp; r.cur_tok = INTERPOLATED((*other_whole_nt)); r.cur_span = sp;
r.cur_tok = INTERPOLATED(copy *other_whole_nt);
r.cur.idx += 1u; r.cur.idx += 1u;
return ret_val; return ret_val;
} }