1
Fork 0

Conver reborrows to .iter() calls where appropriate

This commit is contained in:
Joshua Landau 2015-06-11 13:56:07 +01:00
parent ca7418b846
commit d7f5fa4636
47 changed files with 109 additions and 109 deletions

View file

@ -130,7 +130,7 @@
//! gadget_owner.gadgets.borrow_mut().push(gadget2.clone().downgrade());
//!
//! // Iterate over our Gadgets, printing their details out
//! for gadget_opt in &*gadget_owner.gadgets.borrow() {
//! for gadget_opt in gadget_owner.gadgets.borrow().iter() {
//!
//! // gadget_opt is a Weak<Gadget>. Since weak pointers can't guarantee
//! // that their object is still allocated, we need to call upgrade()

View file

@ -127,7 +127,7 @@ impl<'longer_than_self> Drop for Arena<'longer_than_self> {
fn drop(&mut self) {
unsafe {
destroy_chunk(&*self.head.borrow());
for chunk in &*self.chunks.borrow() {
for chunk in self.chunks.borrow().iter() {
if !chunk.is_copy.get() {
destroy_chunk(chunk);
}

View file

@ -1639,7 +1639,7 @@ impl<T> Drop for Vec<T> {
// zeroed (when moving out, because of #[unsafe_no_drop_flag]).
if self.cap != 0 && self.cap != mem::POST_DROP_USIZE {
unsafe {
for x in &*self {
for x in self.iter() {
ptr::read(x);
}
dealloc(*self.ptr, self.cap)

View file

@ -558,7 +558,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
}
try!(writeln(w, &["digraph ", g.graph_id().as_slice(), " {"]));
for n in &*g.nodes() {
for n in g.nodes().iter() {
try!(indent(w));
let id = g.node_id(n);
if options.contains(&RenderOption::NoNodeLabels) {
@ -570,7 +570,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
}
}
for e in &*g.edges() {
for e in g.edges().iter() {
let escaped_label = g.edge_label(e).escape();
try!(indent(w));
let source = g.source(e);

View file

@ -704,7 +704,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
}
}
ItemTrait(_, _, ref bounds, ref trait_items) => {
for b in &**bounds {
for b in bounds.iter() {
if let TraitTyParamBound(ref t, TraitBoundModifier::None) = *b {
self.insert(t.trait_ref.ref_id, NodeItem(i));
}

View file

@ -712,7 +712,7 @@ 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() {
for (id, v) in tcx.sess.lints.borrow().iter() {
for &(lint, span, ref msg) in v {
tcx.sess.span_bug(span,
&format!("unprocessed lint {} at {}: {}",

View file

@ -698,7 +698,7 @@ pub fn import_codemap(local_codemap: &codemap::CodeMap,
return false;
}
for (&line1, &line2) in lines1.iter().zip(&*lines2) {
for (&line1, &line2) in lines1.iter().zip(lines2.iter()) {
if (line1 - fm1.start_pos) != (line2 - fm2.start_pos) {
return false;
}
@ -711,7 +711,7 @@ pub fn import_codemap(local_codemap: &codemap::CodeMap,
return false;
}
for (mb1, mb2) in multibytes1.iter().zip(&*multibytes2) {
for (mb1, mb2) in multibytes1.iter().zip(multibytes2.iter()) {
if (mb1.bytes != mb2.bytes) ||
((mb1.pos - fm1.start_pos) != (mb2.pos - fm2.start_pos)) {
return false;

View file

@ -127,7 +127,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() {
for (&k, v) in self.metas.borrow().iter() {
i(k, &**v);
}
}
@ -136,7 +136,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() {
for (&k, v) in self.metas.borrow().iter() {
let origin = self.get_used_crate_source(k);
origin.as_ref().map(|cs| { assert!(k == cs.cnum); });
i(k, &**v, origin);
@ -185,7 +185,7 @@ impl CStore {
}
ordering.push(cnum);
};
for (&num, _) in &*self.metas.borrow() {
for (&num, _) in self.metas.borrow().iter() {
visit(self, num, &mut ordering);
}
ordering.reverse();

View file

@ -377,7 +377,7 @@ 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 {
for base_impl_did in implementations.iter() {
for &method_did in impl_items.get(base_impl_did).unwrap() {
let impl_item = ty::impl_or_trait_item(
ecx.tcx,
@ -403,7 +403,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 {
for trait_item in trait_items.iter() {
if let ty::MethodTraitItem(ref m) = *trait_item {
encode_reexported_static_method(rbml_w,
exp,
@ -981,7 +981,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 {
for &impl_def_id in implementations.iter() {
rbml_w.start_tag(tag_items_data_item_inherent_impl);
encode_def_id(rbml_w, impl_def_id);
rbml_w.end_tag();
@ -1348,7 +1348,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) {
for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() {
rbml_w.start_tag(tag_item_trait_item);
match method_def_id {
ty::ConstTraitItemId(const_def_id) => {
@ -1822,8 +1822,8 @@ fn encode_lang_items(ecx: &EncodeContext, rbml_w: &mut Encoder) {
fn encode_native_libraries(ecx: &EncodeContext, rbml_w: &mut Encoder) {
rbml_w.start_tag(tag_native_libraries);
for &(ref lib, kind) in &*ecx.tcx.sess.cstore.get_used_libraries()
.borrow() {
for &(ref lib, kind) in ecx.tcx.sess.cstore.get_used_libraries()
.borrow().iter() {
match kind {
cstore::NativeStatic => {} // these libraries are not propagated
cstore::NativeFramework | cstore::NativeUnknown => {

View file

@ -491,8 +491,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 {
for item_did in &*impl_items.get(impl_did).unwrap() {
for impl_did in impl_list.iter() {
for item_did in impl_items.get(impl_did).unwrap().iter() {
if self.live_symbols.contains(&item_did.def_id()
.node) {
return true;

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() {
for &ty in tcx.sess.crate_types.borrow().iter() {
fmts.insert(ty, calculate_type(&tcx.sess, ty));
}
tcx.sess.abort_if_errors();

View file

@ -1218,7 +1218,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
errors: &mut Vec<RegionResolutionError<'tcx>>)
{
let mut reg_reg_dups = FnvHashSet();
for verify in &*self.verifys.borrow() {
for verify in self.verifys.borrow().iter() {
match *verify {
VerifyRegSubReg(ref origin, sub, sup) => {
if free_regions.is_subregion_of(self.tcx, sub, sup) {
@ -1350,7 +1350,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
let dummy_idx = graph.add_node(());
for (constraint, _) in &*constraints {
for (constraint, _) in constraints.iter() {
match *constraint {
ConstrainVarSubVar(a_id, b_id) => {
graph.add_edge(NodeIndex(a_id.index as usize),
@ -1575,7 +1575,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
changed = false;
iteration += 1;
debug!("---- {} Iteration {}{}", "#", tag, iteration);
for (constraint, _) in &*self.constraints.borrow() {
for (constraint, _) in self.constraints.borrow().iter() {
let edge_changed = body(constraint);
if edge_changed {
debug!("Updated due to constraint {}",

View file

@ -354,7 +354,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() {
for (_, destructor_def_id) in self.tcx.destructor_for_type.borrow().iter() {
if destructor_def_id.krate == ast::LOCAL_CRATE {
self.reachable_symbols.insert(destructor_def_id.node);
}

View file

@ -372,22 +372,22 @@ struct RegionResolutionVisitor<'a> {
impl RegionMaps {
pub fn each_encl_scope<E>(&self, mut e:E) where E: FnMut(&CodeExtent, &CodeExtent) {
for (child, parent) in &*self.scope_map.borrow() {
for (child, parent) in self.scope_map.borrow().iter() {
e(child, parent)
}
}
pub fn each_var_scope<E>(&self, mut e:E) where E: FnMut(&ast::NodeId, &CodeExtent) {
for (child, parent) in &*self.var_map.borrow() {
for (child, parent) in self.var_map.borrow().iter() {
e(child, parent)
}
}
pub fn each_rvalue_scope<E>(&self, mut e:E) where E: FnMut(&ast::NodeId, &CodeExtent) {
for (child, parent) in &*self.rvalue_scopes.borrow() {
for (child, parent) in self.rvalue_scopes.borrow().iter() {
e(child, parent)
}
}
pub fn each_terminating_scope<E>(&self, mut e:E) where E: FnMut(&CodeExtent) {
for scope in &*self.terminating_scopes.borrow() {
for scope in self.terminating_scopes.borrow().iter() {
e(scope)
}
}

View file

@ -232,7 +232,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
}
fn visit_generics(&mut self, generics: &ast::Generics) {
for ty_param in &*generics.ty_params {
for ty_param in generics.ty_params.iter() {
visit::walk_ty_param_bounds_helper(self, &ty_param.bounds);
match ty_param.default {
Some(ref ty) => self.visit_ty(&**ty),
@ -773,7 +773,7 @@ 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 {
for ty_param in generics.ty_params.iter() {
visit::walk_ty_param_bounds_helper(&mut collector, &ty_param.bounds);
}
for predicate in &generics.where_clause.predicates {

View file

@ -79,7 +79,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) {
for item in ty::get_attrs(infcx.tcx, def_id).iter() {
if item.check_name("rustc_on_unimplemented") {
let err_sp = if item.meta().span == DUMMY_SP {
span

View file

@ -872,7 +872,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
// It is not in the impl - get the default from the trait.
let trait_ref = obligation.predicate.trait_ref;
for trait_item in &*ty::trait_items(selcx.tcx(), trait_ref.def_id) {
for trait_item in ty::trait_items(selcx.tcx(), trait_ref.def_id).iter() {
if let &ty::TypeTraitItem(ref assoc_ty) = trait_item {
if assoc_ty.name == obligation.predicate.item_name {
if let Some(ty) = assoc_ty.ty {

View file

@ -431,7 +431,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 {
for trait_item in trait_items.iter() {
match *trait_item {
ty::MethodTraitItem(_) => method_count += 1,
_ => {}

View file

@ -862,7 +862,7 @@ macro_rules! sty_debug_print {
$(let mut $variant = total;)*
for (_, t) in &*tcx.interner.borrow() {
for (_, t) in tcx.interner.borrow().iter() {
let variant = match t.sty {
ty::ty_bool | ty::ty_char | ty::ty_int(..) | ty::ty_uint(..) |
ty::ty_float(..) | ty::ty_str => continue,
@ -2571,7 +2571,7 @@ impl<'tcx> TraitDef<'tcx> {
pub fn for_each_impl<F: FnMut(DefId)>(&self, tcx: &ctxt<'tcx>, mut f: F) {
ty::populate_implementations_for_trait_if_necessary(tcx, self.trait_ref.def_id);
for &impl_def_id in &*self.blanket_impls.borrow() {
for &impl_def_id in self.blanket_impls.borrow().iter() {
f(impl_def_id);
}
@ -2589,7 +2589,7 @@ impl<'tcx> TraitDef<'tcx> {
{
ty::populate_implementations_for_trait_if_necessary(tcx, self.trait_ref.def_id);
for &impl_def_id in &*self.blanket_impls.borrow() {
for &impl_def_id in self.blanket_impls.borrow().iter() {
f(impl_def_id);
}
@ -7207,7 +7207,7 @@ 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 {
for variant in enum_variants.iter() {
for variant_arg_type in &variant.args {
let substd_arg_type =
variant_arg_type.subst(tcx, substs);

View file

@ -478,14 +478,14 @@ impl<'tcx> MoveData<'tcx> {
KillFrom::Execution, dfcx_moves);
}
for assignment in &*self.path_assignments.borrow() {
for assignment in self.path_assignments.borrow().iter() {
self.kill_moves(assignment.path, assignment.id,
KillFrom::Execution, dfcx_moves);
}
// Kill all moves related to a variable `x` when
// it goes out of scope:
for path in &*self.paths.borrow() {
for path in self.paths.borrow().iter() {
match path.loan_path.kind {
LpVar(..) | LpUpvar(..) | LpDowncast(..) => {
let kill_scope = path.loan_path.kill_scope(tcx);

View file

@ -792,7 +792,7 @@ fn write_out_deps(sess: &Session,
let file = outputs.path(*output_type);
match *output_type {
config::OutputTypeExe => {
for output in &*sess.crate_types.borrow() {
for output in sess.crate_types.borrow().iter() {
let p = link::filename_for_input(sess, *output,
id, &file);
out_filenames.push(p);

View file

@ -645,7 +645,7 @@ impl LintPass for UnusedAttributes {
}
let plugin_attributes = cx.sess().plugin_attributes.borrow_mut();
for &(ref name, ty) in &*plugin_attributes {
for &(ref name, ty) in plugin_attributes.iter() {
if ty == AttributeType::Whitelisted && attr.check_name(&*name) {
break;
}
@ -860,7 +860,7 @@ impl LintPass for NonCamelCaseTypes {
}
fn check_generics(&mut self, cx: &Context, it: &ast::Generics) {
for gen in &*it.ty_params {
for gen in it.ty_params.iter() {
self.check_case(cx, "type parameter", gen.ident, gen.span);
}
}
@ -2249,7 +2249,7 @@ impl LintPass for DropWithReprExtern {
lint_array!(DROP_WITH_REPR_EXTERN)
}
fn check_crate(&mut self, ctx: &Context, _: &ast::Crate) {
for dtor_did in &*ctx.tcx.destructors.borrow() {
for dtor_did in ctx.tcx.destructors.borrow().iter() {
let (drop_impl_did, dtor_self_type) =
if dtor_did.krate == ast::LOCAL_CRATE {
let impl_did = ctx.tcx.map.get_parent_did(dtor_did.node);

View file

@ -1301,7 +1301,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
return
}
for bound in &**bounds {
for bound in bounds.iter() {
self.check_ty_param_bound(bound)
}
}
@ -1466,15 +1466,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
}
fn visit_generics(&mut self, generics: &ast::Generics) {
for ty_param in &*generics.ty_params {
for bound in &*ty_param.bounds {
for ty_param in generics.ty_params.iter() {
for bound in ty_param.bounds.iter() {
self.check_ty_param_bound(bound)
}
}
for predicate in &generics.where_clause.predicates {
match predicate {
&ast::WherePredicate::BoundPredicate(ref bound_pred) => {
for bound in &*bound_pred.bounds {
for bound in bound_pred.bounds.iter() {
self.check_ty_param_bound(bound)
}
}

View file

@ -1574,7 +1574,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Descend into children and anonymous children.
build_reduced_graph::populate_module_if_necessary(self, &module_);
for (_, child_node) in &*module_.children.borrow() {
for (_, child_node) in module_.children.borrow().iter() {
match child_node.get_module_if_available() {
None => {
// Continue.
@ -1585,7 +1585,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}
for (_, module_) in &*module_.anonymous_children.borrow() {
for (_, module_) in module_.anonymous_children.borrow().iter() {
self.report_unresolved_imports(module_.clone());
}
}
@ -2039,7 +2039,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
fn resolve_generics(&mut self, generics: &Generics) {
for type_parameter in &*generics.ty_params {
for type_parameter in generics.ty_params.iter() {
self.check_if_primitive_type_name(type_parameter.ident.name, type_parameter.span);
}
for predicate in &generics.where_clause.predicates {
@ -3502,7 +3502,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
build_reduced_graph::populate_module_if_necessary(self, &search_module);
{
for (_, child_names) in &*search_module.children.borrow() {
for (_, child_names) in search_module.children.borrow().iter() {
let def = match child_names.def_for_namespace(TypeNS) {
Some(def) => def,
None => continue
@ -3518,7 +3518,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
// Look for imports.
for (_, import) in &*search_module.import_resolutions.borrow() {
for (_, import) in search_module.import_resolutions.borrow().iter() {
let target = match import.target_for_namespace(TypeNS) {
None => continue,
Some(target) => target,
@ -3591,13 +3591,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
debug!("Children:");
build_reduced_graph::populate_module_if_necessary(self, &module_);
for (&name, _) in &*module_.children.borrow() {
for (&name, _) in module_.children.borrow().iter() {
debug!("* {}", token::get_name(name));
}
debug!("Import resolutions:");
let import_resolutions = module_.import_resolutions.borrow();
for (&name, import_resolution) in &*import_resolutions {
for (&name, import_resolution) in import_resolutions.iter() {
let value_repr;
match import_resolution.target_for_namespace(ValueNS) {
None => { value_repr = "".to_string(); }

View file

@ -81,7 +81,7 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
self.record_exports_for_module(&*module_);
build_reduced_graph::populate_module_if_necessary(self.resolver, &module_);
for (_, child_name_bindings) in &*module_.children.borrow() {
for (_, child_name_bindings) in module_.children.borrow().iter() {
match child_name_bindings.get_module_if_available() {
None => {
// Nothing to do.
@ -92,7 +92,7 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
}
}
for (_, child_module) in &*module_.anonymous_children.borrow() {
for (_, child_module) in module_.anonymous_children.borrow().iter() {
self.record_exports_for_module_subtree(child_module.clone());
}
}
@ -134,7 +134,7 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
fn add_exports_for_module(&mut self,
exports: &mut Vec<Export>,
module_: &Module) {
for (name, import_resolution) in &*module_.import_resolutions.borrow() {
for (name, import_resolution) in module_.import_resolutions.borrow().iter() {
if !import_resolution.is_public {
continue
}

View file

@ -234,7 +234,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
self.resolver.current_module = orig_module;
build_reduced_graph::populate_module_if_necessary(self.resolver, &module_);
for (_, child_node) in &*module_.children.borrow() {
for (_, child_node) in module_.children.borrow().iter() {
match child_node.get_module_if_available() {
None => {
// Nothing to do.
@ -245,7 +245,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
}
}
for (_, child_module) in &*module_.anonymous_children.borrow() {
for (_, child_module) in module_.anonymous_children.borrow().iter() {
self.resolve_imports_for_module_subtree(child_module.clone());
}
}
@ -732,7 +732,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
// Add all resolved imports from the containing module.
let import_resolutions = target_module.import_resolutions.borrow();
for (ident, target_import_resolution) in &*import_resolutions {
for (ident, target_import_resolution) in import_resolutions.iter() {
debug!("(resolving glob import) writing module resolution \
{} into `{}`",
token::get_name(*ident),
@ -793,7 +793,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
// Add all children from the containing module.
build_reduced_graph::populate_module_if_necessary(self.resolver, &target_module);
for (&name, name_bindings) in &*target_module.children.borrow() {
for (&name, name_bindings) in target_module.children.borrow().iter() {
self.merge_import_resolution(module_,
target_module.clone(),
import_directive,
@ -803,7 +803,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
}
// Add external module children from the containing module.
for (&name, module) in &*target_module.external_module_children.borrow() {
for (&name, module) in target_module.external_module_children.borrow().iter() {
let name_bindings =
Rc::new(Resolver::create_name_bindings_from_module(module.clone()));
self.merge_import_resolution(module_,

View file

@ -204,7 +204,7 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
symbol_hasher.input_str(&link_meta.crate_name);
symbol_hasher.input_str("-");
symbol_hasher.input_str(link_meta.crate_hash.as_str());
for meta in &*tcx.sess.crate_metadata.borrow() {
for meta in tcx.sess.crate_metadata.borrow().iter() {
symbol_hasher.input_str(&meta[..]);
}
symbol_hasher.input_str("-");
@ -389,7 +389,7 @@ pub fn link_binary(sess: &Session,
outputs: &OutputFilenames,
crate_name: &str) -> Vec<PathBuf> {
let mut out_filenames = Vec::new();
for &crate_type in &*sess.crate_types.borrow() {
for &crate_type in sess.crate_types.borrow().iter() {
if invalid_output_for_target(sess, crate_type) {
sess.bug(&format!("invalid output type `{:?}` for target os `{}`",
crate_type, sess.opts.target_triple));
@ -559,7 +559,7 @@ fn link_rlib<'a>(sess: &'a Session,
let mut ab = ArchiveBuilder::create(config);
ab.add_file(obj_filename).unwrap();
for &(ref l, kind) in &*sess.cstore.get_used_libraries().borrow() {
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
match kind {
cstore::NativeStatic => ab.add_native_library(&l).unwrap(),
cstore::NativeFramework | cstore::NativeUnknown => {}
@ -918,7 +918,7 @@ fn link_args(cmd: &mut Linker,
let empty_vec = Vec::new();
let empty_str = String::new();
let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec);
let mut args = args.iter().chain(&*used_link_args);
let mut args = args.iter().chain(used_link_args.iter());
let relocation_model = sess.opts.cg.relocation_model.as_ref()
.unwrap_or(&empty_str);
if (t.options.relocation_model == "pic" || *relocation_model == "pic")

View file

@ -31,7 +31,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
}
// Make sure we actually can run LTO
for crate_type in &*sess.crate_types.borrow() {
for crate_type in sess.crate_types.borrow().iter() {
match *crate_type {
config::CrateTypeExecutable | config::CrateTypeStaticlib => {}
_ => {

View file

@ -727,7 +727,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
&val);
// super-traits
for super_bound in &**trait_refs {
for super_bound in trait_refs.iter() {
let trait_ref = match *super_bound {
ast::TraitTyParamBound(ref trait_ref, _) => {
trait_ref
@ -1202,8 +1202,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
}
fn visit_generics(&mut self, generics: &ast::Generics) {
for param in &*generics.ty_params {
for bound in &*param.bounds {
for param in generics.ty_params.iter() {
for bound in param.bounds.iter() {
if let ast::TraitTyParamBound(ref trait_ref, _) = *bound {
self.process_trait_ref(&trait_ref.trait_ref);
}

View file

@ -233,7 +233,7 @@ pub fn get_extern_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, did: ast::DefId,
// don't do this then linker errors can be generated where the linker
// complains that one object files has a thread local version of the
// symbol and another one doesn't.
for attr in &*ty::get_attrs(ccx.tcx(), did) {
for attr in ty::get_attrs(ccx.tcx(), did).iter() {
if attr.check_name("thread_local") {
llvm::set_thread_local(c, true);
}
@ -2698,7 +2698,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
stats.fn_stats.borrow_mut().sort_by(|&(_, insns_a), &(_, insns_b)| {
insns_b.cmp(&insns_a)
});
for tuple in &*stats.fn_stats.borrow() {
for tuple in stats.fn_stats.borrow().iter() {
match *tuple {
(ref name, insns) => {
println!("{} insns, {}", insns, *name);
@ -2707,7 +2707,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
}
}
if shared_ccx.sess().count_llvm_insns() {
for (k, v) in &*shared_ccx.stats().llvm_insns.borrow() {
for (k, v) in shared_ccx.stats().llvm_insns.borrow().iter() {
println!("{:7} {}", *v, *k);
}
}

View file

@ -106,7 +106,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
ast::ItemEnum(_, _) => {
let vs_here = ty::enum_variants(ccx.tcx(), local_def(item.id));
let vs_there = ty::enum_variants(ccx.tcx(), parent_id);
for (here, there) in vs_here.iter().zip(&*vs_there) {
for (here, there) in vs_here.iter().zip(vs_there.iter()) {
if there.id == fn_id { my_id = here.id.node; }
ccx.external().borrow_mut().insert(there.id, Some(here.id.node));
}

View file

@ -93,7 +93,7 @@ pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Opti
/// the only intrinsic that needs such verification is `transmute`.
pub fn check_intrinsics(ccx: &CrateContext) {
let mut last_failing_id = None;
for transmute_restriction in &*ccx.tcx().transmute_restrictions.borrow() {
for transmute_restriction in ccx.tcx().transmute_restrictions.borrow().iter() {
// Sometimes, a single call to transmute will push multiple
// type pairs to test in order to exhaustively test the
// possibility around a type parameter. If one of those fails,

View file

@ -260,7 +260,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
fn assemble_inherent_candidates(&mut self) {
let steps = self.steps.clone();
for step in &*steps {
for step in steps.iter() {
self.assemble_probe(step.self_ty);
}
}
@ -374,7 +374,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
ty::populate_inherent_implementations_for_type_if_necessary(self.tcx(), def_id);
if let Some(impl_infos) = self.tcx().inherent_impls.borrow().get(&def_id) {
for &impl_def_id in &***impl_infos {
for &impl_def_id in impl_infos.iter() {
self.assemble_inherent_impl_probe(impl_def_id);
}
}
@ -700,7 +700,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
// Check if there is an unboxed-closure self-type in the list of receivers.
// If so, add "synthetic impls".
let steps = self.steps.clone();
for step in &*steps {
for step in steps.iter() {
let closure_def_id = match step.self_ty.sty {
ty::ty_closure(a, _) => a,
_ => continue,
@ -754,7 +754,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
item.repr(self.tcx()),
item_index);
for step in &*self.steps {
for step in self.steps.iter() {
debug!("assemble_projection_candidates: step={}",
step.repr(self.tcx()));

View file

@ -482,7 +482,7 @@ pub fn check_item_types(ccx: &CrateCtxt) {
ccx.tcx.sess.abort_if_errors();
for drop_method_did in &*ccx.tcx.destructors.borrow() {
for drop_method_did in ccx.tcx.destructors.borrow().iter() {
if drop_method_did.krate == ast::LOCAL_CRATE {
let drop_impl_did = ccx.tcx.map.get_parent_did(drop_method_did.node);
match dropck::check_drop_impl(ccx.tcx, drop_impl_did) {
@ -1071,7 +1071,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let provided_methods = ty::provided_trait_methods(tcx, impl_trait_ref.def_id);
let associated_consts = ty::associated_consts(tcx, impl_trait_ref.def_id);
let mut missing_items = Vec::new();
for trait_item in &*trait_items {
for trait_item in trait_items.iter() {
match *trait_item {
ty::ConstTraitItem(ref associated_const) => {
let is_implemented = impl_items.iter().any(|ii| {
@ -4292,7 +4292,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
// we need not check for that.
let variants = ty::enum_variants(ccx.tcx, def_id);
for (v, variant) in vs.iter().zip(&*variants) {
for (v, variant) in vs.iter().zip(variants.iter()) {
let current_disr_val = variant.disr_val;
// Check for duplicate discriminant values

View file

@ -205,7 +205,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
return;
}
for (upvar_id, upvar_capture) in &*self.fcx.inh.upvar_capture_map.borrow() {
for (upvar_id, upvar_capture) in self.fcx.inh.upvar_capture_map.borrow().iter() {
let new_upvar_capture = match *upvar_capture {
ty::UpvarCapture::ByValue => ty::UpvarCapture::ByValue,
ty::UpvarCapture::ByRef(ref upvar_borrow) => {
@ -227,12 +227,12 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
return
}
for (def_id, closure_ty) in &*self.fcx.inh.closure_tys.borrow() {
for (def_id, closure_ty) in self.fcx.inh.closure_tys.borrow().iter() {
let closure_ty = self.resolve(closure_ty, ResolvingClosure(*def_id));
self.fcx.tcx().closure_tys.borrow_mut().insert(*def_id, closure_ty);
}
for (def_id, &closure_kind) in &*self.fcx.inh.closure_kinds.borrow() {
for (def_id, &closure_kind) in self.fcx.inh.closure_kinds.borrow().iter() {
self.fcx.tcx().closure_kinds.borrow_mut().insert(*def_id, closure_kind);
}
}

View file

@ -119,7 +119,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
// the tcx.
let mut tcx_inherent_impls =
self.crate_context.tcx.inherent_impls.borrow_mut();
for (k, v) in &*self.inherent_impls.borrow() {
for (k, v) in self.inherent_impls.borrow().iter() {
tcx_inherent_impls.insert((*k).clone(),
Rc::new((*v.borrow()).clone()));
}

View file

@ -516,7 +516,7 @@ impl<'tcx> GetTypeParameterBounds<'tcx> for ast::Generics {
self.ty_params
.iter()
.filter(|p| p.id == node_id)
.flat_map(|p| &*p.bounds)
.flat_map(|p| p.bounds.iter())
.flat_map(|b| predicates_from_bound(astconv, ty, b));
let from_where_clauses =
@ -528,7 +528,7 @@ impl<'tcx> GetTypeParameterBounds<'tcx> for ast::Generics {
_ => None
})
.filter(|bp| is_param(astconv.tcx(), &bp.bounded_ty, node_id))
.flat_map(|bp| &*bp.bounds)
.flat_map(|bp| bp.bounds.iter())
.flat_map(|b| predicates_from_bound(astconv, ty, b));
from_ty_params.chain(from_where_clauses).collect()
@ -777,8 +777,8 @@ fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
thing: &'static str) {
let mut warn = false;
for ty_param in &*generics.ty_params {
for bound in &*ty_param.bounds {
for ty_param in generics.ty_params.iter() {
for bound in ty_param.bounds.iter() {
match *bound {
ast::TraitTyParamBound(..) => {
warn = true;
@ -1778,7 +1778,7 @@ fn ty_generic_predicates<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
&ExplicitRscope,
&*bound_pred.bounded_ty);
for bound in &*bound_pred.bounds {
for bound in bound_pred.bounds.iter() {
match bound {
&ast::TyParamBound::TraitTyParamBound(ref poly_trait_ref, _) => {
let mut projections = Vec::new();

View file

@ -228,7 +228,7 @@ pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
match tcx.inherent_impls.borrow().get(&did) {
None => {}
Some(i) => {
for &did in &**i {
for &did in i.iter() {
build_impl(cx, tcx, did, &mut impls);
}
}

View file

@ -471,7 +471,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::Result<String> {
// Reduce `NodeId` in paths into smaller sequential numbers,
// and prune the paths that do not appear in the index.
for item in &*search_index {
for item in search_index.iter() {
match item.parent {
Some(nodeid) => {
if !nodeid_to_pathid.contains_key(&nodeid) {

View file

@ -368,7 +368,7 @@ mod imp {
unsafe extern fn run_dtors(mut ptr: *mut u8) {
while !ptr.is_null() {
let list: Box<List> = Box::from_raw(ptr as *mut List);
for &(ptr, dtor) in &*list {
for &(ptr, dtor) in list.iter() {
dtor(ptr);
}
ptr = DTORS.get();

View file

@ -330,7 +330,7 @@ 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 {
for type_parameter in generics.ty_params.iter() {
self.operation.visit_id(type_parameter.id)
}
for lifetime in &generics.lifetimes {

View file

@ -796,7 +796,7 @@ impl CodeMap {
}
pub fn get_filemap(&self, filename: &str) -> Rc<FileMap> {
for fm in &*self.files.borrow() {
for fm in self.files.borrow().iter() {
if filename == fm.name {
return fm.clone();
}
@ -821,7 +821,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() {
for mbc in map.multibyte_chars.borrow().iter() {
debug!("{}-byte char at {:?}", mbc.bytes, mbc.pos);
if mbc.pos < bpos {
// every character is at least one byte, so we only

View file

@ -505,7 +505,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 {
for declared_bound in ty_param.bounds.iter() {
bounds.push((*declared_bound).clone());
}

View file

@ -2110,7 +2110,7 @@ impl<'a> State<'a> {
comma = true;
}
for binding in &*data.bindings {
for binding in data.bindings.iter() {
if comma {
try!(self.word_space(","))
}
@ -2845,7 +2845,7 @@ impl<'a> State<'a> {
}
ast::LitBinary(ref v) => {
let mut escaped: String = String::new();
for &ch in &**v {
for &ch in v.iter() {
escaped.extend(ascii::escape_default(ch)
.map(|c| c as char));
}

View file

@ -428,13 +428,13 @@ 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 {
for typ in data.types.iter() {
visitor.visit_ty(&**typ);
}
for lifetime in &data.lifetimes {
visitor.visit_lifetime_ref(lifetime);
}
for binding in &*data.bindings {
for binding in data.bindings.iter() {
visitor.visit_assoc_type_binding(&**binding);
}
}
@ -531,7 +531,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_ty_param_bounds_helper<'v, V: Visitor<'v>>(visitor: &mut V,
bounds: &'v OwnedSlice<TyParamBound>) {
for bound in &**bounds {
for bound in bounds.iter() {
visitor.visit_ty_param_bound(bound)
}
}
@ -549,7 +549,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
}
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
for param in &*generics.ty_params {
for param in generics.ty_params.iter() {
visitor.visit_ident(param.span, param.ident);
walk_ty_param_bounds_helper(visitor, &param.bounds);
walk_ty_opt(visitor, &param.default);

View file

@ -158,7 +158,7 @@ fn offset_momentum(bodies: &mut [Planet;N_BODIES]) {
let mut px = 0.0;
let mut py = 0.0;
let mut pz = 0.0;
for bi in &*bodies {
for bi in bodies.iter() {
px += bi.vx * bi.mass;
py += bi.vy * bi.mass;
pz += bi.vz * bi.mass;

View file

@ -100,13 +100,13 @@ pub fn main() {
fn check_legs(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
let mut legs = 0;
for pet in &*arc {
for pet in arc.iter() {
legs += pet.num_legs();
}
assert!(legs == 12);
}
fn check_names(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
for pet in &*arc {
for pet in arc.iter() {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
pet.name(Box::new(|name| {
assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8);
@ -114,7 +114,7 @@ fn check_names(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
}
}
fn check_pedigree(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
for pet in &*arc {
for pet in arc.iter() {
assert!(pet.of_good_pedigree());
}
}