diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-01-31 12:20:46 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-02-02 13:40:18 -0500 |
| commit | d5d7e6565a4034b93d19be1edafd20730a4276bc (patch) | |
| tree | f978751c20a214c9fe0cd2d60645a4e1a3b760fd /src/libsyntax | |
| parent | 9f90d666e0cd9a73ef35b76b6605f9d1f69df849 (diff) | |
| download | rust-d5d7e6565a4034b93d19be1edafd20730a4276bc.tar.gz rust-d5d7e6565a4034b93d19be1edafd20730a4276bc.zip | |
`for x in xs.iter()` -> `for x in &xs`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/hash.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/primitive.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 82 | ||||
| -rw-r--r-- | src/libsyntax/util/interner.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 100 |
21 files changed, 138 insertions, 138 deletions
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 8546e03cc87..5535e5911e0 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -730,7 +730,7 @@ impl<'ast> NodeCollector<'ast> { } fn visit_fn_decl(&mut self, decl: &'ast FnDecl) { - for a in decl.inputs.iter() { + for a in &decl.inputs { self.insert(a.id, NodeArg(&*a.pat)); } } @@ -743,7 +743,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { self.parent = i.id; match i.node { ItemImpl(_, _, _, _, _, ref impl_items) => { - for impl_item in impl_items.iter() { + for impl_item in impl_items { match *impl_item { MethodImplItem(ref m) => { self.insert(m.id, NodeImplItem(impl_item)); @@ -755,12 +755,12 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { } } ItemEnum(ref enum_definition, _) => { - for v in enum_definition.variants.iter() { + for v in &enum_definition.variants { self.insert(v.node.id, NodeVariant(&**v)); } } ItemForeignMod(ref nm) => { - for nitem in nm.items.iter() { + for nitem in &nm.items { self.insert(nitem.id, NodeForeignItem(&**nitem)); } } @@ -774,13 +774,13 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { } } ItemTrait(_, _, ref bounds, ref trait_items) => { - for b in bounds.iter() { + for b in &**bounds { if let TraitTyParamBound(ref t, TraitBoundModifier::None) = *b { self.insert(t.trait_ref.ref_id, NodeItem(i)); } } - for tm in trait_items.iter() { + for tm in trait_items { match *tm { RequiredMethod(ref m) => { self.insert(m.id, NodeTraitItem(tm)); diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 7f1264ac9a1..8fc9012829b 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -302,7 +302,7 @@ pub fn split_trait_methods(trait_methods: &[TraitItem]) -> (Vec<TypeMethod>, Vec<P<Method>> ) { let mut reqd = Vec::new(); let mut provd = Vec::new(); - for trt_method in trait_methods.iter() { + for trt_method in trait_methods { match *trt_method { RequiredMethod(ref tm) => reqd.push((*tm).clone()), ProvidedMethod(ref m) => provd.push((*m).clone()), @@ -391,10 +391,10 @@ pub struct IdVisitor<'a, O:'a> { impl<'a, O: IdVisitingOperation> IdVisitor<'a, O> { fn visit_generics_helper(&mut self, generics: &Generics) { - for type_parameter in generics.ty_params.iter() { + for type_parameter in &*generics.ty_params { self.operation.visit_id(type_parameter.id) } - for lifetime in generics.lifetimes.iter() { + for lifetime in &generics.lifetimes { self.operation.visit_id(lifetime.lifetime.id) } } @@ -430,14 +430,14 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> { ViewPathSimple(_, _) | ViewPathGlob(_) => {} ViewPathList(_, ref paths) => { - for path in paths.iter() { + for path in paths { self.operation.visit_id(path.node.id()) } } } } ItemEnum(ref enum_definition, _) => { - for variant in enum_definition.variants.iter() { + for variant in &enum_definition.variants { self.operation.visit_id(variant.node.id) } } @@ -511,7 +511,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> { visit::FkFnBlock => {} } - for argument in function_declaration.inputs.iter() { + for argument in &function_declaration.inputs { self.operation.visit_id(argument.id) } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 4427a7aaf02..61ddd240abc 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -394,7 +394,7 @@ fn find_stability_generic<'a, let mut feature = None; let mut since = None; let mut reason = None; - for meta in metas.iter() { + for meta in metas { if meta.name().get() == "feature" { match meta.value_str() { Some(v) => feature = Some(v), @@ -496,7 +496,7 @@ pub fn find_stability(diagnostic: &SpanHandler, attrs: &[Attribute], pub fn require_unique_names(diagnostic: &SpanHandler, metas: &[P<MetaItem>]) { let mut set = HashSet::new(); - for meta in metas.iter() { + for meta in metas { let name = meta.name(); if !set.insert(name.clone()) { @@ -518,7 +518,7 @@ pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAt match attr.node.value.node { ast::MetaList(ref s, ref items) if *s == "repr" => { mark_used(attr); - for item in items.iter() { + for item in items { match item.node { ast::MetaWord(ref word) => { let hint = match word.get() { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 8adb9b24222..bd7a7783580 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -453,7 +453,7 @@ impl CodeMap { } pub fn get_filemap(&self, filename: &str) -> Rc<FileMap> { - for fm in self.files.borrow().iter() { + for fm in &*self.files.borrow() { if filename == fm.name { return fm.clone(); } @@ -477,7 +477,7 @@ impl CodeMap { // The number of extra bytes due to multibyte chars in the FileMap let mut total_extra_bytes = 0; - for mbc in map.multibyte_chars.borrow().iter() { + for mbc in &*map.multibyte_chars.borrow() { debug!("{}-byte char at {:?}", mbc.bytes, mbc.pos); if mbc.pos < bpos { // every character is at least one byte, so we only diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 821ac8e2f89..19c4c3cabfc 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -461,7 +461,7 @@ fn highlight_lines(err: &mut EmitterWriter, elided = true; } // Print the offending lines - for &line_number in display_lines.iter() { + for &line_number in display_lines { if let Some(line) = fm.get_line(line_number) { try!(write!(&mut err.dst, "{}:{} {}\n", fm.name, line_number + 1, line)); @@ -550,7 +550,7 @@ fn custom_highlight_lines(w: &mut EmitterWriter, last_line_number + 1, last_line)); } } else { - for &line_number in lines.iter() { + for &line_number in lines { if let Some(line) = fm.get_line(line_number) { try!(write!(&mut w.dst, "{}:{} {}\n", fm.name, line_number + 1, line)); diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 1b84d93738d..39c67c60511 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -427,7 +427,7 @@ impl<'a> TraitDef<'a> { bounds.push(cx.typarambound(trait_path.clone())); // also add in any bounds from the declaration - for declared_bound in ty_param.bounds.iter() { + for declared_bound in &*ty_param.bounds { bounds.push((*declared_bound).clone()); } @@ -974,7 +974,7 @@ impl<'a> MethodDef<'a> { subpats.push(p); idents }; - for self_arg_name in self_arg_names.tail().iter() { + for self_arg_name in self_arg_names.tail() { let (p, idents) = mk_self_pat(cx, &self_arg_name[]); subpats.push(p); self_pats_idents.push(idents); diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index e7f546b2691..efd93226618 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -100,7 +100,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) _ => cx.span_bug(trait_span, "impossible substructure in `derive(Hash)`") }; - for &FieldInfo { ref self_, span, .. } in fields.iter() { + for &FieldInfo { ref self_, span, .. } in fields { stmts.push(call_hash(span, self_.clone())); } diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index c694b054ba3..ae7b20f7853 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -93,7 +93,7 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure let mut arms = Vec::new(); - for variant in enum_def.variants.iter() { + for variant in &enum_def.variants { match variant.node.kind { ast::TupleVariantKind(ref args) => { if !args.is_empty() { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 5736400313e..8b4816f5d2b 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -504,7 +504,7 @@ fn expand_item_modifiers(mut it: P<ast::Item>, fld: &mut MacroExpander) return it.expect_item(); } - for attr in modifiers.iter() { + for attr in &modifiers { let mname = attr.name(); match fld.cx.syntax_env.find(&intern(mname.get())) { @@ -552,7 +552,7 @@ fn expand_item_underscore(item: ast::Item_, fld: &mut MacroExpander) -> ast::Ite // does this attribute list contain "macro_use" ? fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool { - for attr in attrs.iter() { + for attr in attrs { let mut is_use = attr.check_name("macro_use"); if attr.check_name("macro_escape") { fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use"); @@ -853,7 +853,7 @@ impl<'v> Visitor<'v> for PatIdentFinder { ast::Pat { id: _, node: ast::PatIdent(_, ref path1, ref inner), span: _ } => { self.ident_accumulator.push(path1.node); // visit optional subpattern of PatIdent: - for subpat in inner.iter() { + if let Some(ref subpat) = *inner { self.visit_pat(&**subpat) } } @@ -873,7 +873,7 @@ fn pattern_bindings(pat: &ast::Pat) -> Vec<ast::Ident> { /// find the PatIdent paths in a fn fn_decl_arg_bindings(fn_decl: &ast::FnDecl) -> Vec<ast::Ident> { let mut pat_idents = PatIdentFinder{ident_accumulator:Vec::new()}; - for arg in fn_decl.inputs.iter() { + for arg in &fn_decl.inputs { pat_idents.visit_pat(&*arg.pat); } pat_idents.ident_accumulator @@ -1063,7 +1063,7 @@ fn expand_annotatable(a: Annotatable, let mut decorator_items = SmallVector::zero(); let mut new_attrs = Vec::new(); - for attr in a.attrs().iter() { + for attr in a.attrs() { let mname = attr.name(); match fld.cx.syntax_env.find(&intern(mname.get())) { @@ -1218,7 +1218,7 @@ fn expand_item_multi_modifier(mut it: Annotatable, return it } - for attr in modifiers.iter() { + for attr in &modifiers { let mname = attr.name(); match fld.cx.syntax_env.find(&intern(mname.get())) { diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 36dbf117604..16aaccb0207 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -499,7 +499,7 @@ impl<'a, 'b> Context<'a, 'b> { self.ecx.expr_ident(e.span, name))); heads.push(self.ecx.expr_addr_of(e.span, e)); } - for name in self.name_ordering.iter() { + for name in &self.name_ordering { let e = match self.names.remove(name) { Some(e) => e, None => continue @@ -706,7 +706,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, cx.ecx.span_err(cx.args[i].span, "argument never used"); } } - for (name, e) in cx.names.iter() { + for (name, e) in &cx.names { if !cx.name_types.contains_key(name) { cx.ecx.span_err(e.span, "named argument never used"); } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 0f617302c92..e9c6629be3c 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -694,7 +694,7 @@ fn mk_tt(cx: &ExtCtxt, tt: &ast::TokenTree) -> Vec<P<ast::Stmt>> { fn mk_tts(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> Vec<P<ast::Stmt>> { let mut ss = Vec::new(); - for tt in tts.iter() { + for tt in tts { ss.extend(mk_tt(cx, tt).into_iter()); } ss diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index e3211c7c337..ac4a149a3ed 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -209,12 +209,12 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>]) ret_val: &mut HashMap<Ident, Rc<NamedMatch>>, idx: &mut usize) { match m { &TtSequence(_, ref seq) => { - for next_m in seq.tts.iter() { + for next_m in &seq.tts { n_rec(p_s, next_m, res, ret_val, idx) } } &TtDelimited(_, ref delim) => { - for next_m in delim.tts.iter() { + for next_m in &delim.tts { n_rec(p_s, next_m, res, ret_val, idx) } } @@ -239,7 +239,7 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>]) } let mut ret_val = HashMap::new(); let mut idx = 0us; - for m in ms.iter() { n_rec(p_s, m, res, &mut ret_val, &mut idx) } + for m in ms { n_rec(p_s, m, res, &mut ret_val, &mut idx) } ret_val } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 666281ac6b6..ac9f375e0a4 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -259,7 +259,7 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt, _ => cx.span_bug(def.span, "wrong-structured lhs") }; - for lhs in lhses.iter() { + for lhs in &lhses { check_lhs_nt_follows(cx, &**lhs, def.span); } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 775cfede70d..4e76359e930 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -253,7 +253,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { } fn visit_item(&mut self, i: &ast::Item) { - for attr in i.attrs.iter() { + for attr in &i.attrs { if attr.name() == "thread_local" { self.gate_feature("thread_local", i.span, "`#[thread_local]` is an experimental feature, and does not \ @@ -508,7 +508,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C let mut unknown_features = Vec::new(); - for attr in krate.attrs.iter() { + for attr in &krate.attrs { if !attr.check_name("feature") { continue } @@ -519,7 +519,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C expected #![feature(...)]"); } Some(list) => { - for mi in list.iter() { + for mi in list { let name = match mi.node { ast::MetaWord(ref word) => (*word).clone(), _ => { diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 926385ccd11..7269afcaea4 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -90,7 +90,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { let mut i = usize::MAX; let mut can_trim = true; let mut first = true; - for line in lines.iter() { + for line in &lines { for (j, c) in line.chars().enumerate() { if j > i || !"* \t".contains_char(c) { can_trim = false; @@ -125,7 +125,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { // one-line comments lose their prefix static ONLINERS: &'static [&'static str] = &["///!", "///", "//!", "//"]; - for prefix in ONLINERS.iter() { + for prefix in ONLINERS { if comment.starts_with(*prefix) { return (&comment[prefix.len()..]).to_string(); } diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 2cf6058a433..ca6193508fe 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1526,7 +1526,7 @@ mod test { // check that the given reader produces the desired stream // of tokens (stop checking after exhausting the expected vec) fn check_tokenization (mut string_reader: StringReader, expected: Vec<token::Token> ) { - for expected_tok in expected.iter() { + for expected_tok in &expected { assert_eq!(&string_reader.next_token().tok, expected_tok); } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 8ac5b6e5274..81803d6bd89 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -1163,7 +1163,7 @@ mod test { "impl z { fn a (self: Foo, &myarg: i32) {} }", ]; - for &src in srcs.iter() { + for &src in &srcs { let spans = get_spans_of_pat_idents(src); let Span{ lo, hi, .. } = spans[0]; assert!("self" == &src[lo.to_usize()..hi.to_usize()], diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d99095eeba3..b7960d9e709 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2706,7 +2706,7 @@ impl<'a> Parser<'a> { match self.token { token::Eof => { let open_braces = self.open_braces.clone(); - for sp in open_braces.iter() { + for sp in &open_braces { self.span_help(*sp, "did you mean to close this delimiter?"); } // There shouldn't really be a span, but it's easier for the test runner @@ -5200,7 +5200,7 @@ impl<'a> Parser<'a> { Some(i) => { let mut err = String::from_str("circular modules: "); let len = included_mod_stack.len(); - for p in included_mod_stack[i.. len].iter() { + for p in &included_mod_stack[i.. len] { err.push_str(&p.display().as_cow()[]); err.push_str(" -> "); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5367ccc1357..21cd02b3851 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -593,7 +593,7 @@ impl<'a> State<'a> { { try!(self.rbox(0us, b)); let mut first = true; - for elt in elts.iter() { + for elt in elts { if first { first = false; } else { try!(self.word_space(",")); } try!(op(self, elt)); } @@ -612,7 +612,7 @@ impl<'a> State<'a> { try!(self.rbox(0us, b)); let len = elts.len(); let mut i = 0us; - for elt in elts.iter() { + for elt in elts { try!(self.maybe_print_comment(get_span(elt).hi)); try!(op(self, elt)); i += 1us; @@ -634,7 +634,7 @@ impl<'a> State<'a> { pub fn print_mod(&mut self, _mod: &ast::Mod, attrs: &[ast::Attribute]) -> IoResult<()> { try!(self.print_inner_attributes(attrs)); - for item in _mod.items.iter() { + for item in &_mod.items { try!(self.print_item(&**item)); } Ok(()) @@ -643,7 +643,7 @@ impl<'a> State<'a> { pub fn print_foreign_mod(&mut self, nmod: &ast::ForeignMod, attrs: &[ast::Attribute]) -> IoResult<()> { try!(self.print_inner_attributes(attrs)); - for item in nmod.items.iter() { + for item in &nmod.items { try!(self.print_foreign_item(&**item)); } Ok(()) @@ -651,8 +651,8 @@ impl<'a> State<'a> { pub fn print_opt_lifetime(&mut self, lifetime: &Option<ast::Lifetime>) -> IoResult<()> { - for l in lifetime.iter() { - try!(self.print_lifetime(l)); + if let Some(l) = *lifetime { + try!(self.print_lifetime(&l)); try!(self.nbsp()); } Ok(()) @@ -799,7 +799,7 @@ impl<'a> State<'a> { ast::ItemExternCrate(ref optional_path) => { try!(self.head(&visibility_qualified(item.vis, "extern crate")[])); - for &(ref p, style) in optional_path.iter() { + if let Some((ref p, style)) = *optional_path { try!(self.print_string(p.get(), style)); try!(space(&mut self.s)); try!(word(&mut self.s, "as")); @@ -945,7 +945,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.bopen()); try!(self.print_inner_attributes(&item.attrs[])); - for impl_item in impl_items.iter() { + for impl_item in impl_items { match *impl_item { ast::MethodImplItem(ref meth) => { try!(self.print_method(&**meth)); @@ -979,7 +979,7 @@ impl<'a> State<'a> { try!(self.print_where_clause(generics)); try!(word(&mut self.s, " ")); try!(self.bopen()); - for meth in methods.iter() { + for meth in methods { try!(self.print_trait_method(meth)); } try!(self.bclose(item.span)); @@ -1010,7 +1010,7 @@ impl<'a> State<'a> { if !t.bound_lifetimes.is_empty() { try!(word(&mut self.s, "for<")); let mut comma = false; - for lifetime_def in t.bound_lifetimes.iter() { + for lifetime_def in &t.bound_lifetimes { if comma { try!(self.word_space(",")) } @@ -1039,7 +1039,7 @@ impl<'a> State<'a> { variants: &[P<ast::Variant>], span: codemap::Span) -> IoResult<()> { try!(self.bopen()); - for v in variants.iter() { + for v in variants { try!(self.space_if_not_bol()); try!(self.maybe_print_comment(v.span.lo)); try!(self.print_outer_attributes(&v.node.attrs[])); @@ -1094,7 +1094,7 @@ impl<'a> State<'a> { try!(self.bopen()); try!(self.hardbreak_if_not_bol()); - for field in struct_def.fields.iter() { + for field in &struct_def.fields { match field.node.kind { ast::UnnamedField(..) => panic!("unexpected unnamed field"), ast::NamedField(ident, visibility) => { @@ -1141,7 +1141,7 @@ impl<'a> State<'a> { }, ast::TtSequence(_, ref seq) => { try!(word(&mut self.s, "$(")); - for tt_elt in seq.tts.iter() { + for tt_elt in &seq.tts { try!(self.print_tt(tt_elt)); } try!(word(&mut self.s, ")")); @@ -1278,7 +1278,7 @@ impl<'a> State<'a> { pub fn print_outer_attributes(&mut self, attrs: &[ast::Attribute]) -> IoResult<()> { let mut count = 0us; - for attr in attrs.iter() { + for attr in attrs { match attr.node.style { ast::AttrOuter => { try!(self.print_attribute(attr)); @@ -1296,7 +1296,7 @@ impl<'a> State<'a> { pub fn print_inner_attributes(&mut self, attrs: &[ast::Attribute]) -> IoResult<()> { let mut count = 0us; - for attr in attrs.iter() { + for attr in attrs { match attr.node.style { ast::AttrInner => { try!(self.print_attribute(attr)); @@ -1395,7 +1395,7 @@ impl<'a> State<'a> { try!(self.print_inner_attributes(attrs)); - for st in blk.stmts.iter() { + for st in &blk.stmts { try!(self.print_stmt(&**st)); } match blk.expr { @@ -1691,8 +1691,8 @@ impl<'a> State<'a> { try!(self.print_if_let(&**pat, &**expr, &** blk, elseopt.as_ref().map(|e| &**e))); } ast::ExprWhile(ref test, ref blk, opt_ident) => { - for ident in opt_ident.iter() { - try!(self.print_ident(*ident)); + if let Some(ident) = opt_ident { + try!(self.print_ident(ident)); try!(self.word_space(":")); } try!(self.head("while")); @@ -1701,8 +1701,8 @@ impl<'a> State<'a> { try!(self.print_block(&**blk)); } ast::ExprWhileLet(ref pat, ref expr, ref blk, opt_ident) => { - for ident in opt_ident.iter() { - try!(self.print_ident(*ident)); + if let Some(ident) = opt_ident { + try!(self.print_ident(ident)); try!(self.word_space(":")); } try!(self.head("while let")); @@ -1714,8 +1714,8 @@ impl<'a> State<'a> { try!(self.print_block(&**blk)); } ast::ExprForLoop(ref pat, ref iter, ref blk, opt_ident) => { - for ident in opt_ident.iter() { - try!(self.print_ident(*ident)); + if let Some(ident) = opt_ident { + try!(self.print_ident(ident)); try!(self.word_space(":")); } try!(self.head("for")); @@ -1727,8 +1727,8 @@ impl<'a> State<'a> { try!(self.print_block(&**blk)); } ast::ExprLoop(ref blk, opt_ident) => { - for ident in opt_ident.iter() { - try!(self.print_ident(*ident)); + if let Some(ident) = opt_ident { + try!(self.print_ident(ident)); try!(self.word_space(":")); } try!(self.head("loop")); @@ -1742,7 +1742,7 @@ impl<'a> State<'a> { try!(self.print_expr(&**expr)); try!(space(&mut self.s)); try!(self.bopen()); - for arm in arms.iter() { + for arm in arms { try!(self.print_arm(arm)); } try!(self.bclose_(expr.span, indent_unit)); @@ -1825,16 +1825,16 @@ impl<'a> State<'a> { ast::ExprBreak(opt_ident) => { try!(word(&mut self.s, "break")); try!(space(&mut self.s)); - for ident in opt_ident.iter() { - try!(self.print_ident(*ident)); + if let Some(ident) = opt_ident { + try!(self.print_ident(ident)); try!(space(&mut self.s)); } } ast::ExprAgain(opt_ident) => { try!(word(&mut self.s, "continue")); try!(space(&mut self.s)); - for ident in opt_ident.iter() { - try!(self.print_ident(*ident)); + if let Some(ident) = opt_ident { + try!(self.print_ident(ident)); try!(space(&mut self.s)) } } @@ -1991,7 +1991,7 @@ impl<'a> State<'a> { } let mut first = true; - for segment in path.segments.iter() { + for segment in &path.segments { if first { first = false } else { @@ -2040,7 +2040,7 @@ impl<'a> State<'a> { try!(word(&mut self.s, "<")); let mut comma = false; - for lifetime in data.lifetimes.iter() { + for lifetime in &data.lifetimes { if comma { try!(self.word_space(",")) } @@ -2059,7 +2059,7 @@ impl<'a> State<'a> { comma = true; } - for binding in data.bindings.iter() { + for binding in &*data.bindings { if comma { try!(self.word_space(",")) } @@ -2193,7 +2193,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, &before[], |s, p| s.print_pat(&**p))); - for p in slice.iter() { + if let Some(ref p) = *slice { if !before.is_empty() { try!(self.word_space(",")); } try!(self.print_pat(&**p)); match **p { @@ -2224,7 +2224,7 @@ impl<'a> State<'a> { try!(self.ibox(0us)); try!(self.print_outer_attributes(&arm.attrs[])); let mut first = true; - for p in arm.pats.iter() { + for p in &arm.pats { if first { first = false; } else { @@ -2309,7 +2309,7 @@ impl<'a> State<'a> { // self type and the args all in the same box. try!(self.rbox(0us, Inconsistent)); let mut first = true; - for &explicit_self in opt_explicit_self.iter() { + if let Some(explicit_self) = opt_explicit_self { let m = match explicit_self { &ast::SelfStatic => ast::MutImmutable, _ => match decl.inputs[0].pat.node { @@ -2327,7 +2327,7 @@ impl<'a> State<'a> { &decl.inputs[1..] }; - for arg in args.iter() { + for arg in args { if first { first = false; } else { try!(self.word_space(",")); } try!(self.print_arg(arg)); } @@ -2397,7 +2397,7 @@ impl<'a> State<'a> { if !bounds.is_empty() { try!(word(&mut self.s, prefix)); let mut first = true; - for bound in bounds.iter() { + for bound in bounds { try!(self.nbsp()); if first { first = false; @@ -2437,7 +2437,7 @@ impl<'a> State<'a> { { try!(self.print_lifetime(&lifetime.lifetime)); let mut sep = ":"; - for v in lifetime.bounds.iter() { + for v in &lifetime.bounds { try!(word(&mut self.s, sep)); try!(self.print_lifetime(v)); sep = "+"; @@ -2792,7 +2792,7 @@ impl<'a> State<'a> { } ast::LitBinary(ref v) => { let mut escaped: String = String::new(); - for &ch in v.iter() { + for &ch in &**v { ascii::escape_default(ch as u8, |ch| escaped.push(ch as char)); } @@ -2842,7 +2842,7 @@ impl<'a> State<'a> { } comments::Isolated => { try!(self.hardbreak_if_not_bol()); - for line in cmnt.lines.iter() { + for line in &cmnt.lines { // Don't print empty lines because they will end up as trailing // whitespace if !line.is_empty() { @@ -2859,7 +2859,7 @@ impl<'a> State<'a> { hardbreak(&mut self.s) } else { try!(self.ibox(0us)); - for line in cmnt.lines.iter() { + for line in &cmnt.lines { if !line.is_empty() { try!(word(&mut self.s, &line[])); } diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 1b35b1b04a3..51144267519 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -40,7 +40,7 @@ impl<T: Eq + Hash<Hasher> + Clone + 'static> Interner<T> { pub fn prefill(init: &[T]) -> Interner<T> { let rv = Interner::new(); - for v in init.iter() { + for v in init { rv.intern((*v).clone()); } rv @@ -158,7 +158,7 @@ impl StrInterner { pub fn prefill(init: &[&str]) -> StrInterner { let rv = StrInterner::new(); - for &v in init.iter() { rv.intern(v); } + for &v in init { rv.intern(v); } rv } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index eb906788aa7..bd84306fe17 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -159,13 +159,13 @@ pub fn walk_inlined_item<'v,V>(visitor: &mut V, item: &'v InlinedItem) pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate) { visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID); - for attr in krate.attrs.iter() { + for attr in &krate.attrs { visitor.visit_attribute(attr); } } pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod) { - for item in module.items.iter() { + for item in &module.items { visitor.visit_item(&**item) } } @@ -179,7 +179,7 @@ pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) { pub fn walk_lifetime_def<'v, V: Visitor<'v>>(visitor: &mut V, lifetime_def: &'v LifetimeDef) { visitor.visit_name(lifetime_def.lifetime.span, lifetime_def.lifetime.name); - for bound in lifetime_def.bounds.iter() { + for bound in &lifetime_def.bounds { visitor.visit_lifetime_bound(bound); } } @@ -239,7 +239,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_path(path, item.id); } ViewPathList(ref prefix, ref list) => { - for id in list.iter() { + for id in list { match id.node { PathListIdent { name, .. } => { visitor.visit_ident(id.span, name); @@ -270,7 +270,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_mod(module, item.span, item.id) } ItemForeignMod(ref foreign_module) => { - for foreign_item in foreign_module.items.iter() { + for foreign_item in &foreign_module.items { visitor.visit_foreign_item(&**foreign_item) } } @@ -293,7 +293,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { None => () } visitor.visit_ty(&**typ); - for impl_item in impl_items.iter() { + for impl_item in impl_items { match *impl_item { MethodImplItem(ref method) => { walk_method_helper(visitor, &**method) @@ -315,13 +315,13 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { ItemTrait(_, ref generics, ref bounds, ref methods) => { visitor.visit_generics(generics); walk_ty_param_bounds_helper(visitor, bounds); - for method in methods.iter() { + for method in methods { visitor.visit_trait_item(method) } } ItemMac(ref mac) => visitor.visit_mac(mac), } - for attr in item.attrs.iter() { + for attr in &item.attrs { visitor.visit_attribute(attr); } } @@ -329,7 +329,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { pub fn walk_enum_def<'v, V: Visitor<'v>>(visitor: &mut V, enum_definition: &'v EnumDef, generics: &'v Generics) { - for variant in enum_definition.variants.iter() { + for variant in &enum_definition.variants { visitor.visit_variant(&**variant, generics); } } @@ -341,7 +341,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, match variant.node.kind { TupleVariantKind(ref variant_arguments) => { - for variant_argument in variant_arguments.iter() { + for variant_argument in variant_arguments { visitor.visit_ty(&*variant_argument.ty) } } @@ -356,7 +356,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, Some(ref expr) => visitor.visit_expr(&**expr), None => () } - for attr in variant.node.attrs.iter() { + for attr in &variant.node.attrs { visitor.visit_attribute(attr); } } @@ -385,12 +385,12 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { visitor.visit_ty(&*mutable_type.ty) } TyTup(ref tuple_element_types) => { - for tuple_element_type in tuple_element_types.iter() { + for tuple_element_type in tuple_element_types { visitor.visit_ty(&**tuple_element_type) } } TyBareFn(ref function_declaration) => { - for argument in function_declaration.decl.inputs.iter() { + for argument in &function_declaration.decl.inputs { visitor.visit_ty(&*argument.ty) } walk_fn_ret_ty(visitor, &function_declaration.decl.output); @@ -422,13 +422,13 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { pub fn walk_lifetime_decls_helper<'v, V: Visitor<'v>>(visitor: &mut V, lifetimes: &'v Vec<LifetimeDef>) { - for l in lifetimes.iter() { + for l in lifetimes { visitor.visit_lifetime_def(l); } } pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) { - for segment in path.segments.iter() { + for segment in &path.segments { visitor.visit_path_segment(path.span, segment); } } @@ -453,21 +453,21 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V, path_parameters: &'v PathParameters) { match *path_parameters { ast::AngleBracketedParameters(ref data) => { - for typ in data.types.iter() { + for typ in &*data.types { visitor.visit_ty(&**typ); } - for lifetime in data.lifetimes.iter() { + for lifetime in &data.lifetimes { visitor.visit_lifetime_ref(lifetime); } - for binding in data.bindings.iter() { + for binding in &*data.bindings { visitor.visit_assoc_type_binding(&**binding); } } ast::ParenthesizedParameters(ref data) => { - for typ in data.inputs.iter() { + for typ in &data.inputs { visitor.visit_ty(&**typ); } - for typ in data.output.iter() { + if let Some(ref typ) = data.output { visitor.visit_ty(&**typ); } } @@ -484,20 +484,20 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) { match pattern.node { PatEnum(ref path, ref children) => { visitor.visit_path(path, pattern.id); - for children in children.iter() { - for child in children.iter() { - visitor.visit_pat(&**child) + if let Some(ref children) = *children { + for child in children { + visitor.visit_pat(&*child) } } } PatStruct(ref path, ref fields, _) => { visitor.visit_path(path, pattern.id); - for field in fields.iter() { + for field in fields { visitor.visit_pat(&*field.node.pat) } } PatTup(ref tuple_elements) => { - for tuple_element in tuple_elements.iter() { + for tuple_element in tuple_elements { visitor.visit_pat(&**tuple_element) } } @@ -519,13 +519,13 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) { } PatWild(_) => (), PatVec(ref prepattern, ref slice_pattern, ref postpatterns) => { - for prepattern in prepattern.iter() { + for prepattern in prepattern { visitor.visit_pat(&**prepattern) } - for slice_pattern in slice_pattern.iter() { + if let Some(ref slice_pattern) = *slice_pattern { visitor.visit_pat(&**slice_pattern) } - for postpattern in postpatterns.iter() { + for postpattern in postpatterns { visitor.visit_pat(&**postpattern) } } @@ -545,14 +545,14 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, ForeignItemStatic(ref typ, _) => visitor.visit_ty(&**typ), } - for attr in foreign_item.attrs.iter() { + for attr in &foreign_item.attrs { visitor.visit_attribute(attr); } } pub fn walk_ty_param_bounds_helper<'v, V: Visitor<'v>>(visitor: &mut V, bounds: &'v OwnedSlice<TyParamBound>) { - for bound in bounds.iter() { + for bound in &**bounds { visitor.visit_ty_param_bound(bound) } } @@ -576,11 +576,11 @@ pub fn walk_ty_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v TyParam) { } pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) { - for type_parameter in generics.ty_params.iter() { + for type_parameter in &*generics.ty_params { walk_ty_param(visitor, type_parameter); } walk_lifetime_decls_helper(visitor, &generics.lifetimes); - for predicate in generics.where_clause.predicates.iter() { + for predicate in &generics.where_clause.predicates { match predicate { &ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bounded_ty, ref bounds, @@ -593,7 +593,7 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics ..}) => { visitor.visit_lifetime_ref(lifetime); - for bound in bounds.iter() { + for bound in bounds { visitor.visit_lifetime_ref(bound); } } @@ -615,7 +615,7 @@ pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionR } pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl) { - for argument in function_declaration.inputs.iter() { + for argument in &function_declaration.inputs { visitor.visit_pat(&*argument.pat); visitor.visit_ty(&*argument.ty) } @@ -635,7 +635,7 @@ pub fn walk_method_helper<'v, V: Visitor<'v>>(visitor: &mut V, method: &'v Metho &**body, method.span, method.id); - for attr in method.attrs.iter() { + for attr in &method.attrs { visitor.visit_attribute(attr); } @@ -673,12 +673,12 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_ty_method<'v, V: Visitor<'v>>(visitor: &mut V, method_type: &'v TypeMethod) { visitor.visit_ident(method_type.span, method_type.ident); visitor.visit_explicit_self(&method_type.explicit_self); - for argument_type in method_type.decl.inputs.iter() { + for argument_type in &method_type.decl.inputs { visitor.visit_ty(&*argument_type.ty) } visitor.visit_generics(&method_type.generics); walk_fn_ret_ty(visitor, &method_type.decl.output); - for attr in method_type.attrs.iter() { + for attr in &method_type.attrs { visitor.visit_attribute(attr); } } @@ -695,7 +695,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_method: &'v Tr pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V, struct_definition: &'v StructDef) { - for field in struct_definition.fields.iter() { + for field in &struct_definition.fields { visitor.visit_struct_field(field) } } @@ -708,13 +708,13 @@ pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V, visitor.visit_ty(&*struct_field.node.ty); - for attr in struct_field.node.attrs.iter() { + for attr in &struct_field.node.attrs { visitor.visit_attribute(attr); } } pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) { - for statement in block.stmts.iter() { + for statement in &block.stmts { visitor.visit_stmt(&**statement) } walk_expr_opt(visitor, &block.expr) @@ -746,7 +746,7 @@ pub fn walk_expr_opt<'v, V: Visitor<'v>>(visitor: &mut V, } pub fn walk_exprs<'v, V: Visitor<'v>>(visitor: &mut V, expressions: &'v [P<Expr>]) { - for expression in expressions.iter() { + for expression in expressions { visitor.visit_expr(&**expression) } } @@ -770,25 +770,25 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { } ExprStruct(ref path, ref fields, ref optional_base) => { visitor.visit_path(path, expression.id); - for field in fields.iter() { + for field in fields { visitor.visit_expr(&*field.expr) } walk_expr_opt(visitor, optional_base) } ExprTup(ref subexpressions) => { - for subexpression in subexpressions.iter() { + for subexpression in subexpressions { visitor.visit_expr(&**subexpression) } } ExprCall(ref callee_expression, ref arguments) => { - for argument in arguments.iter() { + for argument in arguments { visitor.visit_expr(&**argument) } visitor.visit_expr(&**callee_expression) } ExprMethodCall(_, ref types, ref arguments) => { walk_exprs(visitor, arguments.as_slice()); - for typ in types.iter() { + for typ in types { visitor.visit_ty(&**typ) } } @@ -832,7 +832,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { ExprLoop(ref block, _) => visitor.visit_block(&**block), ExprMatch(ref subexpression, ref arms, _) => { visitor.visit_expr(&**subexpression); - for arm in arms.iter() { + for arm in arms { visitor.visit_arm(arm) } } @@ -881,11 +881,11 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { visitor.visit_expr(&**subexpression) } ExprInlineAsm(ref ia) => { - for input in ia.inputs.iter() { + for input in &ia.inputs { let (_, ref input) = *input; visitor.visit_expr(&**input) } - for output in ia.outputs.iter() { + for output in &ia.outputs { let (_, ref output, _) = *output; visitor.visit_expr(&**output) } @@ -896,12 +896,12 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { } pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) { - for pattern in arm.pats.iter() { + for pattern in &arm.pats { visitor.visit_pat(&**pattern) } walk_expr_opt(visitor, &arm.guard); visitor.visit_expr(&*arm.body); - for attr in arm.attrs.iter() { + for attr in &arm.attrs { visitor.visit_attribute(attr); } } |
