diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index f6a6ddefb7e..9973c9558c9 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -65,7 +65,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, // Produces an AST expression that represents a RT::conv record, // which tells the RT::conv* functions how to perform the conversion - fn make_rt_conv_expr(cx: @ext_ctxt, sp: span, cnv: Conv) -> @ast::expr { + fn make_rt_conv_expr(cx: @ext_ctxt, sp: span, cnv: &Conv) -> @ast::expr { fn make_flags(cx: @ext_ctxt, sp: span, flags: ~[Flag]) -> @ast::expr { let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none"); for flags.each |f| { @@ -139,7 +139,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, make_conv_struct(cx, sp, rt_conv_flags, rt_conv_width, rt_conv_precision, rt_conv_ty) } - fn make_conv_call(cx: @ext_ctxt, sp: span, conv_type: ~str, cnv: Conv, + fn make_conv_call(cx: @ext_ctxt, sp: span, conv_type: ~str, cnv: &Conv, arg: @ast::expr) -> @ast::expr { let fname = ~"conv_" + conv_type; let path = make_path_vec(cx, @fname); @@ -148,11 +148,11 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, return mk_call_global(cx, arg.span, path, args); } - fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) -> + fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: &Conv, arg: @ast::expr) -> @ast::expr { // FIXME: Move validation code into core::extfmt (Issue #2249) - fn is_signed_type(cnv: Conv) -> bool { + fn is_signed_type(cnv: &Conv) -> bool { match cnv.ty { TyInt(s) => match s { Signed => return true, @@ -220,7 +220,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, mk_addr_of(cx, sp, arg)) } } - fn log_conv(c: Conv) { + fn log_conv(c: &Conv) { match c.param { Some(p) => { debug!("param: %s", p.to_str()); } _ => debug!("param: none") @@ -285,12 +285,12 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, ~"for the given format string"); } debug!("Building conversion:"); - log_conv(/*bad*/ copy *conv); + log_conv(conv); let arg_expr = args[n]; let c_expr = make_new_conv( cx, fmt_sp, - /*bad*/ copy *conv, + conv, arg_expr ); piece_exprs.push(c_expr); diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index b6ec3aff44d..98208bf9f76 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -220,7 +220,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str], if col < len { s1 = str::slice(s, col, len); } else { s1 = ~""; } - } else { s1 = /*bad*/ copy s; } + } else { s1 = s; } debug!("pushing line: %s", s1); lines.push(s1); } @@ -357,8 +357,8 @@ pub fn gather_comments_and_literals(span_diagnostic: let TokenAndSpan {tok: tok, sp: sp} = rdr.peek(); if token::is_lit(&tok) { let s = get_str_from(rdr, bstart); - literals.push(lit {lit: /*bad*/ copy s, pos: sp.lo}); debug!("tok lit: %s", s); + literals.push(lit {lit: s, pos: sp.lo}); } else { debug!("tok: %s", token::to_str(rdr.interner, &tok)); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6f4d9332df8..45e09e4c29e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1438,7 +1438,7 @@ pub impl Parser { let (s, z) = p.parse_sep_and_zerok(); tt_seq( mk_sp(sp.lo ,p.span.hi), - /*bad*/ copy seq.node, + seq.node, s, z ) @@ -1855,7 +1855,7 @@ pub impl Parser { // Turn on the restriction to stop at | or || so we can parse // them as the lambda arguments let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP); - match /*bad*/ copy e.node { + match e.node { expr_call(f, args, NoSugar) => { let block = self.parse_lambda_block_expr(); let last_arg = self.mk_expr(block.span.lo, block.span.hi, @@ -2129,7 +2129,7 @@ pub impl Parser { let lo = self.span.lo; let mut hi = self.span.hi; let mut pat; - match copy *self.token { + match *self.token { token::UNDERSCORE => { self.bump(); pat = pat_wild; } token::AT => { self.bump(); @@ -2237,7 +2237,7 @@ pub impl Parser { self.expect(&token::RBRACKET); pat = ast::pat_vec(before, slice, after); } - copy tok => { + tok => { if !is_ident_or_path(&tok) || self.is_keyword(&~"true") || self.is_keyword(&~"false") @@ -3341,6 +3341,7 @@ pub impl Parser { VIEW_ITEMS_AND_ITEMS_ALLOWED, true); let mut items: ~[@item] = starting_items; + let attrs_remaining_len = attrs_remaining.len(); // looks like this code depends on the invariant that // outer attributes can't occur on view items (or macros @@ -3349,7 +3350,7 @@ pub impl Parser { while *self.token != term { let mut attrs = self.parse_outer_attributes(); if first { - attrs = vec::append(/*bad*/ copy attrs_remaining, attrs); + attrs = attrs_remaining + attrs; first = false; } debug!("parse_mod_items: parse_item_or_view_item(attrs=%?)", @@ -3378,7 +3379,7 @@ pub impl Parser { debug!("parse_mod_items: attrs=%?", attrs); } - if first && attrs_remaining.len() > 0u { + if first && attrs_remaining_len > 0u { // We parsed attributes for the first item but didn't find it self.fatal(~"expected item"); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9b8448bc2d9..4021598c466 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -134,7 +134,7 @@ pub fn print_crate(cm: @CodeMap, } pub fn print_crate_(s: @ps, &&crate: @ast::crate) { - print_mod(s, crate.node.module, crate.node.attrs); + print_mod(s, &crate.node.module, crate.node.attrs); print_remaining_comments(s); eof(s.s); } @@ -310,7 +310,7 @@ pub fn synth_comment(s: @ps, text: ~str) { word(s.s, ~"*/"); } -pub fn commasep(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN)) { +pub fn commasep(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) { box(s, 0u, b); let mut first = true; for elts.each |elt| { @@ -321,7 +321,7 @@ pub fn commasep(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN)) { } -pub fn commasep_cmnt(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN), +pub fn commasep_cmnt(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN), get_span: &fn(IN) -> codemap::span) { box(s, 0u, b); let len = vec::len::(elts); @@ -340,12 +340,12 @@ pub fn commasep_cmnt(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN), end(s); } -pub fn commasep_exprs(s: @ps, b: breaks, exprs: ~[@ast::expr]) { +pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) { fn expr_span(&&expr: @ast::expr) -> codemap::span { return expr.span; } commasep_cmnt(s, b, exprs, print_expr, expr_span); } -pub fn print_mod(s: @ps, _mod: ast::_mod, attrs: ~[ast::attribute]) { +pub fn print_mod(s: @ps, _mod: &ast::_mod, attrs: ~[ast::attribute]) { print_inner_attributes(s, attrs); for _mod.view_items.each |vitem| { print_view_item(s, *vitem); @@ -353,7 +353,7 @@ pub fn print_mod(s: @ps, _mod: ast::_mod, attrs: ~[ast::attribute]) { for _mod.items.each |item| { print_item(s, *item); } } -pub fn print_foreign_mod(s: @ps, nmod: ast::foreign_mod, +pub fn print_foreign_mod(s: @ps, nmod: &ast::foreign_mod, attrs: ~[ast::attribute]) { print_inner_attributes(s, attrs); for nmod.view_items.each |vitem| { @@ -376,12 +376,12 @@ pub fn print_type(s: @ps, &&ty: @ast::Ty) { pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) { maybe_print_comment(s, ty.span.lo); ibox(s, 0u); - match /*bad*/ copy ty.node { + match ty.node { ast::ty_nil => word(s.s, ~"()"), ast::ty_bot => word(s.s, ~"!"), - ast::ty_box(mt) => { word(s.s, ~"@"); print_mt(s, mt); } - ast::ty_uniq(mt) => { word(s.s, ~"~"); print_mt(s, mt); } - ast::ty_vec(mt) => { + ast::ty_box(ref mt) => { word(s.s, ~"@"); print_mt(s, mt); } + ast::ty_uniq(ref mt) => { word(s.s, ~"~"); print_mt(s, mt); } + ast::ty_vec(ref mt) => { word(s.s, ~"["); match mt.mutbl { ast::m_mutbl => word_space(s, ~"mut"), @@ -391,15 +391,15 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) { print_type(s, mt.ty); word(s.s, ~"]"); } - ast::ty_ptr(mt) => { word(s.s, ~"*"); print_mt(s, mt); } - ast::ty_rptr(lifetime, mt) => { + ast::ty_ptr(ref mt) => { word(s.s, ~"*"); print_mt(s, mt); } + ast::ty_rptr(lifetime, ref mt) => { word(s.s, ~"&"); print_opt_lifetime(s, lifetime); print_mt(s, mt); } - ast::ty_tup(elts) => { + ast::ty_tup(ref elts) => { popen(s); - commasep(s, inconsistent, elts, print_type); + commasep(s, inconsistent, *elts, print_type); if elts.len() == 1 { word(s.s, ~","); } @@ -416,7 +416,7 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) { None, None); } ast::ty_path(path, _) => print_path(s, path, print_colons), - ast::ty_fixed_length_vec(mt, v) => { + ast::ty_fixed_length_vec(ref mt, v) => { word(s.s, ~"["); match mt.mutbl { ast::m_mutbl => word_space(s, ~"mut"), @@ -443,7 +443,7 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); - match /*bad*/ copy item.node { + match item.node { ast::foreign_item_fn(ref decl, purity, ref generics) => { print_fn(s, decl, Some(purity), item.ident, generics, None, ast::inherited); @@ -469,7 +469,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) { print_outer_attributes(s, item.attrs); let ann_node = node_item(s, item); (s.ann.pre)(ann_node); - match /*bad*/ copy item.node { + match item.node { ast::item_const(ty, expr) => { head(s, visibility_qualified(item.vis, ~"const")); print_ident(s, item.ident); @@ -497,7 +497,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) { word(s.s, ~" "); print_block_with_attrs(s, body, item.attrs); } - ast::item_mod(_mod) => { + ast::item_mod(ref _mod) => { head(s, visibility_qualified(item.vis, ~"mod")); print_ident(s, item.ident); nbsp(s); @@ -505,7 +505,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) { print_mod(s, _mod, item.attrs); bclose(s, item.span); } - ast::item_foreign_mod(nmod) => { + ast::item_foreign_mod(ref nmod) => { head(s, visibility_qualified(item.vis, ~"extern")); print_string(s, *s.intr.get(nmod.abi)); nbsp(s); @@ -767,15 +767,15 @@ pub fn print_tts(s: @ps, &&tts: &[ast::token_tree]) { pub fn print_variant(s: @ps, v: ast::variant) { print_visibility(s, v.node.vis); - match /*bad*/ copy v.node.kind { - ast::tuple_variant_kind(args) => { + match v.node.kind { + ast::tuple_variant_kind(ref args) => { print_ident(s, v.node.name); if !args.is_empty() { popen(s); fn print_variant_arg(s: @ps, arg: ast::variant_arg) { print_type(s, arg.ty); } - commasep(s, consistent, args, print_variant_arg); + commasep(s, consistent, *args, print_variant_arg); pclose(s); } } @@ -1103,7 +1103,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { ibox(s, indent_unit); let ann_node = node_expr(s, expr); (s.ann.pre)(ann_node); - match /*bad*/ copy expr.node { + match expr.node { ast::expr_vstore(e, v) => match v { ast::expr_vstore_fixed(_) => { print_expr(s, e); @@ -1115,14 +1115,14 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { print_expr(s, e); } }, - ast::expr_vec(exprs, mutbl) => { + ast::expr_vec(ref exprs, mutbl) => { ibox(s, indent_unit); word(s.s, ~"["); if mutbl == ast::m_mutbl { word(s.s, ~"mut"); - if vec::len(exprs) > 0u { nbsp(s); } + if exprs.len() > 0u { nbsp(s); } } - commasep_exprs(s, inconsistent, exprs); + commasep_exprs(s, inconsistent, *exprs); word(s.s, ~"]"); end(s); } @@ -1159,29 +1159,29 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { } word(s.s, ~"}"); } - ast::expr_tup(exprs) => { + ast::expr_tup(ref exprs) => { popen(s); - commasep_exprs(s, inconsistent, exprs); + commasep_exprs(s, inconsistent, *exprs); if exprs.len() == 1 { word(s.s, ~","); } pclose(s); } - ast::expr_call(func, args, sugar) => { - let mut base_args = copy args; + ast::expr_call(func, ref args, sugar) => { + let mut base_args = copy *args; let blk = print_call_pre(s, sugar, &mut base_args); print_expr(s, func); print_call_post(s, sugar, &blk, &mut base_args); } - ast::expr_method_call(func, ident, tys, args, sugar) => { - let mut base_args = copy args; + ast::expr_method_call(func, ident, ref tys, ref args, sugar) => { + let mut base_args = copy *args; let blk = print_call_pre(s, sugar, &mut base_args); print_expr(s, func); word(s.s, ~"."); print_ident(s, ident); - if vec::len(tys) > 0u { + if tys.len() > 0u { word(s.s, ~"::<"); - commasep(s, inconsistent, tys, print_type); + commasep(s, inconsistent, *tys, print_type); word(s.s, ~">"); } print_call_post(s, sugar, &blk, &mut base_args); @@ -1356,13 +1356,13 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { word_space(s, ~"="); print_expr(s, rhs); } - ast::expr_field(expr, id, tys) => { + ast::expr_field(expr, id, ref tys) => { print_expr(s, expr); word(s.s, ~"."); print_ident(s, id); - if vec::len(tys) > 0u { + if tys.len() > 0u { word(s.s, ~"::<"); - commasep(s, inconsistent, tys, print_type); + commasep(s, inconsistent, *tys, print_type); word(s.s, ~">"); } } @@ -1454,15 +1454,15 @@ pub fn print_local_decl(s: @ps, loc: @ast::local) { pub fn print_decl(s: @ps, decl: @ast::decl) { maybe_print_comment(s, decl.span.lo); - match /*bad*/ copy decl.node { - ast::decl_local(locs) => { + match decl.node { + ast::decl_local(ref locs) => { space_if_not_bol(s); ibox(s, indent_unit); word_nbsp(s, ~"let"); // if any are mut, all are mut - if vec::any(locs, |l| l.node.is_mutbl) { - fail_unless!(vec::all(locs, |l| l.node.is_mutbl)); + if locs.any(|l| l.node.is_mutbl) { + fail_unless!(locs.all(|l| l.node.is_mutbl)); word_nbsp(s, ~"mut"); } @@ -1479,7 +1479,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) { _ => () } } - commasep(s, consistent, locs, print_local); + commasep(s, consistent, *locs, print_local); end(s); } ast::decl_item(item) => print_item(s, item) @@ -1539,7 +1539,7 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) { (s.ann.pre)(ann_node); /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ - match /*bad*/ copy pat.node { + match pat.node { ast::pat_wild => word(s.s, ~"_"), ast::pat_ident(binding_mode, path, sub) => { if refutable { @@ -1563,14 +1563,14 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) { None => () } } - ast::pat_enum(path, args_) => { + ast::pat_enum(path, ref args_) => { print_path(s, path, true); - match args_ { + match *args_ { None => word(s.s, ~"(*)"), - Some(args) => { + Some(ref args) => { if !args.is_empty() { popen(s); - commasep(s, inconsistent, args, + commasep(s, inconsistent, *args, |s, p| print_pat(s, p, refutable)); pclose(s); } else { } @@ -1851,7 +1851,7 @@ pub fn print_view_path(s: @ps, &&vp: @ast::view_path) { } } -pub fn print_view_paths(s: @ps, vps: ~[@ast::view_path]) { +pub fn print_view_paths(s: @ps, vps: &[@ast::view_path]) { commasep(s, inconsistent, vps, print_view_path); } @@ -1860,7 +1860,7 @@ pub fn print_view_item(s: @ps, item: @ast::view_item) { maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); print_visibility(s, item.vis); - match /*bad*/ copy item.node { + match item.node { ast::view_item_extern_mod(id, mta, _) => { head(s, ~"extern mod"); print_ident(s, id); @@ -1871,9 +1871,9 @@ pub fn print_view_item(s: @ps, item: @ast::view_item) { } } - ast::view_item_use(vps) => { + ast::view_item_use(ref vps) => { head(s, ~"use"); - print_view_paths(s, vps); + print_view_paths(s, *vps); } } word(s.s, ~";"); @@ -1889,7 +1889,7 @@ pub fn print_mutability(s: @ps, mutbl: ast::mutability) { } } -pub fn print_mt(s: @ps, mt: ast::mt) { +pub fn print_mt(s: @ps, mt: &ast::mt) { print_mutability(s, mt.mutbl); print_type(s, mt.ty); } @@ -1942,7 +1942,7 @@ pub fn print_ty_fn(s: @ps, print_onceness(s, onceness); word(s.s, ~"fn"); match id { Some(id) => { word(s.s, ~" "); print_ident(s, id); } _ => () } - match /*bad*/ copy generics { Some(g) => print_generics(s, g), _ => () } + match generics { Some(g) => print_generics(s, g), _ => () } zerobreak(s.s); popen(s);