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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 2 additions & 2 deletions
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;

0 commit comments

Comments
 (0)