From 92d39fe4d5e5ad3d2c2dcafe45eaf6e23edddfd7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 12 May 2013 00:25:31 -0400 Subject: syntax: Remove #[allow(vecs_implicitly_copyable)] --- src/libsyntax/ext/asm.rs | 8 +- src/libsyntax/ext/auto_encode.rs | 4 +- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/deriving/clone.rs | 6 +- src/libsyntax/ext/deriving/cmp/ord.rs | 4 +- src/libsyntax/ext/deriving/cmp/totalord.rs | 9 ++- src/libsyntax/ext/deriving/generic.rs | 125 +++++++++++++++-------------- src/libsyntax/ext/deriving/mod.rs | 8 +- src/libsyntax/ext/deriving/ty.rs | 22 ++--- src/libsyntax/ext/fmt.rs | 2 +- src/libsyntax/ext/pipes/proto.rs | 8 +- src/libsyntax/ext/quote.rs | 8 +- src/libsyntax/ext/tt/macro_parser.rs | 41 +++++----- src/libsyntax/ext/tt/macro_rules.rs | 12 +-- src/libsyntax/ext/tt/transcribe.rs | 14 ++-- 15 files changed, 137 insertions(+), 136 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 00c178b6d7c..97c5797cf57 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -119,13 +119,13 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) cons = str::connect(clobs, ","); } Options => { - let option = *p.parse_str(); + let option = p.parse_str(); - if option == ~"volatile" { + if "volatile" == *option { volatile = true; - } else if option == ~"alignstack" { + } else if "alignstack" == *option { alignstack = true; - } else if option == ~"intel" { + } else if "intel" == *option { dialect = ast::asm_intel; } diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 9b78d9954d3..ac86d266d73 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -836,7 +836,7 @@ fn mk_struct_deser_impl( cx: @ext_ctxt, span: span, ident: ast::ident, - fields: ~[@ast::struct_field], + fields: &[@ast::struct_field], generics: &ast::Generics ) -> @ast::item { let fields = do mk_struct_fields(fields).mapi |idx, field| { @@ -1120,7 +1120,7 @@ fn mk_enum_deser_body( ext_cx: @ext_ctxt, span: span, name: ast::ident, - variants: ~[ast::variant] + variants: &[ast::variant] ) -> @ast::expr { let expr_arm_names = build::mk_base_vec_e( ext_cx, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 3f90fd6267b..605ba65b51a 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -509,7 +509,7 @@ pub fn mk_unreachable(cx: @ext_ctxt, span: span) -> @ast::expr { ], ~[ mk_base_str(cx, span, ~"internal error: entered unreachable code"), - mk_base_str(cx, span, loc.file.name), + mk_base_str(cx, span, copy loc.file.name), mk_uint(cx, span, loc.line), ] ) diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 1c33fe35070..2151e9529c4 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -60,11 +60,11 @@ fn cs_clone(cx: @ext_ctxt, span: span, build::mk_method_call(cx, span, field, clone_ident, ~[]); match *substr.fields { - Struct(af) => { + Struct(ref af) => { ctor_ident = ~[ substr.type_ident ]; all_fields = af; } - EnumMatching(_, variant, af) => { + EnumMatching(_, variant, ref af) => { ctor_ident = ~[ variant.node.name ]; all_fields = af; }, @@ -72,7 +72,7 @@ fn cs_clone(cx: @ext_ctxt, span: span, StaticEnum(*) | StaticStruct(*) => cx.span_bug(span, "Static method in `deriving(Clone)`") } - match all_fields { + match *all_fields { [(None, _, _), .. _] => { // enum-like let subcalls = all_fields.map(|&(_, self_f, _)| subcall(self_f)); diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index a9234c858f4..cdb9f620301 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -65,8 +65,6 @@ fn cs_ord(less: bool, equal: bool, let false_blk_expr = build::mk_block(cx, span, ~[], ~[], Some(build::mk_bool(cx, span, false))); - let true_blk = build::mk_simple_block(cx, span, - build::mk_bool(cx, span, true)); let base = build::mk_bool(cx, span, equal); cs_fold( @@ -108,6 +106,8 @@ fn cs_ord(less: bool, equal: bool, let cmp = build::mk_method_call(cx, span, self_f, binop, other_fs.to_owned()); + let true_blk = build::mk_simple_block(cx, span, + build::mk_bool(cx, span, true)); let if_ = expr_if(cmp, true_blk, Some(elseif)); build::mk_expr(cx, span, if_) diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 7d560a197d0..5ec4e028454 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -55,15 +55,16 @@ pub fn ordering_const(cx: @ext_ctxt, span: span, cnst: Ordering) -> @expr { pub fn cs_cmp(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { - let lexical_ord = ~[cx.ident_of("core"), - cx.ident_of("cmp"), - cx.ident_of("lexical_ordering")]; cs_same_method_fold( // foldr (possibly) nests the matches in lexical_ordering better false, |cx, span, old, new| { - build::mk_call_global(cx, span, lexical_ord, ~[old, new]) + build::mk_call_global(cx, span, + ~[cx.ident_of("core"), + cx.ident_of("cmp"), + cx.ident_of("lexical_ordering")], + ~[old, new]) }, ordering_const(cx, span, Equal), |cx, span, list, _| { diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index d785f3816de..be2cc6dd25e 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -259,14 +259,14 @@ pub enum SubstructureFields<'self> { fields: `(field ident, self, [others])`, where the field ident is only non-`None` in the case of a struct variant. */ - EnumMatching(uint, ast::variant, ~[(Option, @expr, ~[@expr])]), + EnumMatching(uint, &'self ast::variant, ~[(Option, @expr, ~[@expr])]), /** non-matching variants of the enum, [(variant index, ast::variant, [field ident, fields])] (i.e. all fields for self are in the first tuple, for other1 are in the second tuple, etc.) */ - EnumNonMatching(~[(uint, ast::variant, ~[(Option, @expr)])]), + EnumNonMatching(&'self [(uint, ast::variant, ~[(Option, @expr)])]), /// A static method where Self is a struct StaticStruct(&'self ast::struct_def, Either), @@ -290,7 +290,7 @@ representing each variant: (variant index, ast::variant instance, */ pub type EnumNonMatchFunc<'self> = &'self fn(@ext_ctxt, span, - ~[(uint, ast::variant, + &[(uint, ast::variant, ~[(Option, @expr)])], &[@expr]) -> @expr; @@ -416,8 +416,9 @@ impl<'self> MethodDef<'self> { let mut nonstatic = false; match self.self_ty { - Some(self_ptr) => { - let (self_expr, self_ty) = ty::get_explicit_self(cx, span, self_ptr); + Some(ref self_ptr) => { + let (self_expr, self_ty) = ty::get_explicit_self(cx, span, + self_ptr); ast_self_ty = self_ty; self_args.push(self_expr); @@ -616,9 +617,10 @@ impl<'self> MethodDef<'self> { self_args: &[@expr], nonself_args: &[@expr]) -> @expr { + let mut matches = ~[]; self.build_enum_match(cx, span, enum_def, type_ident, self_args, nonself_args, - None, ~[], 0) + None, &mut matches, 0) } @@ -650,58 +652,57 @@ impl<'self> MethodDef<'self> { self_args: &[@expr], nonself_args: &[@expr], matching: Option, - matches_so_far: ~[(uint, ast::variant, - ~[(Option, @expr)])], + matches_so_far: &mut ~[(uint, ast::variant, + ~[(Option, @expr)])], match_count: uint) -> @expr { if match_count == self_args.len() { // we've matched against all arguments, so make the final // expression at the bottom of the match tree - match matches_so_far { - [] => cx.span_bug(span, ~"no self match on an enum in generic `deriving`"), - _ => { - // we currently have a vec of vecs, where each - // subvec is the fields of one of the arguments, - // but if the variants all match, we want this as - // vec of tuples, where each tuple represents a - // field. - - let substructure; - - // most arms don't have matching variants, so do a - // quick check to see if they match (even though - // this means iterating twice) instead of being - // optimistic and doing a pile of allocations etc. - match matching { - Some(variant_index) => { - // `ref` inside let matches is buggy. Causes havoc wih rusc. - // let (variant_index, ref self_vec) = matches_so_far[0]; - let (variant, self_vec) = match matches_so_far[0] { - (_, v, ref s) => (v, s) - }; - - let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]); - - for matches_so_far.tail().each |&(_, _, other_fields)| { - for other_fields.eachi |i, &(_, other_field)| { - enum_matching_fields[i].push(other_field); - } - } - let field_tuples = - do vec::map_zip(*self_vec, - enum_matching_fields) |&(id, self_f), &other| { - (id, self_f, other) - }; - substructure = EnumMatching(variant_index, variant, field_tuples); - } - None => { - substructure = EnumNonMatching(matches_so_far); + if matches_so_far.len() == 0 { + cx.span_bug(span, ~"no self match on an enum in generic \ + `deriving`"); + } + // we currently have a vec of vecs, where each + // subvec is the fields of one of the arguments, + // but if the variants all match, we want this as + // vec of tuples, where each tuple represents a + // field. + + let substructure; + + // most arms don't have matching variants, so do a + // quick check to see if they match (even though + // this means iterating twice) instead of being + // optimistic and doing a pile of allocations etc. + match matching { + Some(variant_index) => { + // `ref` inside let matches is buggy. Causes havoc wih rusc. + // let (variant_index, ref self_vec) = matches_so_far[0]; + let (variant, self_vec) = match matches_so_far[0] { + (_, ref v, ref s) => (v, s) + }; + + let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]); + + for matches_so_far.tail().each |&(_, _, other_fields)| { + for other_fields.eachi |i, &(_, other_field)| { + enum_matching_fields[i].push(other_field); } } - self.call_substructure_method(cx, span, type_ident, - self_args, nonself_args, - &substructure) + let field_tuples = + do vec::map_zip(*self_vec, + enum_matching_fields) |&(id, self_f), &other| { + (id, self_f, other) + }; + substructure = EnumMatching(variant_index, variant, field_tuples); + } + None => { + substructure = EnumNonMatching(*matches_so_far); } } + self.call_substructure_method(cx, span, type_ident, + self_args, nonself_args, + &substructure) } else { // there are still matches to create let current_match_str = if match_count == 0 { @@ -712,9 +713,6 @@ impl<'self> MethodDef<'self> { let mut arms = ~[]; - // this is used as a stack - let mut matches_so_far = matches_so_far; - // the code for nonmatching variants only matters when // we've seen at least one other variant already if self.const_nonmatching && match_count > 0 { @@ -732,7 +730,7 @@ impl<'self> MethodDef<'self> { current_match_str, ast::m_imm); - matches_so_far.push((index, *variant, idents)); + matches_so_far.push((index, /*bad*/ copy *variant, idents)); let arm_expr = self.build_enum_match(cx, span, enum_def, type_ident, @@ -744,9 +742,10 @@ impl<'self> MethodDef<'self> { arms.push(build::mk_arm(cx, span, ~[ pattern ], arm_expr)); if enum_def.variants.len() > 1 { + let e = &EnumNonMatching(&[]); let wild_expr = self.call_substructure_method(cx, span, type_ident, self_args, nonself_args, - &EnumNonMatching(~[])); + e); let wild_arm = build::mk_arm(cx, span, ~[ build::mk_pat_wild(cx, span) ], wild_expr); @@ -760,7 +759,7 @@ impl<'self> MethodDef<'self> { current_match_str, ast::m_imm); - matches_so_far.push((index, *variant, idents)); + matches_so_far.push((index, /*bad*/ copy *variant, idents)); let new_matching = match matching { _ if match_count == 0 => Some(index), @@ -850,7 +849,7 @@ pub fn cs_fold(use_foldl: bool, cx: @ext_ctxt, span: span, substructure: &Substructure) -> @expr { match *substructure.fields { - EnumMatching(_, _, all_fields) | Struct(all_fields) => { + EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { if use_foldl { do all_fields.foldl(base) |&old, &(_, self_f, other_fs)| { f(cx, span, old, self_f, other_fs) @@ -861,8 +860,9 @@ pub fn cs_fold(use_foldl: bool, } } }, - EnumNonMatching(all_enums) => enum_nonmatch_f(cx, span, - all_enums, substructure.nonself_args), + EnumNonMatching(ref all_enums) => enum_nonmatch_f(cx, span, + *all_enums, + substructure.nonself_args), StaticEnum(*) | StaticStruct(*) => { cx.span_bug(span, "Static function in `deriving`") } @@ -885,7 +885,7 @@ pub fn cs_same_method(f: &fn(@ext_ctxt, span, ~[@expr]) -> @expr, cx: @ext_ctxt, span: span, substructure: &Substructure) -> @expr { match *substructure.fields { - EnumMatching(_, _, all_fields) | Struct(all_fields) => { + EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { // call self_n.method(other_1_n, other_2_n, ...) let called = do all_fields.map |&(_, self_field, other_fields)| { build::mk_method_call(cx, span, @@ -896,8 +896,9 @@ pub fn cs_same_method(f: &fn(@ext_ctxt, span, ~[@expr]) -> @expr, f(cx, span, called) }, - EnumNonMatching(all_enums) => enum_nonmatch_f(cx, span, - all_enums, substructure.nonself_args), + EnumNonMatching(ref all_enums) => enum_nonmatch_f(cx, span, + *all_enums, + substructure.nonself_args), StaticEnum(*) | StaticStruct(*) => { cx.span_bug(span, "Static function in `deriving`") } diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 3b94a95dfe0..ba1f4e3ebb2 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -59,7 +59,7 @@ pub fn expand_meta_deriving(cx: @ext_ctxt, use ast::{meta_list, meta_name_value, meta_word}; match mitem.node { - meta_name_value(_, l) => { + meta_name_value(_, ref l) => { cx.span_err(l.span, ~"unexpected value in `deriving`"); in_items } @@ -67,7 +67,7 @@ pub fn expand_meta_deriving(cx: @ext_ctxt, cx.span_warn(mitem.span, ~"empty trait list in `deriving`"); in_items } - meta_list(_, titems) => { + meta_list(_, ref titems) => { do titems.foldr(in_items) |&titem, in_items| { match titem.node { meta_name_value(tname, _) | @@ -92,9 +92,9 @@ pub fn expand_meta_deriving(cx: @ext_ctxt, ~"ToStr" => expand!(to_str::expand_deriving_to_str), - tname => { + ref tname => { cx.span_err(titem.span, fmt!("unknown \ - `deriving` trait: `%s`", tname)); + `deriving` trait: `%s`", *tname)); in_items } } diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 0bb88dae26b..768ac7458d6 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -63,7 +63,7 @@ pub impl Path { fn to_path(&self, cx: @ext_ctxt, span: span, self_ty: ident, self_generics: &Generics) -> @ast::Path { let idents = self.path.map(|s| cx.ident_of(*s) ); - let lt = mk_lifetime(cx, span, self.lifetime); + let lt = mk_lifetime(cx, span, &self.lifetime); let tys = self.params.map(|t| t.to_ty(cx, span, self_ty, self_generics)); if self.global { @@ -106,9 +106,9 @@ pub fn nil_ty() -> Ty { Tuple(~[]) } -fn mk_lifetime(cx: @ext_ctxt, span: span, lt: Option<~str>) -> Option<@ast::Lifetime> { - match lt { - Some(s) => Some(@build::mk_lifetime(cx, span, cx.ident_of(s))), +fn mk_lifetime(cx: @ext_ctxt, span: span, lt: &Option<~str>) -> Option<@ast::Lifetime> { + match *lt { + Some(ref s) => Some(@build::mk_lifetime(cx, span, cx.ident_of(*s))), None => None } } @@ -123,10 +123,10 @@ pub impl Ty { Owned => { build::mk_ty_uniq(cx, span, raw_ty) } - Managed(copy mutbl) => { + Managed(mutbl) => { build::mk_ty_box(cx, span, raw_ty, mutbl) } - Borrowed(copy lt, copy mutbl) => { + Borrowed(ref lt, mutbl) => { let lt = mk_lifetime(cx, span, lt); build::mk_ty_rptr(cx, span, raw_ty, lt, mutbl) } @@ -216,20 +216,20 @@ pub impl LifetimeBounds { } -pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: Option) +pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: &Option) -> (@expr, ast::self_ty) { let self_path = build::make_self(cx, span); - match self_ptr { + match *self_ptr { None => { (self_path, respan(span, ast::sty_value)) } - Some(ptr) => { + Some(ref ptr) => { let self_ty = respan( span, - match ptr { + match *ptr { Owned => ast::sty_uniq(ast::m_imm), Managed(mutbl) => ast::sty_box(mutbl), - Borrowed(lt, mutbl) => { + Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| @build::mk_lifetime(cx, span, cx.ident_of(*s))); ast::sty_region(lt, mutbl) diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 1a8edec3714..26b3178a911 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -62,7 +62,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, // 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_flags(cx: @ext_ctxt, sp: span, flags: ~[Flag]) -> @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| { let fstr = match *f { diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 7c78ec066d0..f897eb787e5 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -154,14 +154,14 @@ pub struct protocol_ { pub impl protocol_ { /// Get a state. - fn get_state(&self, name: ~str) -> state { - self.states.find(|i| i.name == name).get() + fn get_state(&self, name: &str) -> state { + self.states.find(|i| name == i.name).get() } fn get_state_by_id(&self, id: uint) -> state { self.states[id] } - fn has_state(&self, name: ~str) -> bool { - self.states.find(|i| i.name == name).is_some() + fn has_state(&self, name: &str) -> bool { + self.states.find(|i| name == i.name).is_some() } fn filename(&self) -> ~str { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index d5b3adca168..f4227cd2f2c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -452,9 +452,9 @@ fn mk_binop(cx: @ext_ctxt, sp: span, bop: token::binop) -> @ast::expr { ids_ext(cx, ~[name.to_owned()])) } -fn mk_token(cx: @ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { +fn mk_token(cx: @ext_ctxt, sp: span, tok: &token::Token) -> @ast::expr { - match tok { + match *tok { BINOP(binop) => { return build::mk_call(cx, sp, ids_ext(cx, ~[~"BINOP"]), @@ -561,7 +561,7 @@ fn mk_token(cx: @ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { _ => () } - let name = match tok { + let name = match *tok { EQ => "EQ", LT => "LT", LE => "LE", @@ -612,7 +612,7 @@ fn mk_tt(cx: @ext_ctxt, sp: span, tt: &ast::token_tree) let e_tok = build::mk_call(cx, sp, ids_ext(cx, ~[~"tt_tok"]), - ~[e_sp, mk_token(cx, sp, *tok)]); + ~[e_sp, mk_token(cx, sp, tok)]); let e_push = build::mk_method_call(cx, sp, build::mk_path(cx, sp, ids_ext(cx, ~[~"tt"])), diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 46b09aca8b2..aa211973f1c 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -130,7 +130,6 @@ pub fn count_names(ms: &[matcher]) -> uint { }}) } -#[allow(non_implicitly_copyable_typarams)] pub fn initial_matcher_pos(ms: ~[matcher], sep: Option, lo: BytePos) -> ~MatcherPos { let mut match_idx_hi = 0u; @@ -184,15 +183,15 @@ pub enum named_match { pub type earley_item = ~MatcherPos; -pub fn nameize(p_s: @mut ParseSess, ms: ~[matcher], res: ~[@named_match]) +pub fn nameize(p_s: @mut ParseSess, ms: &[matcher], res: &[@named_match]) -> HashMap { - fn n_rec(p_s: @mut ParseSess, m: matcher, res: ~[@named_match], + fn n_rec(p_s: @mut ParseSess, m: &matcher, res: &[@named_match], ret_val: &mut HashMap) { - match m { + match *m { codemap::spanned {node: match_tok(_), _} => (), codemap::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => { - for (*more_ms).each() |next_m| { - n_rec(p_s, *next_m, res, ret_val) + for more_ms.each |next_m| { + n_rec(p_s, next_m, res, ret_val) }; } codemap::spanned { @@ -207,7 +206,7 @@ pub fn nameize(p_s: @mut ParseSess, ms: ~[matcher], res: ~[@named_match]) } } let mut ret_val = HashMap::new(); - for ms.each() |m| { n_rec(p_s, *m, res, &mut ret_val) } + for ms.each |m| { n_rec(p_s, m, res, &mut ret_val) } return ret_val; } @@ -234,10 +233,10 @@ pub fn parse( sess: @mut ParseSess, cfg: ast::crate_cfg, rdr: @reader, - ms: ~[matcher] + ms: &[matcher] ) -> parse_result { let mut cur_eis = ~[]; - cur_eis.push(initial_matcher_pos(copy ms, None, rdr.peek().sp.lo)); + cur_eis.push(initial_matcher_pos(ms.to_owned(), None, rdr.peek().sp.lo)); loop { let mut bb_eis = ~[]; // black-box parsed by parser.rs @@ -277,7 +276,7 @@ pub fn parse( // Only touch the binders we have actually bound for uint::range(ei.match_lo, ei.match_hi) |idx| { - let sub = ei.matches[idx]; + let sub = copy ei.matches[idx]; new_pos.matches[idx] .push(@matched_seq(sub, mk_sp(ei.sp_lo, @@ -410,31 +409,31 @@ pub fn parse( } } -pub fn parse_nt(p: &Parser, name: ~str) -> nonterminal { +pub fn parse_nt(p: &Parser, name: &str) -> nonterminal { match name { - ~"item" => match p.parse_item(~[]) { + "item" => match p.parse_item(~[]) { Some(i) => token::nt_item(i), None => p.fatal(~"expected an item keyword") }, - ~"block" => token::nt_block(p.parse_block()), - ~"stmt" => token::nt_stmt(p.parse_stmt(~[])), - ~"pat" => token::nt_pat(p.parse_pat(true)), - ~"expr" => token::nt_expr(p.parse_expr()), - ~"ty" => token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)), + "block" => token::nt_block(p.parse_block()), + "stmt" => token::nt_stmt(p.parse_stmt(~[])), + "pat" => token::nt_pat(p.parse_pat(true)), + "expr" => token::nt_expr(p.parse_expr()), + "ty" => token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)), // this could be handled like a token, since it is one - ~"ident" => match *p.token { + "ident" => match *p.token { token::IDENT(sn,b) => { p.bump(); token::nt_ident(sn,b) } _ => p.fatal(~"expected ident, found " + token::to_str(p.reader.interner(), © *p.token)) }, - ~"path" => token::nt_path(p.parse_path_with_tps(false)), - ~"tt" => { + "path" => token::nt_path(p.parse_path_with_tps(false)), + "tt" => { *p.quote_depth += 1u; //but in theory, non-quoted tts might be useful let res = token::nt_tt(@p.parse_token_tree()); *p.quote_depth -= 1u; res } - ~"matchers" => token::nt_matchers(p.parse_matchers()), + "matchers" => token::nt_matchers(p.parse_matchers()), _ => p.fatal(~"Unsupported builtin nonterminal parser: " + name) } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 169652b1120..be6cc7a846a 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -63,19 +63,19 @@ pub fn add_new_extension(cx: @ext_ctxt, // Extract the arguments: let lhses = match *argument_map.get(&lhs_nm) { - @matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s, + @matched_seq(ref s, _) => /* FIXME (#2543) */ @copy *s, _ => cx.span_bug(sp, ~"wrong-structured lhs") }; let rhses = match *argument_map.get(&rhs_nm) { - @matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s, + @matched_seq(ref s, _) => /* FIXME (#2543) */ @copy *s, _ => cx.span_bug(sp, ~"wrong-structured rhs") }; // Given `lhses` and `rhses`, this is the new macro we create fn generic_extension(cx: @ext_ctxt, sp: span, name: ident, arg: &[ast::token_tree], - lhses: ~[@named_match], rhses: ~[@named_match]) + lhses: &[@named_match], rhses: &[@named_match]) -> MacResult { if cx.trace_macros() { @@ -93,7 +93,7 @@ pub fn add_new_extension(cx: @ext_ctxt, let s_d = cx.parse_sess().span_diagnostic; let itr = cx.parse_sess().interner; - for lhses.eachi() |i, lhs| { // try each arm's matchers + for lhses.eachi |i, lhs| { // try each arm's matchers match *lhs { @matched_nonterminal(nt_matchers(ref mtcs)) => { // `none` is because we're not interpolating @@ -103,7 +103,7 @@ pub fn add_new_extension(cx: @ext_ctxt, None, vec::to_owned(arg) ) as @reader; - match parse(cx.parse_sess(), cx.cfg(), arg_rdr, (*mtcs)) { + match parse(cx.parse_sess(), cx.cfg(), arg_rdr, *mtcs) { success(named_matches) => { let rhs = match rhses[i] { // okay, what's your transcriber? @@ -146,7 +146,7 @@ pub fn add_new_extension(cx: @ext_ctxt, } let exp: @fn(@ext_ctxt, span, &[ast::token_tree]) -> MacResult = - |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{ name: copy *cx.parse_sess().interner.get(name), diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 19c83e21a86..438efb2326c 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -91,11 +91,11 @@ pub fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader { sp_diag: r.sp_diag, interner: r.interner, stack: dup_tt_frame(r.stack), - interpolations: r.interpolations, repeat_idx: copy r.repeat_idx, repeat_len: copy r.repeat_len, cur_tok: copy r.cur_tok, - cur_span: r.cur_span + cur_span: r.cur_span, + interpolations: copy r.interpolations, } } @@ -127,7 +127,7 @@ enum lis { lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str) } -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 { match lhs { lis_unconstrained => copy rhs, @@ -146,10 +146,10 @@ fn lockstep_iter_size(t: token_tree, r: &mut TtReader) -> lis { } } } - match t { + match *t { tt_delim(ref tts) | tt_seq(_, ref tts, _, _) => { - vec::foldl(lis_unconstrained, (*tts), |lis, tt| { - let lis2 = lockstep_iter_size(*tt, r); + vec::foldl(lis_unconstrained, *tts, |lis, tt| { + let lis2 = lockstep_iter_size(tt, r); lis_merge(lis, lis2, r) }) } @@ -230,7 +230,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { } tt_seq(sp, copy tts, copy sep, zerok) => { let t = tt_seq(sp, copy tts, copy sep, zerok); - match lockstep_iter_size(t, r) { + match lockstep_iter_size(&t, r) { lis_unconstrained => { r.sp_diag.span_fatal( sp, /* blame macro writer */ -- cgit 1.4.1-3-g733a5