Skip to content

Commit ca7418b

Browse files
committed
Removed many pointless calls to *iter() and iter_mut()
1 parent d8a9570 commit ca7418b

File tree

117 files changed

+292
-294
lines changed

Some content is hidden

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

117 files changed

+292
-294
lines changed

src/compiletest/runtest.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
285285
format!("--target={}", config.target),
286286
"-L".to_string(),
287287
aux_dir.to_str().unwrap().to_string());
288-
args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
289-
args.extend(split_maybe_args(&props.compile_flags).into_iter());
288+
args.extend(split_maybe_args(&config.target_rustcflags));
289+
args.extend(split_maybe_args(&props.compile_flags));
290290
return ProcArgs {
291291
prog: config.rustc_path.to_str().unwrap().to_string(),
292292
args: args,
@@ -333,8 +333,8 @@ actual:\n\
333333
config.build_base.to_str().unwrap().to_string(),
334334
"-L".to_string(),
335335
aux_dir.to_str().unwrap().to_string());
336-
args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
337-
args.extend(split_maybe_args(&props.compile_flags).into_iter());
336+
args.extend(split_maybe_args(&config.target_rustcflags));
337+
args.extend(split_maybe_args(&props.compile_flags));
338338
// FIXME (#9639): This needs to handle non-utf8 paths
339339
return ProcArgs {
340340
prog: config.rustc_path.to_str().unwrap().to_string(),
@@ -380,7 +380,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
380380
script_str.push_str(&format!("set solib-search-path \
381381
./{}/stage2/lib/rustlib/{}/lib/\n",
382382
config.host, config.target));
383-
for line in breakpoint_lines.iter() {
383+
for line in &breakpoint_lines {
384384
script_str.push_str(&format!("break {:?}:{}\n",
385385
testfile.file_name().unwrap()
386386
.to_string_lossy(),
@@ -1171,7 +1171,7 @@ fn document(config: &Config, props: &TestProps,
11711171
out_dir.to_str().unwrap().to_string(),
11721172
testfile.to_str().unwrap().to_string()];
11731173
args.extend(extra_args.iter().cloned());
1174-
args.extend(split_maybe_args(&props.compile_flags).into_iter());
1174+
args.extend(split_maybe_args(&props.compile_flags));
11751175
let args = ProcArgs {
11761176
prog: config.rustdoc_path.to_str().unwrap().to_string(),
11771177
args: args,
@@ -1236,7 +1236,7 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
12361236
vec!("--crate-type=dylib".to_string())
12371237
}
12381238
};
1239-
crate_type.extend(extra_link_args.clone().into_iter());
1239+
crate_type.extend(extra_link_args.clone());
12401240
let aux_args =
12411241
make_compile_args(config,
12421242
&aux_props,
@@ -1334,11 +1334,11 @@ fn make_compile_args<F>(config: &Config,
13341334
};
13351335
args.push(path.to_str().unwrap().to_string());
13361336
if props.force_host {
1337-
args.extend(split_maybe_args(&config.host_rustcflags).into_iter());
1337+
args.extend(split_maybe_args(&config.host_rustcflags));
13381338
} else {
1339-
args.extend(split_maybe_args(&config.target_rustcflags).into_iter());
1339+
args.extend(split_maybe_args(&config.target_rustcflags));
13401340
}
1341-
args.extend(split_maybe_args(&props.compile_flags).into_iter());
1341+
args.extend(split_maybe_args(&props.compile_flags));
13421342
return ProcArgs {
13431343
prog: config.rustc_path.to_str().unwrap().to_string(),
13441344
args: args,
@@ -1373,7 +1373,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path)
13731373
args.push(exe_file.to_str().unwrap().to_string());
13741374

13751375
// Add the arguments in the run_flags directive
1376-
args.extend(split_maybe_args(&props.run_flags).into_iter());
1376+
args.extend(split_maybe_args(&props.run_flags));
13771377

13781378
let prog = args.remove(0);
13791379
return ProcArgs {
@@ -1683,7 +1683,7 @@ fn compile_test_and_save_ir(config: &Config, props: &TestProps,
16831683
aux_dir.to_str().unwrap().to_string());
16841684
let llvm_args = vec!("--emit=llvm-ir".to_string(),
16851685
"--crate-type=lib".to_string());
1686-
link_args.extend(llvm_args.into_iter());
1686+
link_args.extend(llvm_args);
16871687
let args = make_compile_args(config,
16881688
props,
16891689
link_args,

src/error-index-generator/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ r##"<!DOCTYPE html>
7373

7474
try!(write!(&mut output_file, "<h1>Rust Compiler Error Index</h1>\n"));
7575

76-
for (err_code, info) in err_map.iter() {
76+
for (err_code, info) in err_map {
7777
// Enclose each error in a div so they can be shown/hidden en masse.
7878
let desc_desc = match info.description {
7979
Some(_) => "error-described",

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().iter() {
133+
//! for gadget_opt in &*gadget_owner.gadgets.borrow() {
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/libcollections/binary_heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
//!
8686
//! // For each node we can reach, see if we can find a way with
8787
//! // a lower cost going through this node
88-
//! for edge in adj_list[position].iter() {
88+
//! for edge in &adj_list[position] {
8989
//! let next = State { cost: cost + edge.cost, position: edge.node };
9090
//!
9191
//! // If so, add it to the frontier and continue
@@ -450,7 +450,7 @@ impl<T: Ord> BinaryHeap<T> {
450450
/// let vec = heap.into_vec();
451451
///
452452
/// // Will print in some order
453-
/// for x in vec.iter() {
453+
/// for x in vec {
454454
/// println!("{}", x);
455455
/// }
456456
/// ```

src/libcollections/bit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ impl BitVec {
266266
/// # #![feature(collections)]
267267
/// use std::collections::BitVec;
268268
///
269-
/// let mut bv = BitVec::from_elem(10, false);
269+
/// let bv = BitVec::from_elem(10, false);
270270
/// assert_eq!(bv.len(), 10);
271-
/// for x in bv.iter() {
271+
/// for x in &bv {
272272
/// assert_eq!(x, false);
273273
/// }
274274
/// ```
@@ -1245,7 +1245,7 @@ impl<'a> IntoIterator for &'a BitVec {
12451245
/// s.union_with(&other);
12461246
///
12471247
/// // Print 0, 1, 3 in some order
1248-
/// for x in s.iter() {
1248+
/// for x in &s {
12491249
/// println!("{}", x);
12501250
/// }
12511251
///
@@ -1370,7 +1370,7 @@ impl BitSet {
13701370
/// let s = BitSet::from_bit_vec(bv);
13711371
///
13721372
/// // Print 1, 2 in arbitrary order
1373-
/// for x in s.iter() {
1373+
/// for x in &s {
13741374
/// println!("{}", x);
13751375
/// }
13761376
/// ```

src/libcollections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ impl<K: Ord, V> Default for BTreeMap<K, V> {
907907
impl<K: PartialEq, V: PartialEq> PartialEq for BTreeMap<K, V> {
908908
fn eq(&self, other: &BTreeMap<K, V>) -> bool {
909909
self.len() == other.len() &&
910-
self.iter().zip(other.iter()).all(|(a, b)| a == b)
910+
self.iter().zip(other).all(|(a, b)| a == b)
911911
}
912912
}
913913

@@ -1544,7 +1544,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
15441544
/// for (_, balance) in map.range_mut(Included(&"B"), Excluded(&"Cheryl")) {
15451545
/// *balance += 100;
15461546
/// }
1547-
/// for (name, balance) in map.iter() {
1547+
/// for (name, balance) in &map {
15481548
/// println!("{} => {}", name, balance);
15491549
/// }
15501550
/// ```

src/libcollections/linked_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl<T> LinkedList<T> {
265265
///
266266
/// a.append(&mut b);
267267
///
268-
/// for e in a.iter() {
268+
/// for e in &a {
269269
/// println!("{}", e); // prints 1, then 2, then 3, then 4
270270
/// }
271271
/// println!("{}", b.len()); // prints 0
@@ -1189,7 +1189,7 @@ mod tests {
11891189
check_links(&m);
11901190

11911191
let mut i = 0;
1192-
for (a, &b) in m.into_iter().zip(v.iter()) {
1192+
for (a, &b) in m.into_iter().zip(&v) {
11931193
i += 1;
11941194
assert_eq!(a, b);
11951195
}

src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ impl<T> [T] {
971971
reason = "uncertain about this API approach")]
972972
#[inline]
973973
pub fn move_from(&mut self, mut src: Vec<T>, start: usize, end: usize) -> usize {
974-
for (a, b) in self.iter_mut().zip(src[start .. end].iter_mut()) {
974+
for (a, b) in self.iter_mut().zip(&mut src[start .. end]) {
975975
mem::swap(a, b);
976976
}
977977
cmp::min(self.len(), end-start)

src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ impl str {
18901890
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
18911891
pub fn to_uppercase(&self) -> String {
18921892
let mut s = String::with_capacity(self.len());
1893-
s.extend(self[..].chars().flat_map(|c| c.to_uppercase()));
1893+
s.extend(self.chars().flat_map(|c| c.to_uppercase()));
18941894
return s;
18951895
}
18961896

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ impl<T:Clone> Clone for Vec<T> {
13311331
}
13321332

13331333
// reuse the contained values' allocations/resources.
1334-
for (place, thing) in self.iter_mut().zip(other.iter()) {
1334+
for (place, thing) in self.iter_mut().zip(other) {
13351335
place.clone_from(thing)
13361336
}
13371337

0 commit comments

Comments
 (0)