rollup merge of #21830: japaric/for-cleanup

Conflicts:
	src/librustc/metadata/filesearch.rs
	src/librustc_back/target/mod.rs
	src/libstd/os.rs
	src/libstd/sys/windows/os.rs
	src/libsyntax/ext/tt/macro_parser.rs
	src/libsyntax/print/pprust.rs
	src/test/compile-fail/issue-2149.rs
This commit is contained in:
Alex Crichton 2015-02-02 11:01:12 -08:00
commit 7335c7dd63
319 changed files with 1308 additions and 1443 deletions

View file

@ -23,8 +23,6 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), allow(unused_mut))] // NOTE: remove after stage0 snap
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]

View file

@ -459,7 +459,7 @@ impl LintPass for ImproperCTypes {
}
fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
for input in decl.inputs.iter() {
for input in &decl.inputs {
check_ty(cx, &*input.ty);
}
if let ast::Return(ref ret_ty) = decl.output {
@ -469,7 +469,7 @@ impl LintPass for ImproperCTypes {
match it.node {
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
for ni in nmod.items.iter() {
for ni in &nmod.items {
match ni.node {
ast::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl),
ast::ForeignItemStatic(ref t, _) => check_ty(cx, &**t)
@ -532,7 +532,7 @@ impl LintPass for BoxPointers {
// If it's a struct, we also have to check the fields' types
match it.node {
ast::ItemStruct(ref struct_def, _) => {
for struct_field in struct_def.fields.iter() {
for struct_field in &struct_def.fields {
self.check_heap_type(cx, struct_field.span,
ty::node_id_to_type(cx.tcx, struct_field.node.id));
}
@ -691,7 +691,7 @@ impl LintPass for UnusedAttributes {
"no_builtins",
];
for &name in ATTRIBUTE_WHITELIST.iter() {
for &name in ATTRIBUTE_WHITELIST {
if attr.check_name(name) {
break;
}
@ -793,7 +793,7 @@ impl LintPass for UnusedResults {
}
fn check_must_use(cx: &Context, attrs: &[ast::Attribute], sp: Span) -> bool {
for attr in attrs.iter() {
for attr in attrs {
if attr.check_name("must_use") {
let mut msg = "unused result which must be used".to_string();
// check for #[must_use="..."]
@ -877,7 +877,7 @@ impl LintPass for NonCamelCaseTypes {
ast::ItemEnum(ref enum_definition, _) => {
if has_extern_repr { return }
self.check_case(cx, "type", it.ident, it.span);
for variant in enum_definition.variants.iter() {
for variant in &enum_definition.variants {
self.check_case(cx, "variant", variant.node.name, variant.span);
}
}
@ -886,7 +886,7 @@ impl LintPass for NonCamelCaseTypes {
}
fn check_generics(&mut self, cx: &Context, it: &ast::Generics) {
for gen in it.ty_params.iter() {
for gen in &*it.ty_params {
self.check_case(cx, "type parameter", gen.ident, gen.span);
}
}
@ -1056,7 +1056,7 @@ impl LintPass for NonSnakeCase {
fn check_struct_def(&mut self, cx: &Context, s: &ast::StructDef,
_: ast::Ident, _: &ast::Generics, _: ast::NodeId) {
for sf in s.fields.iter() {
for sf in &s.fields {
if let ast::StructField_ { kind: ast::NamedField(ident, _), .. } = sf.node {
self.check_snake_case(cx, "structure field", ident, sf.span);
}
@ -1354,7 +1354,7 @@ impl UnusedMut {
// avoid false warnings in match arms with multiple patterns
let mut mutables = FnvHashMap();
for p in pats.iter() {
for p in pats {
pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
let ident = path1.node;
if let ast::BindByValue(ast::MutMutable) = mode {
@ -1369,7 +1369,7 @@ impl UnusedMut {
}
let used_mutables = cx.tcx.used_mut_nodes.borrow();
for (_, v) in mutables.iter() {
for (_, v) in &mutables {
if !v.iter().any(|e| used_mutables.contains(e)) {
cx.span_lint(UNUSED_MUT, cx.tcx.map.span(v[0]),
"variable does not need to be mutable");
@ -1385,7 +1385,7 @@ impl LintPass for UnusedMut {
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
if let ast::ExprMatch(_, ref arms, _) = e.node {
for a in arms.iter() {
for a in arms {
self.check_unused_mut_pat(cx, &a.pats[])
}
}
@ -1402,7 +1402,7 @@ impl LintPass for UnusedMut {
fn check_fn(&mut self, cx: &Context,
_: visit::FnKind, decl: &ast::FnDecl,
_: &ast::Block, _: Span, _: ast::NodeId) {
for a in decl.inputs.iter() {
for a in &decl.inputs {
self.check_unused_mut_pat(cx, slice::ref_slice(&a.pat));
}
}
@ -1879,7 +1879,7 @@ impl LintPass for UnconditionalRecursion {
if cx.current_level(UNCONDITIONAL_RECURSION) != Level::Allow {
let sess = cx.sess();
// offer some help to the programmer.
for call in self_call_spans.iter() {
for call in &self_call_spans {
sess.span_note(*call, "recursive call site")
}
sess.span_help(sp, "a `loop` may express intention better if this is on purpose")

View file

@ -116,7 +116,7 @@ impl LintStore {
pub fn register_pass(&mut self, sess: Option<&Session>,
from_plugin: bool, pass: LintPassObject) {
for &lint in pass.get_lints().iter() {
for &lint in pass.get_lints() {
self.lints.push((*lint, from_plugin));
let id = LintId::of(*lint);
@ -260,7 +260,7 @@ impl LintStore {
}
pub fn process_command_line(&mut self, sess: &Session) {
for &(ref lint_name, level) in sess.opts.lint_opts.iter() {
for &(ref lint_name, level) in &sess.opts.lint_opts {
match self.find_lint(&lint_name[], sess, None) {
Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
None => {
@ -329,7 +329,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
// Move the vector of passes out of `$cx` so that we can
// iterate over it mutably while passing `$cx` to the methods.
let mut passes = $cx.lints.passes.take().unwrap();
for obj in passes.iter_mut() {
for obj in &mut passes {
obj.$f($cx, $($args),*);
}
$cx.lints.passes = Some(passes);
@ -340,7 +340,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
pub fn gather_attrs(attrs: &[ast::Attribute])
-> Vec<Result<(InternedString, Level, Span), Span>> {
let mut out = vec!();
for attr in attrs.iter() {
for attr in attrs {
let level = match Level::from_str(attr.name().get()) {
None => continue,
Some(lvl) => lvl,
@ -357,7 +357,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
}
};
for meta in metas.iter() {
for meta in metas {
out.push(match meta.node {
ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
_ => Err(meta.span),
@ -417,11 +417,11 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
_ => sess.bug("impossible level in raw_emit_lint"),
}
for note in note.into_iter() {
if let Some(note) = note {
sess.note(&note[]);
}
for span in def.into_iter() {
if let Some(span) = def {
sess.span_note(span, "lint level defined here");
}
}
@ -492,7 +492,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
// specified closure
let mut pushed = 0;
for result in gather_attrs(attrs).into_iter() {
for result in gather_attrs(attrs) {
let v = match result {
Err(span) => {
self.tcx.sess.span_err(span, "malformed lint attribute");
@ -519,7 +519,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
}
};
for (lint_id, level, span) in v.into_iter() {
for (lint_id, level, span) in v {
let now = self.lints.get_level_source(lint_id).0;
if now == Forbid && level != Forbid {
let lint_name = lint_id.as_str();
@ -727,7 +727,7 @@ impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> {
match self.tcx.sess.lints.borrow_mut().remove(&id) {
None => {}
Some(lints) => {
for (lint_id, span, msg) in lints.into_iter() {
for (lint_id, span, msg) in lints {
self.span_lint(lint_id.lint, span, &msg[])
}
}
@ -794,8 +794,8 @@ pub fn check_crate(tcx: &ty::ctxt,
// If we missed any lints added to the session, then there's a bug somewhere
// in the iteration code.
for (id, v) in tcx.sess.lints.borrow().iter() {
for &(lint, span, ref msg) in v.iter() {
for (id, v) in &*tcx.sess.lints.borrow() {
for &(lint, span, ref msg) in v {
tcx.sess.span_bug(span,
format!("unprocessed lint {} at {}: {}",
lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice())

View file

@ -162,7 +162,7 @@ impl<'a> CrateReader<'a> {
dump_crates(&self.sess.cstore);
}
for &(ref name, kind) in self.sess.opts.libs.iter() {
for &(ref name, kind) in &self.sess.opts.libs {
register_native_lib(self.sess, None, name.clone(), kind);
}
}
@ -235,7 +235,7 @@ impl<'a> CrateReader<'a> {
None
})
.collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() {
for m in &link_args {
match m.value_str() {
Some(linkarg) => self.sess.cstore.add_used_link_args(linkarg.get()),
None => { /* fallthrough */ }
@ -250,7 +250,7 @@ impl<'a> CrateReader<'a> {
None
})
.collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() {
for m in &link_args {
match m.meta_item_list() {
Some(items) => {
let kind = items.iter().find(|k| {

View file

@ -382,7 +382,7 @@ pub fn get_stability(cstore: &cstore::CStore,
pub fn is_staged_api(cstore: &cstore::CStore, def: ast::DefId) -> bool {
let cdata = cstore.get_crate_data(def.krate);
let attrs = decoder::get_crate_attributes(cdata.data());
for attr in attrs.iter() {
for attr in &attrs {
if attr.name().get() == "staged_api" {
match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) }
}

View file

@ -113,7 +113,7 @@ impl CStore {
pub fn iter_crate_data<I>(&self, mut i: I) where
I: FnMut(ast::CrateNum, &crate_metadata),
{
for (&k, v) in self.metas.borrow().iter() {
for (&k, v) in &*self.metas.borrow() {
i(k, &**v);
}
}
@ -122,7 +122,7 @@ impl CStore {
pub fn iter_crate_data_origins<I>(&self, mut i: I) where
I: FnMut(ast::CrateNum, &crate_metadata, Option<CrateSource>),
{
for (&k, v) in self.metas.borrow().iter() {
for (&k, v) in &*self.metas.borrow() {
let origin = self.get_used_crate_source(k);
origin.as_ref().map(|cs| { assert!(k == cs.cnum); });
i(k, &**v, origin);
@ -167,12 +167,12 @@ impl CStore {
ordering: &mut Vec<ast::CrateNum>) {
if ordering.contains(&cnum) { return }
let meta = cstore.get_crate_data(cnum);
for (_, &dep) in meta.cnum_map.iter() {
for (_, &dep) in &meta.cnum_map {
visit(cstore, dep, ordering);
}
ordering.push(cnum);
};
for (&num, _) in self.metas.borrow().iter() {
for (&num, _) in &*self.metas.borrow() {
visit(self, num, &mut ordering);
}
ordering.reverse();

View file

@ -1022,7 +1022,7 @@ pub fn get_methods_if_impl(intr: Rc<IdentInterner>,
});
let mut impl_methods = Vec::new();
for impl_method_id in impl_method_ids.iter() {
for impl_method_id in &impl_method_ids {
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data());
let family = item_family(impl_method_doc);
match family {
@ -1189,7 +1189,7 @@ fn list_crate_attributes(md: rbml::Doc, hash: &Svh,
try!(write!(out, "=Crate Attributes ({})=\n", *hash));
let r = get_attributes(md);
for attr in r.iter() {
for attr in &r {
try!(write!(out, "{}\n", pprust::attribute_to_string(attr)));
}
@ -1232,7 +1232,7 @@ pub fn get_crate_deps(data: &[u8]) -> Vec<CrateDep> {
fn list_crate_deps(data: &[u8], out: &mut old_io::Writer) -> old_io::IoResult<()> {
try!(write!(out, "=External Dependencies=\n"));
for dep in get_crate_deps(data).iter() {
for dep in &get_crate_deps(data) {
try!(write!(out, "{} {}-{}\n", dep.cnum, dep.name, dep.hash));
}
try!(write!(out, "\n"));

View file

@ -288,7 +288,7 @@ fn encode_parent_item(rbml_w: &mut Encoder, id: DefId) {
fn encode_struct_fields(rbml_w: &mut Encoder,
fields: &[ty::field_ty],
origin: DefId) {
for f in fields.iter() {
for f in fields {
if f.name == special_idents::unnamed_field.name {
rbml_w.start_tag(tag_item_unnamed_field);
} else {
@ -316,7 +316,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
let mut i = 0;
let vi = ty::enum_variants(ecx.tcx,
DefId { krate: ast::LOCAL_CRATE, node: id });
for variant in variants.iter() {
for variant in variants {
let def_id = local_def(variant.node.id);
index.push(entry {
val: variant.node.id as i64,
@ -367,7 +367,7 @@ fn encode_path<PI: Iterator<Item=PathElem>>(rbml_w: &mut Encoder, path: PI) {
let path = path.collect::<Vec<_>>();
rbml_w.start_tag(tag_path);
rbml_w.wr_tagged_u32(tag_path_len, path.len() as u32);
for pe in path.iter() {
for pe in &path {
let tag = match *pe {
ast_map::PathMod(_) => tag_path_elem_mod,
ast_map::PathName(_) => tag_path_elem_name
@ -402,8 +402,8 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
let impl_items = ecx.tcx.impl_items.borrow();
match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
Some(implementations) => {
for base_impl_did in implementations.iter() {
for &method_did in (*impl_items)[*base_impl_did].iter() {
for base_impl_did in &**implementations {
for &method_did in &*(*impl_items)[*base_impl_did] {
let impl_item = ty::impl_or_trait_item(
ecx.tcx,
method_did.def_id());
@ -431,7 +431,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
-> bool {
match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
Some(trait_items) => {
for trait_item in trait_items.iter() {
for trait_item in &**trait_items {
if let ty::MethodTraitItem(ref m) = *trait_item {
encode_reexported_static_method(rbml_w,
exp,
@ -517,9 +517,9 @@ fn encode_reexports(ecx: &EncodeContext,
path: PathElems) {
debug!("(encoding info for module) encoding reexports for {}", id);
match ecx.reexports.get(&id) {
Some(ref exports) => {
Some(exports) => {
debug!("(encoding info for module) found reexports for {}", id);
for exp in exports.iter() {
for exp in exports {
debug!("(encoding info for module) reexport '{}' ({}/{}) for \
{}",
exp.name,
@ -559,7 +559,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
debug!("(encoding info for module) encoding info for module ID {}", id);
// Encode info about all the module children.
for item in md.items.iter() {
for item in &md.items {
rbml_w.start_tag(tag_mod_child);
rbml_w.wr_str(&def_to_string(local_def(item.id))[]);
rbml_w.end_tag();
@ -665,9 +665,9 @@ fn encode_parent_sort(rbml_w: &mut Encoder, sort: char) {
fn encode_provided_source(rbml_w: &mut Encoder,
source_opt: Option<DefId>) {
for source in source_opt.iter() {
if let Some(source) = source_opt {
rbml_w.start_tag(tag_item_method_provided_source);
let s = def_to_string(*source);
let s = def_to_string(source);
rbml_w.writer.write_all(s.as_bytes());
rbml_w.end_tag();
}
@ -684,7 +684,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
let mut index = Vec::new();
/* We encode both private and public fields -- need to include
private fields to get the offsets right */
for field in fields.iter() {
for field in fields {
let nm = field.name;
let id = field.id.node;
@ -783,7 +783,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
rbml_w.wr_tagged_u64(tag_region_param_def_index,
param.index as u64);
for &bound_region in param.bounds.iter() {
for &bound_region in &param.bounds {
encode_region(ecx, rbml_w, bound_region);
}
@ -911,7 +911,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
fn encode_method_argument_names(rbml_w: &mut Encoder,
decl: &ast::FnDecl) {
rbml_w.start_tag(tag_method_argument_names);
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
rbml_w.start_tag(tag_method_argument_name);
if let ast::PatIdent(_, ref path1, _) = arg.pat.node {
let name = token::get_ident(path1.node);
@ -926,7 +926,7 @@ fn encode_repr_attrs(rbml_w: &mut Encoder,
ecx: &EncodeContext,
attrs: &[ast::Attribute]) {
let mut repr_attrs = Vec::new();
for attr in attrs.iter() {
for attr in attrs {
repr_attrs.extend(attr::find_repr_attrs(ecx.tcx.sess.diagnostic(),
attr).into_iter());
}
@ -962,7 +962,7 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
match ecx.tcx.inherent_impls.borrow().get(&def_id) {
None => {}
Some(implementations) => {
for &impl_def_id in implementations.iter() {
for &impl_def_id in &**implementations {
rbml_w.start_tag(tag_items_data_item_inherent_impl);
encode_def_id(rbml_w, impl_def_id);
rbml_w.end_tag();
@ -978,7 +978,7 @@ fn encode_extension_implementations(ecx: &EncodeContext,
match ecx.tcx.trait_impls.borrow().get(&trait_def_id) {
None => {}
Some(implementations) => {
for &impl_def_id in implementations.borrow().iter() {
for &impl_def_id in &*implementations.borrow() {
rbml_w.start_tag(tag_items_data_item_extension_impl);
encode_def_id(rbml_w, impl_def_id);
rbml_w.end_tag();
@ -1091,7 +1091,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_path(rbml_w, path);
// Encode all the items in this module.
for foreign_item in fm.items.iter() {
for foreign_item in &fm.items {
rbml_w.start_tag(tag_mod_child);
rbml_w.wr_str(&def_to_string(local_def(foreign_item.id))[]);
rbml_w.end_tag();
@ -1123,7 +1123,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_name(rbml_w, item.ident.name);
encode_attributes(rbml_w, &item.attrs[]);
encode_repr_attrs(rbml_w, ecx, &item.attrs[]);
for v in (*enum_definition).variants.iter() {
for v in &enum_definition.variants {
encode_variant_id(rbml_w, local_def(v.node.id));
}
encode_inlined_item(ecx, rbml_w, IIItemRef(item));
@ -1216,7 +1216,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
}
_ => {}
}
for &item_def_id in items.iter() {
for &item_def_id in items {
rbml_w.start_tag(tag_item_impl_item);
match item_def_id {
ty::MethodTraitItemId(item_def_id) => {
@ -1230,7 +1230,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
}
rbml_w.end_tag();
}
for ast_trait_ref in opt_trait.iter() {
if let Some(ref ast_trait_ref) = *opt_trait {
let trait_ref = ty::node_id_to_trait_ref(
tcx, ast_trait_ref.ref_id);
encode_trait_ref(rbml_w, ecx, &*trait_ref, tag_item_trait_ref);
@ -1314,7 +1314,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_attributes(rbml_w, &item.attrs[]);
encode_visibility(rbml_w, vis);
encode_stability(rbml_w, stab);
for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() {
for &method_def_id in &*ty::trait_item_def_ids(tcx, def_id) {
rbml_w.start_tag(tag_item_trait_item);
match method_def_id {
ty::MethodTraitItemId(method_def_id) => {
@ -1589,7 +1589,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
T: Hash<SipHasher>,
{
let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect();
for elt in index.into_iter() {
for elt in index {
let mut s = SipHasher::new();
elt.val.hash(&mut s);
let h = s.finish() as uint;
@ -1599,10 +1599,10 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
rbml_w.start_tag(tag_index);
let mut bucket_locs = Vec::new();
rbml_w.start_tag(tag_index_buckets);
for bucket in buckets.iter() {
for bucket in &buckets {
bucket_locs.push(rbml_w.writer.tell().unwrap());
rbml_w.start_tag(tag_index_buckets_bucket);
for elt in bucket.iter() {
for elt in bucket {
rbml_w.start_tag(tag_index_buckets_bucket_elt);
assert!(elt.pos < 0xffff_ffff);
{
@ -1616,7 +1616,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
}
rbml_w.end_tag();
rbml_w.start_tag(tag_index_table);
for pos in bucket_locs.iter() {
for pos in &bucket_locs {
assert!(*pos < 0xffff_ffff);
let wr: &mut SeekableMemWriter = rbml_w.writer;
wr.write_be_u32(*pos as u32);
@ -1660,7 +1660,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
rbml_w.start_tag(tag_meta_item_name);
rbml_w.writer.write_all(name.get().as_bytes());
rbml_w.end_tag();
for inner_item in items.iter() {
for inner_item in items {
encode_meta_item(rbml_w, &**inner_item);
}
rbml_w.end_tag();
@ -1670,7 +1670,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
fn encode_attributes(rbml_w: &mut Encoder, attrs: &[ast::Attribute]) {
rbml_w.start_tag(tag_attributes);
for attr in attrs.iter() {
for attr in attrs {
rbml_w.start_tag(tag_attribute);
rbml_w.wr_tagged_u8(tag_attribute_is_sugared_doc, attr.node.is_sugared_doc as u8);
encode_meta_item(rbml_w, &*attr.node.value);
@ -1694,7 +1694,7 @@ fn encode_paren_sugar(rbml_w: &mut Encoder, paren_sugar: bool) {
fn encode_associated_type_names(rbml_w: &mut Encoder, names: &[ast::Name]) {
rbml_w.start_tag(tag_associated_type_names);
for &name in names.iter() {
for &name in names {
rbml_w.wr_tagged_str(tag_associated_type_name, token::get_name(name).get());
}
rbml_w.end_tag();
@ -1726,7 +1726,7 @@ fn encode_crate_deps(rbml_w: &mut Encoder, cstore: &cstore::CStore) {
// Sanity-check the crate numbers
let mut expected_cnum = 1;
for n in deps.iter() {
for n in &deps {
assert_eq!(n.cnum, expected_cnum);
expected_cnum += 1;
}
@ -1740,7 +1740,7 @@ fn encode_crate_deps(rbml_w: &mut Encoder, cstore: &cstore::CStore) {
// but is enough to get transitive crate dependencies working.
rbml_w.start_tag(tag_crate_deps);
let r = get_ordered_deps(cstore);
for dep in r.iter() {
for dep in &r {
encode_crate_dep(rbml_w, (*dep).clone());
}
rbml_w.end_tag();
@ -1749,8 +1749,8 @@ fn encode_crate_deps(rbml_w: &mut Encoder, cstore: &cstore::CStore) {
fn encode_lang_items(ecx: &EncodeContext, rbml_w: &mut Encoder) {
rbml_w.start_tag(tag_lang_items);
for (i, def_id) in ecx.tcx.lang_items.items() {
for id in def_id.iter() {
for (i, &def_id) in ecx.tcx.lang_items.items() {
if let Some(id) = def_id {
if id.krate == ast::LOCAL_CRATE {
rbml_w.start_tag(tag_lang_items_item);
@ -1773,7 +1773,7 @@ fn encode_lang_items(ecx: &EncodeContext, rbml_w: &mut Encoder) {
}
}
for i in ecx.tcx.lang_items.missing.iter() {
for i in &ecx.tcx.lang_items.missing {
rbml_w.wr_tagged_u32(tag_lang_items_missing, *i as u32);
}
@ -1817,7 +1817,7 @@ fn encode_plugin_registrar_fn(ecx: &EncodeContext, rbml_w: &mut Encoder) {
fn encode_macro_defs(rbml_w: &mut Encoder,
krate: &ast::Crate) {
rbml_w.start_tag(tag_macro_defs);
for def in krate.exported_macros.iter() {
for def in &krate.exported_macros {
rbml_w.start_tag(tag_macro_def);
encode_name(rbml_w, def.ident.name);
@ -1911,7 +1911,7 @@ fn encode_misc_info(ecx: &EncodeContext,
rbml_w: &mut Encoder) {
rbml_w.start_tag(tag_misc_info);
rbml_w.start_tag(tag_misc_info_crate_items);
for item in krate.module.items.iter() {
for item in &krate.module.items {
rbml_w.start_tag(tag_mod_child);
rbml_w.wr_str(&def_to_string(local_def(item.id))[]);
rbml_w.end_tag();
@ -1935,7 +1935,7 @@ fn encode_misc_info(ecx: &EncodeContext,
fn encode_reachable_extern_fns(ecx: &EncodeContext, rbml_w: &mut Encoder) {
rbml_w.start_tag(tag_reachable_extern_fns);
for id in ecx.reachable.iter() {
for id in ecx.reachable {
if let Some(ast_map::NodeItem(i)) = ecx.tcx.map.find(*id) {
if let ast::ItemFn(_, _, abi, ref generics, _) = i.node {
if abi != abi::Rust && !generics.is_type_parameterized() {
@ -2150,7 +2150,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
stats.total_bytes = rbml_w.writer.tell().unwrap();
if tcx.sess.meta_stats() {
for e in rbml_w.writer.get_ref().iter() {
for e in rbml_w.writer.get_ref() {
if *e == 0 {
stats.zero_bytes += 1;
}

View file

@ -66,7 +66,7 @@ impl<'a> FileSearch<'a> {
// Try RUST_PATH
if !found {
let rustpath = rust_path();
for path in rustpath.iter() {
for path in &rustpath {
let tlib_path = make_rustpkg_lib_path(
self.sysroot, path, self.triple);
debug!("is {} in visited_dirs? {}", tlib_path.display(),
@ -243,8 +243,7 @@ pub fn rust_path() -> Vec<Path> {
}
cwd.pop();
}
let h = env::home_dir();
for h in h.iter() {
if let Some(h) = env::home_dir() {
let p = h.join(".rust");
if !env_rust_path.contains(&p) && p.exists() {
env_rust_path.push(p);

View file

@ -425,7 +425,7 @@ impl<'a> Context<'a> {
// libraries corresponds to the crate id and hash criteria that this
// search is being performed for.
let mut libraries = Vec::new();
for (_hash, (rlibs, dylibs)) in candidates.into_iter() {
for (_hash, (rlibs, dylibs)) in candidates {
let mut metadata = None;
let rlib = self.extract_one(rlibs, "rlib", &mut metadata);
let dylib = self.extract_one(dylibs, "dylib", &mut metadata);
@ -452,7 +452,7 @@ impl<'a> Context<'a> {
&format!("multiple matching crates for `{}`",
self.crate_name)[]);
self.sess.note("candidates:");
for lib in libraries.iter() {
for lib in &libraries {
match lib.dylib {
Some((ref p, _)) => {
self.sess.note(&format!("path: {}",
@ -501,7 +501,7 @@ impl<'a> Context<'a> {
}
}
for (lib, kind) in m.into_iter() {
for (lib, kind) in m {
info!("{} reading metadata from: {}", flavor, lib.display());
let metadata = match get_metadata_section(self.target.options.is_like_osx,
&lib) {
@ -610,7 +610,7 @@ impl<'a> Context<'a> {
let mut rlibs = HashMap::new();
let mut dylibs = HashMap::new();
{
let mut locs = locs.iter().map(|l| Path::new(&l[])).filter(|loc| {
let locs = locs.iter().map(|l| Path::new(&l[])).filter(|loc| {
if !loc.exists() {
sess.err(&format!("extern location for {} does not exist: {}",
self.crate_name, loc.display())[]);

View file

@ -249,7 +249,7 @@ fn parse_vec_per_param_space<'a, 'tcx, T, F>(st: &mut PState<'a, 'tcx>,
F: FnMut(&mut PState<'a, 'tcx>) -> T,
{
let mut r = VecPerParamSpace::empty();
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
assert_eq!(next(st), '[');
while peek(st) != ']' {
r.push(space, f(st));

View file

@ -97,7 +97,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
}
ty::ty_tup(ref ts) => {
mywrite!(w, "T[");
for t in ts.iter() { enc_ty(w, cx, *t); }
for t in ts { enc_ty(w, cx, *t); }
mywrite!(w, "]");
}
ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
@ -206,9 +206,9 @@ fn enc_vec_per_param_space<'a, 'tcx, T, F>(w: &mut SeekableMemWriter,
mut op: F) where
F: FnMut(&mut SeekableMemWriter, &ctxt<'a, 'tcx>, &T),
{
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
mywrite!(w, "[");
for t in v.get_slice(space).iter() {
for t in v.get_slice(space) {
op(w, cx, t);
}
mywrite!(w, "]");
@ -337,7 +337,7 @@ pub fn enc_closure_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
fn enc_fn_sig<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
fsig: &ty::PolyFnSig<'tcx>) {
mywrite!(w, "[");
for ty in fsig.0.inputs.iter() {
for ty in &fsig.0.inputs {
enc_ty(w, cx, *ty);
}
mywrite!(w, "]");
@ -357,7 +357,7 @@ fn enc_fn_sig<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
}
pub fn enc_builtin_bounds(w: &mut SeekableMemWriter, _cx: &ctxt, bs: &ty::BuiltinBounds) {
for bound in bs.iter() {
for bound in bs {
match bound {
ty::BoundSend => mywrite!(w, "S"),
ty::BoundSized => mywrite!(w, "Z"),
@ -383,17 +383,17 @@ pub fn enc_bounds<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
bs: &ty::ParamBounds<'tcx>) {
enc_builtin_bounds(w, cx, &bs.builtin_bounds);
for &r in bs.region_bounds.iter() {
for &r in &bs.region_bounds {
mywrite!(w, "R");
enc_region(w, cx, r);
}
for tp in bs.trait_bounds.iter() {
for tp in &bs.trait_bounds {
mywrite!(w, "I");
enc_trait_ref(w, cx, &*tp.0);
}
for tp in bs.projection_bounds.iter() {
for tp in &bs.projection_bounds {
mywrite!(w, "P");
enc_projection_predicate(w, cx, &tp.0);
}

View file

@ -766,7 +766,7 @@ fn encode_vec_per_param_space<T, F>(rbml_w: &mut Encoder,
mut f: F) where
F: FnMut(&mut Encoder, &T),
{
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
rbml_w.emit_from_vec(v.get_slice(space),
|rbml_w, n| Ok(f(rbml_w, n))).unwrap();
}
@ -1156,14 +1156,14 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
debug!("Encoding side tables for id {}", id);
for def in tcx.def_map.borrow().get(&id).iter() {
if let Some(def) = tcx.def_map.borrow().get(&id) {
rbml_w.tag(c::tag_table_def, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| (*def).encode(rbml_w).unwrap());
})
}
for &ty in tcx.node_types.borrow().get(&id).iter() {
if let Some(ty) = tcx.node_types.borrow().get(&id) {
rbml_w.tag(c::tag_table_node_type, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1172,7 +1172,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &item_substs in tcx.item_substs.borrow().get(&id).iter() {
if let Some(item_substs) = tcx.item_substs.borrow().get(&id) {
rbml_w.tag(c::tag_table_item_subst, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1181,7 +1181,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &fv in tcx.freevars.borrow().get(&id).iter() {
if let Some(fv) = tcx.freevars.borrow().get(&id) {
rbml_w.tag(c::tag_table_freevars, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1191,7 +1191,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
});
for freevar in fv.iter() {
for freevar in fv {
rbml_w.tag(c::tag_table_upvar_capture_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1209,7 +1209,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
for &type_scheme in tcx.tcache.borrow().get(&lid).iter() {
if let Some(type_scheme) = tcx.tcache.borrow().get(&lid) {
rbml_w.tag(c::tag_table_tcache, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1218,7 +1218,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &type_param_def in tcx.ty_param_defs.borrow().get(&id).iter() {
if let Some(type_param_def) = tcx.ty_param_defs.borrow().get(&id) {
rbml_w.tag(c::tag_table_param_defs, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1228,7 +1228,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}
let method_call = MethodCall::expr(id);
for &method in tcx.method_map.borrow().get(&method_call).iter() {
if let Some(method) = tcx.method_map.borrow().get(&method_call) {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1237,7 +1237,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &trait_ref in tcx.object_cast_map.borrow().get(&id).iter() {
if let Some(trait_ref) = tcx.object_cast_map.borrow().get(&id) {
rbml_w.tag(c::tag_table_object_cast_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1246,11 +1246,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &adjustment in tcx.adjustments.borrow().get(&id).iter() {
if let Some(adjustment) = tcx.adjustments.borrow().get(&id) {
match *adjustment {
_ if ty::adjust_is_object(adjustment) => {
let method_call = MethodCall::autoobject(id);
for &method in tcx.method_map.borrow().get(&method_call).iter() {
if let Some(method) = tcx.method_map.borrow().get(&method_call) {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1263,7 +1263,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
assert!(!ty::adjust_is_object(adjustment));
for autoderef in 0..adj.autoderefs {
let method_call = MethodCall::autoderef(id, autoderef);
for &method in tcx.method_map.borrow().get(&method_call).iter() {
if let Some(method) = tcx.method_map.borrow().get(&method_call) {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1287,7 +1287,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &closure_type in tcx.closure_tys.borrow().get(&ast_util::local_def(id)).iter() {
if let Some(closure_type) = tcx.closure_tys.borrow().get(&ast_util::local_def(id)) {
rbml_w.tag(c::tag_table_closure_tys, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1296,11 +1296,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &&closure_kind in tcx.closure_kinds.borrow().get(&ast_util::local_def(id)).iter() {
if let Some(closure_kind) = tcx.closure_kinds.borrow().get(&ast_util::local_def(id)) {
rbml_w.tag(c::tag_table_closure_kinds, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
encode_closure_kind(rbml_w, closure_kind)
encode_closure_kind(rbml_w, *closure_kind)
})
})
}

View file

@ -68,7 +68,7 @@ fn add_initial_dummy_node(g: &mut CFGGraph) -> CFGIndex {
impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
fn block(&mut self, blk: &ast::Block, pred: CFGIndex) -> CFGIndex {
let mut stmts_exit = pred;
for stmt in blk.stmts.iter() {
for stmt in &blk.stmts {
stmts_exit = self.stmt(&**stmt, stmts_exit);
}
@ -166,7 +166,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.pat(&*pats[0], pred)
} else {
let collect = self.add_dummy_node(&[]);
for pat in pats.iter() {
for pat in pats {
let pat_exit = self.pat(&**pat, pred);
self.add_contained_edge(pat_exit, collect);
}
@ -325,7 +325,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let expr_exit = self.add_node(expr.id, &[]);
let mut cond_exit = discr_exit;
for arm in arms.iter() {
for arm in arms {
cond_exit = self.add_dummy_node(&[cond_exit]); // 2
let pats_exit = self.pats_any(&arm.pats[],
cond_exit); // 3
@ -522,7 +522,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
assert!(!self.exit_map.contains_key(&id));
self.exit_map.insert(id, node);
}
for &pred in preds.iter() {
for &pred in preds {
self.add_contained_edge(pred, node);
}
node
@ -574,7 +574,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
Some(_) => {
match self.tcx.def_map.borrow().get(&expr.id) {
Some(&def::DefLabel(loop_id)) => {
for l in self.loop_scopes.iter() {
for l in &self.loop_scopes {
if l.loop_id == loop_id {
return *l;
}

View file

@ -46,7 +46,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
}
ast::ItemEnum(ref enum_definition, _) => {
self.inside_const(|v| {
for var in enum_definition.variants.iter() {
for var in &enum_definition.variants {
if let Some(ref ex) = var.node.disr_expr {
v.visit_expr(&**ex);
}
@ -137,7 +137,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) {
}
ast::ExprBlock(ref block) => {
// Check all statements in the block
for stmt in block.stmts.iter() {
for stmt in &block.stmts {
let block_span_err = |&: span|
span_err!(v.tcx.sess, span, E0016,
"blocks in constants are limited to items and \

View file

@ -77,7 +77,7 @@ impl<'a> fmt::Debug for Matrix<'a> {
let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1;
let br = repeat('+').take(total_width).collect::<String>();
try!(write!(f, "{}\n", br));
for row in pretty_printed_matrix.into_iter() {
for row in pretty_printed_matrix {
try!(write!(f, "+"));
for (column, pat_str) in row.into_iter().enumerate() {
try!(write!(f, " "));
@ -157,7 +157,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
visit::walk_expr(cx, ex);
match ex.node {
ast::ExprMatch(ref scrut, ref arms, source) => {
for arm in arms.iter() {
for arm in arms {
// First, check legality of move bindings.
check_legality_of_move_bindings(cx,
arm.guard.is_some(),
@ -285,8 +285,8 @@ fn check_arms(cx: &MatchCheckCtxt,
source: ast::MatchSource) {
let mut seen = Matrix(vec![]);
let mut printed_if_let_err = false;
for &(ref pats, guard) in arms.iter() {
for pat in pats.iter() {
for &(ref pats, guard) in arms {
for pat in pats {
let v = vec![&**pat];
match is_useful(cx, &seen, &v[], LeaveOutWitness) {
@ -979,7 +979,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
visit::walk_fn(cx, kind, decl, body, sp);
for input in decl.inputs.iter() {
for input in &decl.inputs {
is_refutable(cx, &*input.pat, |pat| {
span_err!(cx.tcx.sess, input.pat.span, E0006,
"refutable pattern in function argument: `{}` not covered",
@ -1012,7 +1012,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
let tcx = cx.tcx;
let def_map = &tcx.def_map;
let mut by_ref_span = None;
for pat in pats.iter() {
for pat in pats {
pat_bindings(def_map, &**pat, |bm, _, span, _path| {
match bm {
ast::BindByRef(_) => {
@ -1039,7 +1039,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
}
};
for pat in pats.iter() {
for pat in pats {
walk_pat(&**pat, |p| {
if pat_is_binding(def_map, &*p) {
match p.node {

View file

@ -104,7 +104,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
-> Option<&'a Expr> {
fn variant_expr<'a>(variants: &'a [P<ast::Variant>], id: ast::NodeId)
-> Option<&'a Expr> {
for variant in variants.iter() {
for variant in variants {
if variant.node.id == id {
return variant.node.disr_expr.as_ref().map(|e| &**e);
}

View file

@ -399,7 +399,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
let mut orig_kills = self.kills[start.. end].to_vec();
let mut changed = false;
for &node_id in edge.data.exiting_scopes.iter() {
for &node_id in &edge.data.exiting_scopes {
let opt_cfg_idx = self.nodeid_to_index.get(&node_id).map(|&i|i);
match opt_cfg_idx {
Some(cfg_idx) => {
@ -501,7 +501,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> {
fn reset(&mut self, bits: &mut [uint]) {
let e = if self.dfcx.oper.initial_value() {uint::MAX} else {0};
for b in bits.iter_mut() {
for b in bits {
*b = e;
}
}
@ -550,7 +550,7 @@ fn bits_to_string(words: &[uint]) -> String {
// Note: this is a little endian printout of bytes.
for &word in words.iter() {
for &word in words {
let mut v = word;
for _ in 0..uint::BYTES {
result.push(sep);

View file

@ -173,7 +173,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
};
let fields = ty::lookup_struct_fields(self.tcx, id);
for pat in pats.iter() {
for pat in pats {
let field_id = fields.iter()
.find(|field| field.name == pat.node.ident.name).unwrap().id;
self.live_symbols.insert(field_id.node);
@ -318,7 +318,7 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
}
let dead_code = lint::builtin::DEAD_CODE.name_lower();
for attr in lint::gather_attrs(attrs).into_iter() {
for attr in lint::gather_attrs(attrs) {
match attr {
Ok((ref name, lint::Allow, _))
if name.get() == dead_code => return true,
@ -356,7 +356,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
self.worklist.extend(enum_def.variants.iter().map(|variant| variant.node.id));
}
ast::ItemImpl(_, _, _, Some(ref _trait_ref), _, ref impl_items) => {
for impl_item in impl_items.iter() {
for impl_item in impl_items {
match *impl_item {
ast::MethodImplItem(ref method) => {
self.worklist.push(method.id);
@ -397,10 +397,10 @@ fn create_and_seed_worklist(tcx: &ty::ctxt,
// depending on whether a crate is built as bin or lib, and we want
// the warning to be consistent, we also seed the worklist with
// exported symbols.
for id in exported_items.iter() {
for id in exported_items {
worklist.push(*id);
}
for id in reachable_symbols.iter() {
for id in reachable_symbols {
worklist.push(*id);
}
@ -499,8 +499,8 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
match self.tcx.inherent_impls.borrow().get(&local_def(id)) {
None => (),
Some(impl_list) => {
for impl_did in impl_list.iter() {
for item_did in (*impl_items)[*impl_did].iter() {
for impl_did in &**impl_list {
for item_did in &(*impl_items)[*impl_did] {
if self.live_symbols.contains(&item_did.def_id()
.node) {
return true;
@ -536,7 +536,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
} else {
match item.node {
ast::ItemEnum(ref enum_def, _) => {
for variant in enum_def.variants.iter() {
for variant in &enum_def.variants {
if self.should_warn_about_variant(&variant.node) {
self.warn_dead_code(variant.node.id, variant.span,
variant.node.name, "variant");

View file

@ -85,7 +85,7 @@ pub type Dependencies = FnvHashMap<config::CrateType, DependencyList>;
pub fn calculate(tcx: &ty::ctxt) {
let mut fmts = tcx.dependency_formats.borrow_mut();
for &ty in tcx.sess.crate_types.borrow().iter() {
for &ty in &*tcx.sess.crate_types.borrow() {
fmts.insert(ty, calculate_type(&tcx.sess, ty));
}
tcx.sess.abort_if_errors();
@ -148,7 +148,7 @@ fn calculate_type(sess: &session::Session,
debug!("adding dylib: {}", data.name);
add_library(sess, cnum, cstore::RequireDynamic, &mut formats);
let deps = csearch::get_dylib_dependency_formats(&sess.cstore, cnum);
for &(depnum, style) in deps.iter() {
for &(depnum, style) in &deps {
debug!("adding {:?}: {}", style,
sess.cstore.get_crate_data(depnum).name.clone());
add_library(sess, depnum, style, &mut formats);

View file

@ -139,7 +139,7 @@ fn configure_main(this: &mut EntryContext) {
but you have one or more functions named 'main' that are not \
defined at the crate level. Either move the definition or \
attach the `#[main]` attribute to override this behavior.");
for &(_, span) in this.non_main_fns.iter() {
for &(_, span) in &this.non_main_fns {
this.session.span_note(span, "here is a function named 'main'");
}
this.session.abort_if_errors();

View file

@ -342,7 +342,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fn walk_arg_patterns(&mut self,
decl: &ast::FnDecl,
body: &ast::Block) {
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
let arg_ty = return_if_err!(self.typer.node_ty(arg.pat.id));
let fn_body_scope = region::CodeExtent::from_node_id(body.id);
@ -372,7 +372,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
}
fn consume_exprs(&mut self, exprs: &Vec<P<ast::Expr>>) {
for expr in exprs.iter() {
for expr in exprs {
self.consume_expr(&**expr);
}
}
@ -476,7 +476,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
ast::ExprIf(ref cond_expr, ref then_blk, ref opt_else_expr) => {
self.consume_expr(&**cond_expr);
self.walk_block(&**then_blk);
for else_expr in opt_else_expr.iter() {
if let Some(ref else_expr) = *opt_else_expr {
self.consume_expr(&**else_expr);
}
}
@ -490,7 +490,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
self.borrow_expr(&**discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant);
// treatment of the discriminant is handled while walking the arms.
for arm in arms.iter() {
for arm in arms {
let mode = self.arm_move_mode(discr_cmt.clone(), arm);
let mode = mode.match_mode();
self.walk_arm(discr_cmt.clone(), arm, mode);
@ -511,11 +511,11 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
}
ast::ExprInlineAsm(ref ia) => {
for &(_, ref input) in ia.inputs.iter() {
for &(_, ref input) in &ia.inputs {
self.consume_expr(&**input);
}
for &(_, ref output, is_rw) in ia.outputs.iter() {
for &(_, ref output, is_rw) in &ia.outputs {
self.mutate_expr(expr, &**output,
if is_rw { WriteAndRead } else { JustWrite });
}
@ -572,7 +572,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
}
ast::ExprRet(ref opt_expr) => {
for expr in opt_expr.iter() {
if let Some(ref expr) = *opt_expr {
self.consume_expr(&**expr);
}
}
@ -715,11 +715,11 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fn walk_block(&mut self, blk: &ast::Block) {
debug!("walk_block(blk.id={})", blk.id);
for stmt in blk.stmts.iter() {
for stmt in &blk.stmts {
self.walk_stmt(&**stmt);
}
for tail_expr in blk.expr.iter() {
if let Some(ref tail_expr) = blk.expr {
self.consume_expr(&**tail_expr);
}
}
@ -729,7 +729,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fields: &Vec<ast::Field>,
opt_with: &Option<P<ast::Expr>>) {
// Consume the expressions supplying values for each field.
for field in fields.iter() {
for field in fields {
self.consume_expr(&*field.expr);
}
@ -762,7 +762,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
};
// Consume those fields of the with expression that are needed.
for with_field in with_fields.iter() {
for with_field in &with_fields {
if !contains_field_named(with_field, fields) {
let cmt_field = self.mc.cat_field(&*with_expr,
with_cmt.clone(),
@ -908,7 +908,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
match pass_args {
PassArgs::ByValue => {
self.consume_expr(receiver);
for &arg in rhs.iter() {
for &arg in &rhs {
self.consume_expr(arg);
}
@ -926,7 +926,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
let r = ty::ReScope(region::CodeExtent::from_node_id(expr.id));
let bk = ty::ImmBorrow;
for &arg in rhs.iter() {
for &arg in &rhs {
self.borrow_expr(arg, r, bk, OverloadedOperator);
}
return true;
@ -934,18 +934,18 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fn arm_move_mode(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &ast::Arm) -> TrackMatchMode<Span> {
let mut mode = Unknown;
for pat in arm.pats.iter() {
for pat in &arm.pats {
self.determine_pat_move_mode(discr_cmt.clone(), &**pat, &mut mode);
}
mode
}
fn walk_arm(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &ast::Arm, mode: MatchMode) {
for pat in arm.pats.iter() {
for pat in &arm.pats {
self.walk_pat(discr_cmt.clone(), &**pat, mode);
}
for guard in arm.guard.iter() {
if let Some(ref guard) = arm.guard {
self.consume_expr(&**guard);
}
@ -1195,7 +1195,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
debug!("walk_captures({})", closure_expr.repr(self.tcx()));
ty::with_freevars(self.tcx(), closure_expr.id, |freevars| {
for freevar in freevars.iter() {
for freevar in freevars {
let id_var = freevar.def.def_id().node;
let upvar_id = ty::UpvarId { var_id: id_var,
closure_expr_id: closure_expr.id };

View file

@ -116,7 +116,7 @@ pub trait Combine<'tcx> : Sized {
{
let mut substs = subst::Substs::empty();
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
let a_tps = a_subst.types.get_slice(space);
let b_tps = b_subst.types.get_slice(space);
let tps = try!(self.tps(space, a_tps, b_tps));
@ -129,7 +129,7 @@ pub trait Combine<'tcx> : Sized {
}
(&NonerasedRegions(ref a), &NonerasedRegions(ref b)) => {
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
let a_regions = a.get_slice(space);
let b_regions = b.get_slice(space);
@ -139,7 +139,7 @@ pub trait Combine<'tcx> : Sized {
variances.regions.get_slice(space)
}
None => {
for _ in a_regions.iter() {
for _ in a_regions {
invariance.push(ty::Invariant);
}
&invariance[]

View file

@ -170,7 +170,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
errors: &Vec<RegionResolutionError<'tcx>>) {
let p_errors = self.process_errors(errors);
let errors = if p_errors.is_empty() { errors } else { &p_errors };
for error in errors.iter() {
for error in errors {
match error.clone() {
ConcreteFailure(origin, sub, sup) => {
self.report_concrete_failure(origin, sub, sup);
@ -222,7 +222,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
let mut trace_origins = Vec::new();
let mut same_regions = Vec::new();
let mut processed_errors = Vec::new();
for error in errors.iter() {
for error in errors {
match error.clone() {
ConcreteFailure(origin, sub, sup) => {
debug!("processing ConcreteFailure");
@ -257,7 +257,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
}
if !same_regions.is_empty() {
let common_scope_id = same_regions[0].scope_id;
for sr in same_regions.iter() {
for sr in &same_regions {
// Since ProcessedErrors is used to reconstruct the function
// declaration, we want to make sure that they are, in fact,
// from the same scope
@ -335,7 +335,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
same_frs: &FreeRegionsFromSameFn) {
let scope_id = same_frs.scope_id;
let (sub_fr, sup_fr) = (same_frs.sub_fr, same_frs.sup_fr);
for sr in same_regions.iter_mut() {
for sr in &mut *same_regions {
if sr.contains(&sup_fr.bound_region)
&& scope_id == sr.scope_id {
sr.push(sub_fr.bound_region);
@ -796,11 +796,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
var_origins: &[RegionVariableOrigin],
trace_origins: &[(TypeTrace<'tcx>, ty::type_err<'tcx>)],
same_regions: &[SameRegions]) {
for vo in var_origins.iter() {
for vo in var_origins {
self.report_inference_failure(vo.clone());
}
self.give_suggestion(same_regions);
for &(ref trace, terr) in trace_origins.iter() {
for &(ref trace, terr) in trace_origins {
self.report_type_error(trace.clone(), &terr);
}
}
@ -916,7 +916,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
let mut ty_params = self.generics.ty_params.clone();
let where_clause = self.generics.where_clause.clone();
let mut kept_lifetimes = HashSet::new();
for sr in self.same_regions.iter() {
for sr in self.same_regions {
self.cur_anon.set(0);
self.offset_cur_anon();
let (anon_nums, region_names) =
@ -958,7 +958,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
// vector of string and then sort them. However, it makes the
// choice of lifetime name deterministic and thus easier to test.
let mut names = Vec::new();
for rn in region_names.iter() {
for rn in region_names {
let lt_name = token::get_name(*rn).get().to_string();
names.push(lt_name);
}
@ -973,7 +973,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
-> (HashSet<u32>, HashSet<ast::Name>) {
let mut anon_nums = HashSet::new();
let mut region_names = HashSet::new();
for br in same_regions.regions.iter() {
for br in &same_regions.regions {
match *br {
ty::BrAnon(i) => {
anon_nums.insert(i);
@ -989,8 +989,8 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
fn extract_all_region_names(&self) -> HashSet<ast::Name> {
let mut all_region_names = HashSet::new();
for sr in self.same_regions.iter() {
for br in sr.regions.iter() {
for sr in self.same_regions {
for br in &sr.regions {
match *br {
ty::BrNamed(_, name) => {
all_region_names.insert(name);
@ -1123,11 +1123,11 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
where_clause: ast::WhereClause)
-> ast::Generics {
let mut lifetimes = Vec::new();
for lt in add.iter() {
for lt in add {
lifetimes.push(ast::LifetimeDef { lifetime: *lt,
bounds: Vec::new() });
}
for lt in generics.lifetimes.iter() {
for lt in &generics.lifetimes {
if keep.contains(&lt.lifetime.name) ||
!remove.contains(&lt.lifetime.name) {
lifetimes.push((*lt).clone());
@ -1147,7 +1147,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
region_names: &HashSet<ast::Name>)
-> Vec<ast::Arg> {
let mut new_inputs = Vec::new();
for arg in inputs.iter() {
for arg in inputs {
let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime,
anon_nums, region_names);
let possibly_new_arg = ast::Arg {
@ -1729,7 +1729,7 @@ struct LifeGiver {
impl LifeGiver {
fn with_taken(taken: &[ast::LifetimeDef]) -> LifeGiver {
let mut taken_ = HashSet::new();
for lt in taken.iter() {
for lt in taken {
let lt_name = token::get_name(lt.lifetime.name).get().to_string();
taken_.insert(lt_name);
}

View file

@ -176,7 +176,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
// in both A and B. Replace the variable with the "first"
// bound region from A that we find it to be associated
// with.
for (a_br, a_r) in a_map.iter() {
for (a_br, a_r) in a_map {
if tainted.iter().any(|x| x == a_r) {
debug!("generalize_region(r0={:?}): \
replacing with {:?}, tainted={:?}",
@ -258,7 +258,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
let mut a_r = None;
let mut b_r = None;
let mut only_new_vars = true;
for r in tainted.iter() {
for r in &tainted {
if is_var_in_set(a_vars, *r) {
if a_r.is_some() {
return fresh_bound_variable(infcx, debruijn);
@ -315,7 +315,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
r: ty::Region) -> ty::Region
{
for (a_br, a_r) in a_map.iter() {
for (a_br, a_r) in a_map {
if *a_r == r {
return ty::ReLateBound(ty::DebruijnIndex::new(1), *a_br);
}
@ -497,9 +497,9 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
skol_map.repr(infcx.tcx));
let new_vars = infcx.region_vars_confined_to_snapshot(snapshot);
for (&skol_br, &skol) in skol_map.iter() {
for (&skol_br, &skol) in skol_map {
let tainted = infcx.tainted_regions(snapshot, skol);
for &tainted_region in tainted.iter() {
for &tainted_region in &tainted {
// Each skolemized should only be relatable to itself
// or new variables:
match tainted_region {

View file

@ -998,8 +998,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
mk_msg(resolved_expected.map(|t| self.ty_to_string(t)), actual_ty),
error_str)[]);
for err in err.iter() {
ty::note_and_explain_type_err(self.tcx, *err)
if let Some(err) = err {
ty::note_and_explain_type_err(self.tcx, err)
}
}
}

View file

@ -667,7 +667,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
a, b);
}
VerifyGenericBound(_, _, a, ref bs) => {
for &b in bs.iter() {
for &b in bs {
consider_adding_bidirectional_edges(
&mut result_set, r,
a, b);
@ -1200,7 +1200,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
errors: &mut Vec<RegionResolutionError<'tcx>>)
{
let mut reg_reg_dups = FnvHashSet();
for verify in self.verifys.borrow().iter() {
for verify in &*self.verifys.borrow() {
match *verify {
VerifyRegSubReg(ref origin, sub, sup) => {
if self.is_subregion_of(sub, sup) {
@ -1333,7 +1333,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
let dummy_idx = graph.add_node(());
for (constraint, _) in constraints.iter() {
for (constraint, _) in &*constraints {
match *constraint {
ConstrainVarSubVar(a_id, b_id) => {
graph.add_edge(NodeIndex(a_id.index as uint),
@ -1393,8 +1393,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
lower_bounds.sort_by(|a, b| { free_regions_first(a, b) });
upper_bounds.sort_by(|a, b| { free_regions_first(a, b) });
for lower_bound in lower_bounds.iter() {
for upper_bound in upper_bounds.iter() {
for lower_bound in &lower_bounds {
for upper_bound in &upper_bounds {
if !self.is_subregion_of(lower_bound.region,
upper_bound.region) {
errors.push(SubSupConflict(
@ -1435,8 +1435,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
return;
}
for upper_bound_1 in upper_bounds.iter() {
for upper_bound_2 in upper_bounds.iter() {
for upper_bound_1 in &upper_bounds {
for upper_bound_2 in &upper_bounds {
match self.glb_concrete_regions(upper_bound_1.region,
upper_bound_2.region) {
Ok(_) => {}
@ -1554,7 +1554,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
changed = false;
iteration += 1;
debug!("---- {} Iteration {}{}", "#", tag, iteration);
for (constraint, _) in self.constraints.borrow().iter() {
for (constraint, _) in &*self.constraints.borrow() {
let edge_changed = body(constraint);
if edge_changed {
debug!("Updated due to constraint {}",

View file

@ -105,7 +105,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
already instantiated")
};
for &(dir, vid) in relations.iter() {
for &(dir, vid) in &relations {
stack.push((ty, dir, vid));
}
@ -165,7 +165,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
let mut escaping_types = Vec::new();
let actions_since_snapshot = self.values.actions_since_snapshot(&s.snapshot);
debug!("actions_since_snapshot.len() = {}", actions_since_snapshot.len());
for action in actions_since_snapshot.iter() {
for action in actions_since_snapshot {
match *action {
sv::UndoLog::NewElem(index) => {
// if any new variables were created during the

View file

@ -120,7 +120,7 @@ impl LanguageItems {
(self.fn_once_trait(), ty::FnOnceClosureKind),
];
for &(opt_def_id, kind) in def_id_kinds.iter() {
for &(opt_def_id, kind) in &def_id_kinds {
if Some(id) == opt_def_id {
return Some(kind);
}
@ -217,7 +217,7 @@ impl<'a> LanguageItemCollector<'a> {
}
pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
for attribute in attrs.iter() {
for attribute in attrs {
match attribute.value_str() {
Some(ref value) if attribute.check_name("lang") => {
return Some(value.clone());

View file

@ -378,7 +378,7 @@ fn visit_fn(ir: &mut IrMaps,
debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps);
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
pat_util::pat_bindings(&ir.tcx.def_map,
&*arg.pat,
|_bm, arg_id, _x, path1| {
@ -427,7 +427,7 @@ fn visit_local(ir: &mut IrMaps, local: &ast::Local) {
}
fn visit_arm(ir: &mut IrMaps, arm: &ast::Arm) {
for pat in arm.pats.iter() {
for pat in &arm.pats {
pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
debug!("adding local variable {} from match with bm {:?}",
p_id, bm);
@ -464,7 +464,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
// construction site.
let mut call_caps = Vec::new();
ty::with_freevars(ir.tcx, expr.id, |freevars| {
for fv in freevars.iter() {
for fv in freevars {
if let DefLocal(rv) = fv.def {
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
call_caps.push(CaptureInfo {ln: fv_ln,
@ -1049,7 +1049,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let ln = self.live_node(expr.id, expr.span);
self.init_empty(ln, succ);
let mut first_merge = true;
for arm in arms.iter() {
for arm in arms {
let body_succ =
self.propagate_through_expr(&*arm.body, succ);
let guard_succ =
@ -1445,12 +1445,12 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
}
ast::ExprInlineAsm(ref ia) => {
for &(_, ref input) in ia.inputs.iter() {
for &(_, ref input) in &ia.inputs {
this.visit_expr(&**input);
}
// Output operands must be lvalues
for &(_, ref out, _) in ia.outputs.iter() {
for &(_, ref out, _) in &ia.outputs {
this.check_lvalue(&**out);
this.visit_expr(&**out);
}
@ -1590,7 +1590,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
fn warn_about_unused_args(&self, decl: &ast::FnDecl, entry_ln: LiveNode) {
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
pat_util::pat_bindings(&self.ir.tcx.def_map,
&*arg.pat,
|_bm, p_id, sp, path1| {
@ -1620,7 +1620,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
-> bool {
if !self.used_on_entry(ln, var) {
let r = self.should_warn(var);
for name in r.iter() {
if let Some(name) = r {
// annoying: for parameters in funcs like `fn(x: int)
// {ret}`, there is only one node, so asking about
@ -1634,10 +1634,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
if is_assigned {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLES, id, sp,
format!("variable `{}` is assigned to, but never used",
*name));
name));
} else {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLES, id, sp,
format!("unused variable: `{}`", *name));
format!("unused variable: `{}`", name));
}
}
true
@ -1653,9 +1653,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
var: Variable) {
if self.live_on_exit(ln, var).is_none() {
let r = self.should_warn(var);
for name in r.iter() {
if let Some(name) = r {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_ASSIGNMENTS, id, sp,
format!("value assigned to `{}` is never read", *name));
format!("value assigned to `{}` is never read", name));
}
}
}

View file

@ -1208,7 +1208,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
}
}
Some(&def::DefConst(..)) => {
for subpat in subpats.iter() {
for subpat in subpats {
try!(self.cat_pattern_(cmt.clone(), &**subpat, op));
}
}
@ -1230,7 +1230,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
ast::PatStruct(_, ref field_pats, _) => {
// {f1: p1, ..., fN: pN}
for fp in field_pats.iter() {
for fp in field_pats {
let field_ty = try!(self.pat_ty(&*fp.node.pat)); // see (*2)
let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.ident.name, field_ty);
try!(self.cat_pattern_(cmt_field, &*fp.node.pat, op));
@ -1259,15 +1259,15 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
ast::PatVec(ref before, ref slice, ref after) => {
let elt_cmt = try!(self.cat_index(pat, try!(self.deref_vec(pat, cmt))));
for before_pat in before.iter() {
for before_pat in before {
try!(self.cat_pattern_(elt_cmt.clone(), &**before_pat, op));
}
for slice_pat in slice.iter() {
if let Some(ref slice_pat) = *slice {
let slice_ty = try!(self.pat_ty(&**slice_pat));
let slice_cmt = self.cat_rvalue_node(pat.id(), pat.span(), slice_ty);
try!(self.cat_pattern_(slice_cmt, &**slice_pat, op));
}
for after_pat in after.iter() {
for after_pat in after {
try!(self.cat_pattern_(elt_cmt.clone(), &**after_pat, op));
}
}

View file

@ -353,7 +353,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// this properly would result in the necessity of computing *type*
// reachability, which might result in a compile time loss.
fn mark_destructors_reachable(&mut self) {
for (_, destructor_def_id) in self.tcx.destructor_for_type.borrow().iter() {
for (_, destructor_def_id) in &*self.tcx.destructor_for_type.borrow() {
if destructor_def_id.krate == ast::LOCAL_CRATE {
self.reachable_symbols.insert(destructor_def_id.node);
}
@ -371,7 +371,7 @@ pub fn find_reachable(tcx: &ty::ctxt,
// other crates link to us, they're going to expect to be able to
// use the lang items, so we need to be sure to mark them as
// exported.
for id in exported_items.iter() {
for id in exported_items {
reachable_context.worklist.push(*id);
}
for (_, item) in tcx.lang_items.items() {

View file

@ -20,7 +20,7 @@ use syntax::ast;
use syntax::attr::AttrMetaMethods;
pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) {
for attr in krate.attrs.iter() {
for attr in &krate.attrs {
if !attr.check_name("recursion_limit") {
continue;
}

View file

@ -888,14 +888,14 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &ast::Local) {
record_rvalue_scope(visitor, &**subexpr, blk_id);
}
ast::ExprStruct(_, ref fields, _) => {
for field in fields.iter() {
for field in fields {
record_rvalue_scope_if_borrow_expr(
visitor, &*field.expr, blk_id);
}
}
ast::ExprVec(ref subexprs) |
ast::ExprTup(ref subexprs) => {
for subexpr in subexprs.iter() {
for subexpr in subexprs {
record_rvalue_scope_if_borrow_expr(
visitor, &**subexpr, blk_id);
}

View file

@ -187,14 +187,14 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
}
fn visit_generics(&mut self, generics: &ast::Generics) {
for ty_param in generics.ty_params.iter() {
for ty_param in &*generics.ty_params {
visit::walk_ty_param_bounds_helper(self, &ty_param.bounds);
match ty_param.default {
Some(ref ty) => self.visit_ty(&**ty),
None => {}
}
}
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,
@ -207,7 +207,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
.. }) => {
self.visit_lifetime_ref(lifetime);
for bound in bounds.iter() {
for bound in bounds {
self.visit_lifetime_ref(bound);
}
}
@ -229,7 +229,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |old_scope, this| {
this.check_lifetime_defs(old_scope, &trait_ref.bound_lifetimes);
for lifetime in trait_ref.bound_lifetimes.iter() {
for lifetime in &trait_ref.bound_lifetimes {
this.visit_lifetime_def(lifetime);
}
this.visit_trait_ref(&trait_ref.trait_ref)
@ -408,7 +408,7 @@ impl<'a> LifetimeContext<'a> {
let lifetime_i = &lifetimes[i];
let special_idents = [special_idents::static_lifetime];
for lifetime in lifetimes.iter() {
for lifetime in lifetimes {
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
span_err!(self.sess, lifetime.lifetime.span, E0262,
"illegal lifetime parameter name: `{}`",
@ -431,7 +431,7 @@ impl<'a> LifetimeContext<'a> {
// It is a soft error to shadow a lifetime within a parent scope.
self.check_lifetime_def_for_shadowing(old_scope, &lifetime_i.lifetime);
for bound in lifetime_i.bounds.iter() {
for bound in &lifetime_i.bounds {
self.resolve_lifetime_ref(bound);
}
}
@ -535,10 +535,10 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
let mut collector =
FreeLifetimeCollector { early_bound: &mut early_bound,
late_bound: &mut late_bound };
for ty_param in generics.ty_params.iter() {
for ty_param in &*generics.ty_params {
visit::walk_ty_param_bounds_helper(&mut collector, &ty_param.bounds);
}
for predicate in generics.where_clause.predicates.iter() {
for predicate in &generics.where_clause.predicates {
match predicate {
&ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bounds,
ref bounded_ty,
@ -551,7 +551,7 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
..}) => {
collector.visit_lifetime_ref(lifetime);
for bound in bounds.iter() {
for bound in bounds {
collector.visit_lifetime_ref(bound);
}
}
@ -562,11 +562,11 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
// Any lifetime that either has a bound or is referenced by a
// bound is early.
for lifetime_def in generics.lifetimes.iter() {
for lifetime_def in &generics.lifetimes {
if !lifetime_def.bounds.is_empty() {
shuffle(&mut early_bound, &mut late_bound,
lifetime_def.lifetime.name);
for bound in lifetime_def.bounds.iter() {
for bound in &lifetime_def.bounds {
shuffle(&mut early_bound, &mut late_bound,
bound.name);
}

View file

@ -148,7 +148,7 @@ impl Index {
/// Construct the stability index for a crate being compiled.
pub fn build(sess: &Session, krate: &Crate) -> Index {
let mut staged_api = false;
for attr in krate.attrs.iter() {
for attr in &krate.attrs {
if attr.name().get() == "staged_api" {
match attr.node.value.node {
ast::MetaWord(_) => {
@ -273,7 +273,7 @@ pub fn check_item(tcx: &ty::ctxt, item: &ast::Item,
maybe_do_stability_check(tcx, id, item.span, cb);
}
ast::ItemTrait(_, _, ref supertraits, _) => {
for t in supertraits.iter() {
for t in &**supertraits {
if let ast::TraitTyParamBound(ref t, _) = *t {
let id = ty::trait_ref_to_def_id(tcx, &t.trait_ref);
maybe_do_stability_check(tcx, id, t.trait_ref.path.span, cb);
@ -410,11 +410,11 @@ pub fn check_unused_features(sess: &Session,
let mut active_lib_features: FnvHashMap<InternedString, Span>
= lib_features.clone().into_iter().collect();
for used_feature in used_lib_features.iter() {
for used_feature in used_lib_features {
active_lib_features.remove(used_feature);
}
for (_, &span) in active_lib_features.iter() {
for (_, &span) in &active_lib_features {
sess.add_lint(lint::builtin::UNUSED_FEATURES,
ast::CRATE_NODE_ID,
span,

View file

@ -241,7 +241,7 @@ pub struct SeparateVecsPerParamSpace<T> {
impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "VecPerParamSpace {{"));
for space in ParamSpace::all().iter() {
for space in &ParamSpace::all() {
try!(write!(fmt, "{:?}: {:?}, ", *space, self.get_slice(*space)));
}
try!(write!(fmt, "}}"));
@ -317,7 +317,7 @@ impl<T> VecPerParamSpace<T> {
///
/// Unlike the `extend` method in `Vec`, this should not be assumed
/// to be a cheap operation (even when amortized over many calls).
pub fn extend<I:Iterator<Item=T>>(&mut self, space: ParamSpace, mut values: I) {
pub fn extend<I:Iterator<Item=T>>(&mut self, space: ParamSpace, values: I) {
// This could be made more efficient, obviously.
for item in values {
self.push(space, item);
@ -352,7 +352,7 @@ impl<T> VecPerParamSpace<T> {
pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) {
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
self.truncate(space, 0);
for t in elems.into_iter() {
for t in elems {
self.push(space, t);
}
}

View file

@ -35,7 +35,7 @@ provide an impl. To see what I mean, consider the body of `clone_slice`:
fn clone_slice<T:Clone>(x: &[T]) -> Vec<T> {
let mut v = Vec::new();
for e in x.iter() {
for e in &x {
v.push((*e).clone()); // (*)
}
}

View file

@ -28,7 +28,7 @@ use util::ppaux::{Repr, UserString};
pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
errors: &Vec<FulfillmentError<'tcx>>) {
for error in errors.iter() {
for error in errors {
report_fulfillment_error(infcx, error);
}
}
@ -68,7 +68,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
span: Span) -> Option<String> {
let def_id = trait_ref.def_id;
let mut report = None;
for item in ty::get_attrs(infcx.tcx, def_id).iter() {
for item in &*ty::get_attrs(infcx.tcx, def_id) {
if item.check_name("rustc_on_unimplemented") {
let err_sp = if item.meta().span == DUMMY_SP {
span

View file

@ -125,7 +125,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
let mut selcx = SelectionContext::new(infcx, typer);
let normalized = project::normalize_projection_type(&mut selcx, projection_ty, cause, 0);
for obligation in normalized.obligations.into_iter() {
for obligation in normalized.obligations {
self.register_predicate_obligation(infcx, obligation);
}
@ -289,7 +289,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
// Now go through all the successful ones,
// registering any nested obligations for the future.
for new_obligation in new_obligations.into_iter() {
for new_obligation in new_obligations {
self.register_predicate_obligation(selcx.infcx(), new_obligation);
}
}

View file

@ -438,7 +438,7 @@ pub fn normalize_param_env<'a,'tcx>(param_env: &ty::ParameterEnvironment<'a,'tcx
let mut fulfill_cx = FulfillmentContext::new();
let Normalized { value: predicates, obligations } =
project::normalize(selcx, cause, &param_env.caller_bounds);
for obligation in obligations.into_iter() {
for obligation in obligations {
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
}
try!(fulfill_cx.select_all_or_error(selcx.infcx(), param_env));

View file

@ -176,7 +176,7 @@ fn object_safety_violations_for_method<'tcx>(tcx: &ty::ctxt<'tcx>,
// The `Self` type is erased, so it should not appear in list of
// arguments or return type apart from the receiver.
let ref sig = method.fty.sig;
for &input_ty in sig.0.inputs[1..].iter() {
for &input_ty in &sig.0.inputs[1..] {
if contains_illegal_self_type_reference(tcx, trait_def_id, input_ty) {
return Some(MethodViolationCode::ReferencesSelf);
}

View file

@ -802,7 +802,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
let impl_items = &impl_items_map[impl_vtable.impl_def_id];
let mut impl_ty = None;
for impl_item in impl_items.iter() {
for impl_item in impl_items {
let assoc_type = match impl_or_trait_items_map[impl_item.def_id()] {
ty::TypeTraitItem(ref assoc_type) => assoc_type.clone(),
ty::MethodTraitItem(..) => { continue; }

View file

@ -295,7 +295,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
fn evaluate_predicates_recursively<'a,'o,I>(&mut self,
stack: Option<&TraitObligationStack<'o, 'tcx>>,
mut predicates: I)
predicates: I)
-> EvaluationResult<'tcx>
where I : Iterator<Item=&'a PredicateObligation<'tcx>>, 'tcx:'a
{
@ -1089,7 +1089,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!("assemble_candidates_from_impls(self_ty={})", self_ty.repr(self.tcx()));
let all_impls = self.all_impls(obligation.predicate.def_id());
for &impl_def_id in all_impls.iter() {
for &impl_def_id in &all_impls {
self.infcx.probe(|snapshot| {
let (skol_obligation_trait_pred, skol_map) =
self.infcx().skolemize_late_bound_regions(&obligation.predicate, snapshot);

View file

@ -343,7 +343,7 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &ty::ctxt<'tcx>,
}
let trait_items = ty::trait_items(tcx, bound_ref.def_id());
for trait_item in trait_items.iter() {
for trait_item in &**trait_items {
match *trait_item {
ty::MethodTraitItem(_) => method_count += 1,
ty::TypeTraitItem(_) => {}

View file

@ -872,7 +872,7 @@ macro_rules! sty_debug_print {
$(let mut $variant = total;)*
for (_, t) in tcx.interner.borrow().iter() {
for (_, t) in &*tcx.interner.borrow() {
let variant = match t.sty {
ty::ty_bool | ty::ty_char | ty::ty_int(..) | ty::ty_uint(..) |
ty::ty_float(..) | ty::ty_str => continue,
@ -2579,7 +2579,7 @@ impl FlagComputation {
&ty_trait(box TyTrait { ref principal, ref bounds }) => {
let mut computation = FlagComputation::new();
computation.add_substs(principal.0.substs);
for projection_bound in bounds.projection_bounds.iter() {
for projection_bound in &bounds.projection_bounds {
let mut proj_computation = FlagComputation::new();
proj_computation.add_projection_predicate(&projection_bound.0);
computation.add_bound_computation(&proj_computation);
@ -2618,7 +2618,7 @@ impl FlagComputation {
}
fn add_tys(&mut self, tys: &[Ty]) {
for &ty in tys.iter() {
for &ty in tys {
self.add_ty(ty);
}
}
@ -3530,7 +3530,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
// make no assumptions (other than that it cannot have an
// in-scope type parameter within, which makes no sense).
let mut tc = TC::All - TC::InteriorParam;
for bound in bounds.builtin_bounds.iter() {
for bound in &bounds.builtin_bounds {
tc = tc - match bound {
BoundSync | BoundSend | BoundCopy => TC::None,
BoundSized => TC::Nonsized,
@ -4644,7 +4644,7 @@ pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId {
pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
-> uint {
let mut i = 0;
for f in fields.iter() { if f.name == name { return i; } i += 1; }
for f in fields { if f.name == name { return i; } i += 1; }
tcx.sess.bug(&format!(
"no field named `{}` found in the list of fields `{:?}`",
token::get_name(name),
@ -5468,25 +5468,25 @@ pub fn predicates<'tcx>(
{
let mut vec = Vec::new();
for builtin_bound in bounds.builtin_bounds.iter() {
for builtin_bound in &bounds.builtin_bounds {
match traits::trait_ref_for_builtin_bound(tcx, builtin_bound, param_ty) {
Ok(trait_ref) => { vec.push(trait_ref.as_predicate()); }
Err(ErrorReported) => { }
}
}
for &region_bound in bounds.region_bounds.iter() {
for &region_bound in &bounds.region_bounds {
// account for the binder being introduced below; no need to shift `param_ty`
// because, at present at least, it can only refer to early-bound regions
let region_bound = ty_fold::shift_region(region_bound, 1);
vec.push(ty::Binder(ty::OutlivesPredicate(param_ty, region_bound)).as_predicate());
}
for bound_trait_ref in bounds.trait_bounds.iter() {
for bound_trait_ref in &bounds.trait_bounds {
vec.push(bound_trait_ref.as_predicate());
}
for projection in bounds.projection_bounds.iter() {
for projection in &bounds.projection_bounds {
vec.push(projection.as_predicate());
}
@ -5931,17 +5931,17 @@ pub fn populate_implementations_for_type_if_necessary(tcx: &ctxt,
// Record the trait->implementation mappings, if applicable.
let associated_traits = csearch::get_impl_trait(tcx, impl_def_id);
for trait_ref in associated_traits.iter() {
if let Some(ref trait_ref) = associated_traits {
record_trait_implementation(tcx, trait_ref.def_id, impl_def_id);
}
// For any methods that use a default implementation, add them to
// the map. This is a bit unfortunate.
for impl_item_def_id in impl_items.iter() {
for impl_item_def_id in &impl_items {
let method_def_id = impl_item_def_id.def_id();
match impl_or_trait_item(tcx, method_def_id) {
MethodTraitItem(method) => {
for &source in method.provided_source.iter() {
if let Some(source) = method.provided_source {
tcx.provided_method_sources
.borrow_mut()
.insert(method_def_id, source);
@ -5985,11 +5985,11 @@ pub fn populate_implementations_for_trait_if_necessary(
// For any methods that use a default implementation, add them to
// the map. This is a bit unfortunate.
for impl_item_def_id in impl_items.iter() {
for impl_item_def_id in &impl_items {
let method_def_id = impl_item_def_id.def_id();
match impl_or_trait_item(tcx, method_def_id) {
MethodTraitItem(method) => {
for &source in method.provided_source.iter() {
if let Some(source) = method.provided_source {
tcx.provided_method_sources
.borrow_mut()
.insert(method_def_id, source);
@ -6121,7 +6121,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
};
let fn_sig = |&: state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
let sig = anonymize_late_bound_regions(tcx, sig).0;
for a in sig.inputs.iter() { helper(tcx, *a, svh, state); }
for a in &sig.inputs { helper(tcx, *a, svh, state); }
if let ty::FnConverging(output) = sig.output {
helper(tcx, output, svh, state);
}
@ -6270,7 +6270,7 @@ pub fn construct_free_substs<'a,'tcx>(
free_id: ast::NodeId,
region_params: &[RegionParameterDef])
{
for r in region_params.iter() {
for r in region_params {
regions.push(r.space, ty::free_region_from_def(free_id, r));
}
}
@ -6278,7 +6278,7 @@ pub fn construct_free_substs<'a,'tcx>(
fn push_types_from_defs<'tcx>(tcx: &ty::ctxt<'tcx>,
types: &mut VecPerParamSpace<Ty<'tcx>>,
defs: &[TypeParameterDef<'tcx>]) {
for def in defs.iter() {
for def in defs {
debug!("construct_parameter_environment(): push_types_from_defs: def={:?}",
def.repr(tcx));
let ty = ty::mk_param_from_def(tcx, def);
@ -6351,7 +6351,7 @@ pub fn construct_parameter_environment<'a,'tcx>(
fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, predicates: &[ty::Predicate<'tcx>]) {
debug!("record_region_bounds(predicates={:?})", predicates.repr(tcx));
for predicate in predicates.iter() {
for predicate in predicates {
match *predicate {
Predicate::Projection(..) |
Predicate::Trait(..) |
@ -6870,7 +6870,7 @@ pub fn can_type_implement_copy<'a,'tcx>(param_env: &ParameterEnvironment<'a, 'tc
let did = match self_type.sty {
ty::ty_struct(struct_did, substs) => {
let fields = ty::struct_fields(tcx, struct_did, substs);
for field in fields.iter() {
for field in &fields {
if type_moves_by_default(param_env, span, field.mt.ty) {
return Err(FieldDoesNotImplementCopy(field.name))
}
@ -6879,8 +6879,8 @@ pub fn can_type_implement_copy<'a,'tcx>(param_env: &ParameterEnvironment<'a, 'tc
}
ty::ty_enum(enum_did, substs) => {
let enum_variants = ty::enum_variants(tcx, enum_did);
for variant in enum_variants.iter() {
for variant_arg_type in variant.args.iter() {
for variant in &*enum_variants {
for variant_arg_type in &variant.args {
let substd_arg_type =
variant_arg_type.subst(tcx, substs);
if type_moves_by_default(param_env, span, substd_arg_type) {

View file

@ -78,7 +78,7 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
let mut missing = HashSet::new();
sess.cstore.iter_crate_data(|cnum, _| {
for item in csearch::get_missing_lang_items(&sess.cstore, cnum).iter() {
for item in &csearch::get_missing_lang_items(&sess.cstore, cnum) {
missing.insert(*item);
}
});

View file

@ -48,7 +48,7 @@ pub fn find_plugin_registrar(diagnostic: &diagnostic::SpanHandler,
},
_ => {
diagnostic.handler().err("multiple plugin registration functions found");
for &(_, span) in finder.registrars.iter() {
for &(_, span) in &finder.registrars {
diagnostic.span_note(span, "one is here");
}
diagnostic.handler().abort_if_errors();

View file

@ -73,7 +73,7 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
// We need to error on `#[macro_use] extern crate` when it isn't at the
// crate root, because `$crate` won't work properly. Identify these by
// spans, because the crate map isn't set up yet.
for item in krate.module.items.iter() {
for item in &krate.module.items {
if let ast::ItemExternCrate(_) = item.node {
loader.span_whitelist.insert(item.span);
}
@ -82,7 +82,7 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
visit::walk_crate(&mut loader, krate);
if let Some(plugins) = addl_plugins {
for plugin in plugins.iter() {
for plugin in &plugins {
loader.load_plugin(CrateOrString::Str(plugin.as_slice()),
None, None, None)
}
@ -107,7 +107,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
let mut plugin_attr = None;
let mut macro_selection = Some(HashSet::new()); // None => load all
let mut reexport = HashSet::new();
for attr in item.attrs.iter() {
for attr in &item.attrs {
let mut used = true;
match attr.name().get() {
"phase" => {
@ -127,7 +127,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
macro_selection = None;
}
if let (Some(sel), Some(names)) = (macro_selection.as_mut(), names) {
for name in names.iter() {
for name in names {
if let ast::MetaWord(ref name) = name.node {
sel.insert(name.clone());
} else {
@ -145,7 +145,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
}
};
for name in names.iter() {
for name in names {
if let ast::MetaWord(ref name) = name.node {
reexport.insert(name.clone());
} else {
@ -204,7 +204,7 @@ impl<'a> PluginLoader<'a> {
}
}
for mut def in macros.into_iter() {
for mut def in macros {
let name = token::get_ident(def.ident);
def.use_locally = match macro_selection.as_ref() {
None => true,

View file

@ -300,13 +300,13 @@ macro_rules! options {
pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
{
let mut op = $defaultfn();
for option in matches.opt_strs($prefix).into_iter() {
for option in matches.opt_strs($prefix) {
let mut iter = option.splitn(1, '=');
let key = iter.next().unwrap();
let value = iter.next();
let option_to_lookup = key.replace("-", "_");
let mut found = false;
for &(candidate, setter, opt_type_desc, _) in $stat.iter() {
for &(candidate, setter, opt_type_desc, _) in $stat {
if option_to_lookup != candidate { continue }
if !setter(&mut op, value) {
match (value, opt_type_desc) {
@ -830,8 +830,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let mut lint_opts = vec!();
let mut describe_lints = false;
for &level in [lint::Allow, lint::Warn, lint::Deny, lint::Forbid].iter() {
for lint_name in matches.opt_strs(level.as_str()).into_iter() {
for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
for lint_name in matches.opt_strs(level.as_str()) {
if lint_name == "help" {
describe_lints = true;
} else {
@ -853,7 +853,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let mut output_types = Vec::new();
if !debugging_opts.parse_only && !no_trans {
let unparsed_output_types = matches.opt_strs("emit");
for unparsed_output_type in unparsed_output_types.iter() {
for unparsed_output_type in &unparsed_output_types {
for part in unparsed_output_type.split(',') {
let output_type = match part.as_slice() {
"asm" => OutputTypeAssembly,
@ -923,7 +923,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
};
let mut search_paths = SearchPaths::new();
for s in matches.opt_strs("L").iter() {
for s in &matches.opt_strs("L") {
search_paths.add_path(&s[]);
}
@ -997,7 +997,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
};
let mut externs = HashMap::new();
for arg in matches.opt_strs("extern").iter() {
for arg in &matches.opt_strs("extern") {
let mut parts = arg.splitn(1, '=');
let name = match parts.next() {
Some(s) => s,
@ -1049,7 +1049,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
let mut crate_types: Vec<CrateType> = Vec::new();
for unparsed_crate_type in list_list.iter() {
for unparsed_crate_type in &list_list {
for part in unparsed_crate_type.split(',') {
let new_part = match part {
"lib" => default_lib_output(),

View file

@ -163,7 +163,7 @@ pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
while i < queue.len() {
match edges_map.get(&queue[i]) {
Some(edges) => {
for target in edges.iter() {
for target in edges {
if *target == destination {
return true;
}

View file

@ -62,7 +62,7 @@ impl Hasher for FnvHasher {
impl Writer for FnvHasher {
fn write(&mut self, bytes: &[u8]) {
let FnvHasher(mut hash) = *self;
for byte in bytes.iter() {
for byte in bytes {
hash = hash ^ (*byte as u64);
hash = hash * 0x100000001b3;
}

View file

@ -494,11 +494,11 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
0
};
for t in tps[..tps.len() - num_defaults].iter() {
for t in &tps[..tps.len() - num_defaults] {
strs.push(ty_to_string(cx, *t))
}
for projection in projections.iter() {
for projection in projections {
strs.push(format!("{}={}",
projection.projection_ty.item_name.user_string(cx),
projection.ty.user_string(cx)));
@ -665,7 +665,7 @@ impl<'tcx> UserString<'tcx> for ty::TyTrait<'tcx> {
components.push(tap.user_string(tcx));
// Builtin bounds.
for bound in bounds.builtin_bounds.iter() {
for bound in &bounds.builtin_bounds {
components.push(bound.user_string(tcx));
}
@ -748,7 +748,7 @@ impl<'tcx> Repr<'tcx> for subst::RegionSubsts {
impl<'tcx> Repr<'tcx> for ty::BuiltinBounds {
fn repr(&self, _tcx: &ctxt) -> String {
let mut res = Vec::new();
for b in self.iter() {
for b in self {
res.push(match b {
ty::BoundSend => "Send".to_string(),
ty::BoundSized => "Sized".to_string(),
@ -764,7 +764,7 @@ impl<'tcx> Repr<'tcx> for ty::ParamBounds<'tcx> {
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
let mut res = Vec::new();
res.push(self.builtin_bounds.repr(tcx));
for t in self.trait_bounds.iter() {
for t in &self.trait_bounds {
res.push(t.repr(tcx));
}
res.connect("+")
@ -1157,7 +1157,7 @@ impl<'tcx> UserString<'tcx> for ty::ParamBounds<'tcx> {
if !s.is_empty() {
result.push(s);
}
for n in self.trait_bounds.iter() {
for n in &self.trait_bounds {
result.push(n.user_string(tcx));
}
result.connect(" + ")
@ -1173,11 +1173,11 @@ impl<'tcx> Repr<'tcx> for ty::ExistentialBounds<'tcx> {
res.push(region_str);
}
for bound in self.builtin_bounds.iter() {
for bound in &self.builtin_bounds {
res.push(bound.user_string(tcx));
}
for projection_bound in self.projection_bounds.iter() {
for projection_bound in &self.projection_bounds {
res.push(projection_bound.user_string(tcx));
}