for x in xs.iter() -> for x in &xs

This commit is contained in:
Jorge Aparicio
2015-01-31 12:20:46 -05:00
parent 9f90d666e0
commit d5d7e6565a
269 changed files with 1063 additions and 1064 deletions

View File

@@ -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);

View File

@@ -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()));
}

View File

@@ -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() {

View File

@@ -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())) {

View File

@@ -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");
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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);
}