Skip to content

Commit d7f5fa4

Browse files
committed
Conver reborrows to .iter() calls where appropriate
1 parent ca7418b commit d7f5fa4

File tree

47 files changed

+109
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+109
-109
lines changed

src/liballoc/rc.rs

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

src/libarena/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'longer_than_self> Drop for Arena<'longer_than_self> {
127127
fn drop(&mut self) {
128128
unsafe {
129129
destroy_chunk(&*self.head.borrow());
130-
for chunk in &*self.chunks.borrow() {
130+
for chunk in self.chunks.borrow().iter() {
131131
if !chunk.is_copy.get() {
132132
destroy_chunk(chunk);
133133
}

src/libcollections/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ impl<T> Drop for Vec<T> {
16391639
// zeroed (when moving out, because of #[unsafe_no_drop_flag]).
16401640
if self.cap != 0 && self.cap != mem::POST_DROP_USIZE {
16411641
unsafe {
1642-
for x in &*self {
1642+
for x in self.iter() {
16431643
ptr::read(x);
16441644
}
16451645
dealloc(*self.ptr, self.cap)

src/libgraphviz/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
558558
}
559559

560560
try!(writeln(w, &["digraph ", g.graph_id().as_slice(), " {"]));
561-
for n in &*g.nodes() {
561+
for n in g.nodes().iter() {
562562
try!(indent(w));
563563
let id = g.node_id(n);
564564
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
570570
}
571571
}
572572

573-
for e in &*g.edges() {
573+
for e in g.edges().iter() {
574574
let escaped_label = g.edge_label(e).escape();
575575
try!(indent(w));
576576
let source = g.source(e);

src/librustc/ast_map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
704704
}
705705
}
706706
ItemTrait(_, _, ref bounds, ref trait_items) => {
707-
for b in &**bounds {
707+
for b in bounds.iter() {
708708
if let TraitTyParamBound(ref t, TraitBoundModifier::None) = *b {
709709
self.insert(t.trait_ref.ref_id, NodeItem(i));
710710
}

src/librustc/lint/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ pub fn check_crate(tcx: &ty::ctxt,
712712

713713
// If we missed any lints added to the session, then there's a bug somewhere
714714
// in the iteration code.
715-
for (id, v) in &*tcx.sess.lints.borrow() {
715+
for (id, v) in tcx.sess.lints.borrow().iter() {
716716
for &(lint, span, ref msg) in v {
717717
tcx.sess.span_bug(span,
718718
&format!("unprocessed lint {} at {}: {}",

src/librustc/metadata/creader.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ pub fn import_codemap(local_codemap: &codemap::CodeMap,
698698
return false;
699699
}
700700

701-
for (&line1, &line2) in lines1.iter().zip(&*lines2) {
701+
for (&line1, &line2) in lines1.iter().zip(lines2.iter()) {
702702
if (line1 - fm1.start_pos) != (line2 - fm2.start_pos) {
703703
return false;
704704
}
@@ -711,7 +711,7 @@ pub fn import_codemap(local_codemap: &codemap::CodeMap,
711711
return false;
712712
}
713713

714-
for (mb1, mb2) in multibytes1.iter().zip(&*multibytes2) {
714+
for (mb1, mb2) in multibytes1.iter().zip(multibytes2.iter()) {
715715
if (mb1.bytes != mb2.bytes) ||
716716
((mb1.pos - fm1.start_pos) != (mb2.pos - fm2.start_pos)) {
717717
return false;

src/librustc/metadata/cstore.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl CStore {
127127
pub fn iter_crate_data<I>(&self, mut i: I) where
128128
I: FnMut(ast::CrateNum, &crate_metadata),
129129
{
130-
for (&k, v) in &*self.metas.borrow() {
130+
for (&k, v) in self.metas.borrow().iter() {
131131
i(k, &**v);
132132
}
133133
}
@@ -136,7 +136,7 @@ impl CStore {
136136
pub fn iter_crate_data_origins<I>(&self, mut i: I) where
137137
I: FnMut(ast::CrateNum, &crate_metadata, Option<CrateSource>),
138138
{
139-
for (&k, v) in &*self.metas.borrow() {
139+
for (&k, v) in self.metas.borrow().iter() {
140140
let origin = self.get_used_crate_source(k);
141141
origin.as_ref().map(|cs| { assert!(k == cs.cnum); });
142142
i(k, &**v, origin);
@@ -185,7 +185,7 @@ impl CStore {
185185
}
186186
ordering.push(cnum);
187187
};
188-
for (&num, _) in &*self.metas.borrow() {
188+
for (&num, _) in self.metas.borrow().iter() {
189189
visit(self, num, &mut ordering);
190190
}
191191
ordering.reverse();

src/librustc/metadata/encoder.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
377377
let impl_items = ecx.tcx.impl_items.borrow();
378378
match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
379379
Some(implementations) => {
380-
for base_impl_did in &**implementations {
380+
for base_impl_did in implementations.iter() {
381381
for &method_did in impl_items.get(base_impl_did).unwrap() {
382382
let impl_item = ty::impl_or_trait_item(
383383
ecx.tcx,
@@ -403,7 +403,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
403403
-> bool {
404404
match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
405405
Some(trait_items) => {
406-
for trait_item in &**trait_items {
406+
for trait_item in trait_items.iter() {
407407
if let ty::MethodTraitItem(ref m) = *trait_item {
408408
encode_reexported_static_method(rbml_w,
409409
exp,
@@ -981,7 +981,7 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
981981
match ecx.tcx.inherent_impls.borrow().get(&def_id) {
982982
None => {}
983983
Some(implementations) => {
984-
for &impl_def_id in &**implementations {
984+
for &impl_def_id in implementations.iter() {
985985
rbml_w.start_tag(tag_items_data_item_inherent_impl);
986986
encode_def_id(rbml_w, impl_def_id);
987987
rbml_w.end_tag();
@@ -1348,7 +1348,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
13481348
encode_attributes(rbml_w, &item.attrs);
13491349
encode_visibility(rbml_w, vis);
13501350
encode_stability(rbml_w, stab);
1351-
for &method_def_id in &*ty::trait_item_def_ids(tcx, def_id) {
1351+
for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() {
13521352
rbml_w.start_tag(tag_item_trait_item);
13531353
match method_def_id {
13541354
ty::ConstTraitItemId(const_def_id) => {
@@ -1822,8 +1822,8 @@ fn encode_lang_items(ecx: &EncodeContext, rbml_w: &mut Encoder) {
18221822
fn encode_native_libraries(ecx: &EncodeContext, rbml_w: &mut Encoder) {
18231823
rbml_w.start_tag(tag_native_libraries);
18241824

1825-
for &(ref lib, kind) in &*ecx.tcx.sess.cstore.get_used_libraries()
1826-
.borrow() {
1825+
for &(ref lib, kind) in ecx.tcx.sess.cstore.get_used_libraries()
1826+
.borrow().iter() {
18271827
match kind {
18281828
cstore::NativeStatic => {} // these libraries are not propagated
18291829
cstore::NativeFramework | cstore::NativeUnknown => {

src/librustc/middle/dead.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
491491
match self.tcx.inherent_impls.borrow().get(&local_def(id)) {
492492
None => (),
493493
Some(impl_list) => {
494-
for impl_did in &**impl_list {
495-
for item_did in &*impl_items.get(impl_did).unwrap() {
494+
for impl_did in impl_list.iter() {
495+
for item_did in impl_items.get(impl_did).unwrap().iter() {
496496
if self.live_symbols.contains(&item_did.def_id()
497497
.node) {
498498
return true;

src/librustc/middle/dependency_format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub type Dependencies = FnvHashMap<config::CrateType, DependencyList>;
8585

8686
pub fn calculate(tcx: &ty::ctxt) {
8787
let mut fmts = tcx.dependency_formats.borrow_mut();
88-
for &ty in &*tcx.sess.crate_types.borrow() {
88+
for &ty in tcx.sess.crate_types.borrow().iter() {
8989
fmts.insert(ty, calculate_type(&tcx.sess, ty));
9090
}
9191
tcx.sess.abort_if_errors();

src/librustc/middle/infer/region_inference/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
12181218
errors: &mut Vec<RegionResolutionError<'tcx>>)
12191219
{
12201220
let mut reg_reg_dups = FnvHashSet();
1221-
for verify in &*self.verifys.borrow() {
1221+
for verify in self.verifys.borrow().iter() {
12221222
match *verify {
12231223
VerifyRegSubReg(ref origin, sub, sup) => {
12241224
if free_regions.is_subregion_of(self.tcx, sub, sup) {
@@ -1350,7 +1350,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
13501350
}
13511351
let dummy_idx = graph.add_node(());
13521352

1353-
for (constraint, _) in &*constraints {
1353+
for (constraint, _) in constraints.iter() {
13541354
match *constraint {
13551355
ConstrainVarSubVar(a_id, b_id) => {
13561356
graph.add_edge(NodeIndex(a_id.index as usize),
@@ -1575,7 +1575,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
15751575
changed = false;
15761576
iteration += 1;
15771577
debug!("---- {} Iteration {}{}", "#", tag, iteration);
1578-
for (constraint, _) in &*self.constraints.borrow() {
1578+
for (constraint, _) in self.constraints.borrow().iter() {
15791579
let edge_changed = body(constraint);
15801580
if edge_changed {
15811581
debug!("Updated due to constraint {}",

src/librustc/middle/reachable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
354354
// this properly would result in the necessity of computing *type*
355355
// reachability, which might result in a compile time loss.
356356
fn mark_destructors_reachable(&mut self) {
357-
for (_, destructor_def_id) in &*self.tcx.destructor_for_type.borrow() {
357+
for (_, destructor_def_id) in self.tcx.destructor_for_type.borrow().iter() {
358358
if destructor_def_id.krate == ast::LOCAL_CRATE {
359359
self.reachable_symbols.insert(destructor_def_id.node);
360360
}

src/librustc/middle/region.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -372,22 +372,22 @@ struct RegionResolutionVisitor<'a> {
372372

373373
impl RegionMaps {
374374
pub fn each_encl_scope<E>(&self, mut e:E) where E: FnMut(&CodeExtent, &CodeExtent) {
375-
for (child, parent) in &*self.scope_map.borrow() {
375+
for (child, parent) in self.scope_map.borrow().iter() {
376376
e(child, parent)
377377
}
378378
}
379379
pub fn each_var_scope<E>(&self, mut e:E) where E: FnMut(&ast::NodeId, &CodeExtent) {
380-
for (child, parent) in &*self.var_map.borrow() {
380+
for (child, parent) in self.var_map.borrow().iter() {
381381
e(child, parent)
382382
}
383383
}
384384
pub fn each_rvalue_scope<E>(&self, mut e:E) where E: FnMut(&ast::NodeId, &CodeExtent) {
385-
for (child, parent) in &*self.rvalue_scopes.borrow() {
385+
for (child, parent) in self.rvalue_scopes.borrow().iter() {
386386
e(child, parent)
387387
}
388388
}
389389
pub fn each_terminating_scope<E>(&self, mut e:E) where E: FnMut(&CodeExtent) {
390-
for scope in &*self.terminating_scopes.borrow() {
390+
for scope in self.terminating_scopes.borrow().iter() {
391391
e(scope)
392392
}
393393
}

src/librustc/middle/resolve_lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
232232
}
233233

234234
fn visit_generics(&mut self, generics: &ast::Generics) {
235-
for ty_param in &*generics.ty_params {
235+
for ty_param in generics.ty_params.iter() {
236236
visit::walk_ty_param_bounds_helper(self, &ty_param.bounds);
237237
match ty_param.default {
238238
Some(ref ty) => self.visit_ty(&**ty),
@@ -773,7 +773,7 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
773773
let mut collector =
774774
FreeLifetimeCollector { early_bound: &mut early_bound,
775775
late_bound: &mut late_bound };
776-
for ty_param in &*generics.ty_params {
776+
for ty_param in generics.ty_params.iter() {
777777
visit::walk_ty_param_bounds_helper(&mut collector, &ty_param.bounds);
778778
}
779779
for predicate in &generics.where_clause.predicates {

src/librustc/middle/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
7979
span: Span) -> Option<String> {
8080
let def_id = trait_ref.def_id;
8181
let mut report = None;
82-
for item in &*ty::get_attrs(infcx.tcx, def_id) {
82+
for item in ty::get_attrs(infcx.tcx, def_id).iter() {
8383
if item.check_name("rustc_on_unimplemented") {
8484
let err_sp = if item.meta().span == DUMMY_SP {
8585
span

src/librustc/middle/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
872872

873873
// It is not in the impl - get the default from the trait.
874874
let trait_ref = obligation.predicate.trait_ref;
875-
for trait_item in &*ty::trait_items(selcx.tcx(), trait_ref.def_id) {
875+
for trait_item in ty::trait_items(selcx.tcx(), trait_ref.def_id).iter() {
876876
if let &ty::TypeTraitItem(ref assoc_ty) = trait_item {
877877
if assoc_ty.name == obligation.predicate.item_name {
878878
if let Some(ty) = assoc_ty.ty {

src/librustc/middle/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &ty::ctxt<'tcx>,
431431
}
432432

433433
let trait_items = ty::trait_items(tcx, bound_ref.def_id());
434-
for trait_item in &**trait_items {
434+
for trait_item in trait_items.iter() {
435435
match *trait_item {
436436
ty::MethodTraitItem(_) => method_count += 1,
437437
_ => {}

src/librustc/middle/ty.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ macro_rules! sty_debug_print {
862862
$(let mut $variant = total;)*
863863

864864

865-
for (_, t) in &*tcx.interner.borrow() {
865+
for (_, t) in tcx.interner.borrow().iter() {
866866
let variant = match t.sty {
867867
ty::ty_bool | ty::ty_char | ty::ty_int(..) | ty::ty_uint(..) |
868868
ty::ty_float(..) | ty::ty_str => continue,
@@ -2571,7 +2571,7 @@ impl<'tcx> TraitDef<'tcx> {
25712571
pub fn for_each_impl<F: FnMut(DefId)>(&self, tcx: &ctxt<'tcx>, mut f: F) {
25722572
ty::populate_implementations_for_trait_if_necessary(tcx, self.trait_ref.def_id);
25732573

2574-
for &impl_def_id in &*self.blanket_impls.borrow() {
2574+
for &impl_def_id in self.blanket_impls.borrow().iter() {
25752575
f(impl_def_id);
25762576
}
25772577

@@ -2589,7 +2589,7 @@ impl<'tcx> TraitDef<'tcx> {
25892589
{
25902590
ty::populate_implementations_for_trait_if_necessary(tcx, self.trait_ref.def_id);
25912591

2592-
for &impl_def_id in &*self.blanket_impls.borrow() {
2592+
for &impl_def_id in self.blanket_impls.borrow().iter() {
25932593
f(impl_def_id);
25942594
}
25952595

@@ -7207,7 +7207,7 @@ pub fn can_type_implement_copy<'a,'tcx>(param_env: &ParameterEnvironment<'a, 'tc
72077207
}
72087208
ty::ty_enum(enum_did, substs) => {
72097209
let enum_variants = ty::enum_variants(tcx, enum_did);
7210-
for variant in &*enum_variants {
7210+
for variant in enum_variants.iter() {
72117211
for variant_arg_type in &variant.args {
72127212
let substd_arg_type =
72137213
variant_arg_type.subst(tcx, substs);

src/librustc_borrowck/borrowck/move_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,14 @@ impl<'tcx> MoveData<'tcx> {
478478
KillFrom::Execution, dfcx_moves);
479479
}
480480

481-
for assignment in &*self.path_assignments.borrow() {
481+
for assignment in self.path_assignments.borrow().iter() {
482482
self.kill_moves(assignment.path, assignment.id,
483483
KillFrom::Execution, dfcx_moves);
484484
}
485485

486486
// Kill all moves related to a variable `x` when
487487
// it goes out of scope:
488-
for path in &*self.paths.borrow() {
488+
for path in self.paths.borrow().iter() {
489489
match path.loan_path.kind {
490490
LpVar(..) | LpUpvar(..) | LpDowncast(..) => {
491491
let kill_scope = path.loan_path.kill_scope(tcx);

src/librustc_driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ fn write_out_deps(sess: &Session,
792792
let file = outputs.path(*output_type);
793793
match *output_type {
794794
config::OutputTypeExe => {
795-
for output in &*sess.crate_types.borrow() {
795+
for output in sess.crate_types.borrow().iter() {
796796
let p = link::filename_for_input(sess, *output,
797797
id, &file);
798798
out_filenames.push(p);

src/librustc_lint/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ impl LintPass for UnusedAttributes {
645645
}
646646

647647
let plugin_attributes = cx.sess().plugin_attributes.borrow_mut();
648-
for &(ref name, ty) in &*plugin_attributes {
648+
for &(ref name, ty) in plugin_attributes.iter() {
649649
if ty == AttributeType::Whitelisted && attr.check_name(&*name) {
650650
break;
651651
}
@@ -860,7 +860,7 @@ impl LintPass for NonCamelCaseTypes {
860860
}
861861

862862
fn check_generics(&mut self, cx: &Context, it: &ast::Generics) {
863-
for gen in &*it.ty_params {
863+
for gen in it.ty_params.iter() {
864864
self.check_case(cx, "type parameter", gen.ident, gen.span);
865865
}
866866
}
@@ -2249,7 +2249,7 @@ impl LintPass for DropWithReprExtern {
22492249
lint_array!(DROP_WITH_REPR_EXTERN)
22502250
}
22512251
fn check_crate(&mut self, ctx: &Context, _: &ast::Crate) {
2252-
for dtor_did in &*ctx.tcx.destructors.borrow() {
2252+
for dtor_did in ctx.tcx.destructors.borrow().iter() {
22532253
let (drop_impl_did, dtor_self_type) =
22542254
if dtor_did.krate == ast::LOCAL_CRATE {
22552255
let impl_did = ctx.tcx.map.get_parent_did(dtor_did.node);

src/librustc_privacy/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
13011301
return
13021302
}
13031303

1304-
for bound in &**bounds {
1304+
for bound in bounds.iter() {
13051305
self.check_ty_param_bound(bound)
13061306
}
13071307
}
@@ -1466,15 +1466,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
14661466
}
14671467

14681468
fn visit_generics(&mut self, generics: &ast::Generics) {
1469-
for ty_param in &*generics.ty_params {
1470-
for bound in &*ty_param.bounds {
1469+
for ty_param in generics.ty_params.iter() {
1470+
for bound in ty_param.bounds.iter() {
14711471
self.check_ty_param_bound(bound)
14721472
}
14731473
}
14741474
for predicate in &generics.where_clause.predicates {
14751475
match predicate {
14761476
&ast::WherePredicate::BoundPredicate(ref bound_pred) => {
1477-
for bound in &*bound_pred.bounds {
1477+
for bound in bound_pred.bounds.iter() {
14781478
self.check_ty_param_bound(bound)
14791479
}
14801480
}

0 commit comments

Comments
 (0)