Skip to content

Commit 7335c7d

Browse files
committed
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
2 parents 075588a + 3484706 commit 7335c7d

File tree

319 files changed

+1308
-1443
lines changed

Some content is hidden

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

319 files changed

+1308
-1443
lines changed

src/compiletest/compiletest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
277277
config.src_base.display());
278278
let mut tests = Vec::new();
279279
let dirs = fs::readdir(&config.src_base).unwrap();
280-
for file in dirs.iter() {
280+
for file in &dirs {
281281
let file = file.clone();
282282
debug!("inspecting file {:?}", file.display());
283283
if is_test(config, &file) {
@@ -305,13 +305,13 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
305305

306306
let mut valid = false;
307307

308-
for ext in valid_extensions.iter() {
308+
for ext in &valid_extensions {
309309
if name.ends_with(ext.as_slice()) {
310310
valid = true;
311311
}
312312
}
313313

314-
for pre in invalid_prefixes.iter() {
314+
for pre in &invalid_prefixes {
315315
if name.starts_with(pre.as_slice()) {
316316
valid = false;
317317
}

src/compiletest/procsrv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ pub fn run(lib_path: &str,
4040
let mut cmd = Command::new(prog);
4141
cmd.args(args);
4242
add_target_env(&mut cmd, lib_path, aux_path);
43-
for (key, val) in env.into_iter() {
43+
for (key, val) in env {
4444
cmd.env(key, val);
4545
}
4646

4747
match cmd.spawn() {
4848
Ok(mut process) => {
49-
for input in input.iter() {
49+
if let Some(input) = input {
5050
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
5151
}
5252
let ProcessOutput { status, output, error } =
@@ -72,13 +72,13 @@ pub fn run_background(lib_path: &str,
7272
let mut cmd = Command::new(prog);
7373
cmd.args(args);
7474
add_target_env(&mut cmd, lib_path, aux_path);
75-
for (key, val) in env.into_iter() {
75+
for (key, val) in env {
7676
cmd.env(key, val);
7777
}
7878

7979
match cmd.spawn() {
8080
Ok(mut process) => {
81-
for input in input.iter() {
81+
if let Some(input) = input {
8282
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
8383
}
8484

src/compiletest/runtest.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
547547
exe_file.as_str().unwrap().replace("\\", "\\\\"))[]);
548548

549549
// Add line breakpoints
550-
for line in breakpoint_lines.iter() {
550+
for line in &breakpoint_lines {
551551
script_str.push_str(&format!("break '{}':{}\n",
552552
testfile.filename_display(),
553553
*line)[]);
@@ -683,13 +683,13 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
683683
script_str.push_str("type category enable Rust\n");
684684

685685
// Set breakpoints on every line that contains the string "#break"
686-
for line in breakpoint_lines.iter() {
686+
for line in &breakpoint_lines {
687687
script_str.push_str(format!("breakpoint set --line {}\n",
688688
line).as_slice());
689689
}
690690

691691
// Append the other commands
692-
for line in commands.iter() {
692+
for line in &commands {
693693
script_str.push_str(line.as_slice());
694694
script_str.push_str("\n");
695695
}
@@ -847,7 +847,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
847847
let mut rest = line.trim();
848848
let mut first = true;
849849
let mut failed = false;
850-
for frag in check_fragments[i].iter() {
850+
for frag in &check_fragments[i] {
851851
let found = if first {
852852
if rest.starts_with(frag.as_slice()) {
853853
Some(0)
@@ -915,7 +915,7 @@ fn check_error_patterns(props: &TestProps,
915915
missing_patterns[0]).as_slice(),
916916
proc_res);
917917
} else {
918-
for pattern in missing_patterns.iter() {
918+
for pattern in missing_patterns {
919919
error(format!("error pattern '{}' not found!",
920920
*pattern).as_slice());
921921
}
@@ -935,7 +935,7 @@ fn check_no_compiler_crash(proc_res: &ProcRes) {
935935
fn check_forbid_output(props: &TestProps,
936936
output_to_check: &str,
937937
proc_res: &ProcRes) {
938-
for pat in props.forbid_output.iter() {
938+
for pat in &props.forbid_output {
939939
if output_to_check.contains(pat.as_slice()) {
940940
fatal_proc_rec("forbidden pattern found in compiler output", proc_res);
941941
}
@@ -1173,7 +1173,7 @@ fn compose_and_run_compiler(
11731173
// FIXME (#9639): This needs to handle non-utf8 paths
11741174
let extra_link_args = vec!("-L".to_string(), aux_dir.as_str().unwrap().to_string());
11751175

1176-
for rel_ab in props.aux_builds.iter() {
1176+
for rel_ab in &props.aux_builds {
11771177
let abs_ab = config.aux_base.join(rel_ab.as_slice());
11781178
let aux_props = header::load_props(&abs_ab);
11791179
let mut crate_type = if aux_props.no_prefer_dynamic {
@@ -1503,14 +1503,14 @@ fn _arm_exec_compiled_test(config: &Config,
15031503

15041504
// run test via adb_run_wrapper
15051505
runargs.push("shell".to_string());
1506-
for (key, val) in env.into_iter() {
1506+
for (key, val) in env {
15071507
runargs.push(format!("{}={}", key, val));
15081508
}
15091509
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));
15101510
runargs.push(format!("{}", config.adb_test_dir));
15111511
runargs.push(format!("{}", prog_short));
15121512

1513-
for tv in args.args.iter() {
1513+
for tv in &args.args {
15141514
runargs.push(tv.to_string());
15151515
}
15161516
procsrv::run("",
@@ -1591,7 +1591,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
15911591
let tdir = aux_output_dir_name(config, testfile);
15921592

15931593
let dirs = fs::readdir(&tdir).unwrap();
1594-
for file in dirs.iter() {
1594+
for file in &dirs {
15951595
if file.extension_str() == Some("so") {
15961596
// FIXME (#9639): This needs to handle non-utf8 paths
15971597
let copy_result = procsrv::run("",

src/compiletest/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[
2727
];
2828

2929
pub fn get_os(triple: &str) -> &'static str {
30-
for &(triple_os, os) in OS_TABLE.iter() {
30+
for &(triple_os, os) in OS_TABLE {
3131
if triple.contains(triple_os) {
3232
return os
3333
}

src/libarena/lib.rs

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

src/libcollections/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn find_rand_n<M, T, I, F>(n: uint,
7373
let mut keys = (0..n).map(|_| rng.gen::<uint>() % n)
7474
.collect::<Vec<_>>();
7575

76-
for k in keys.iter() {
76+
for k in &keys {
7777
insert(map, *k);
7878
}
7979

src/libcollections/binary_heap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
673673

674674
#[stable(feature = "rust1", since = "1.0.0")]
675675
impl<T: Ord> Extend<T> for BinaryHeap<T> {
676-
fn extend<Iter: Iterator<Item=T>>(&mut self, mut iter: Iter) {
676+
fn extend<Iter: Iterator<Item=T>>(&mut self, iter: Iter) {
677677
let (lower, _) = iter.size_hint();
678678

679679
self.reserve(lower);
@@ -696,7 +696,7 @@ mod tests {
696696
let iterout = [9, 5, 3];
697697
let heap = BinaryHeap::from_vec(data);
698698
let mut i = 0;
699-
for el in heap.iter() {
699+
for el in &heap {
700700
assert_eq!(*el, iterout[i]);
701701
i += 1;
702702
}
@@ -884,7 +884,7 @@ mod tests {
884884

885885
let mut q: BinaryHeap<uint> = xs.iter().rev().map(|&x| x).collect();
886886

887-
for &x in xs.iter() {
887+
for &x in &xs {
888888
assert_eq!(q.pop().unwrap(), x);
889889
}
890890
}

src/libcollections/bit.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl Bitv {
431431
/// ```
432432
#[inline]
433433
pub fn set_all(&mut self) {
434-
for w in self.storage.iter_mut() { *w = !0u32; }
434+
for w in &mut self.storage { *w = !0u32; }
435435
self.fix_last_block();
436436
}
437437

@@ -451,7 +451,7 @@ impl Bitv {
451451
/// ```
452452
#[inline]
453453
pub fn negate(&mut self) {
454-
for w in self.storage.iter_mut() { *w = !*w; }
454+
for w in &mut self.storage { *w = !*w; }
455455
self.fix_last_block();
456456
}
457457

@@ -912,7 +912,7 @@ impl Bitv {
912912
#[inline]
913913
#[stable(feature = "rust1", since = "1.0.0")]
914914
pub fn clear(&mut self) {
915-
for w in self.storage.iter_mut() { *w = 0u32; }
915+
for w in &mut self.storage { *w = 0u32; }
916916
}
917917
}
918918

@@ -934,7 +934,7 @@ impl FromIterator<bool> for Bitv {
934934
#[stable(feature = "rust1", since = "1.0.0")]
935935
impl Extend<bool> for Bitv {
936936
#[inline]
937-
fn extend<I: Iterator<Item=bool>>(&mut self, mut iterator: I) {
937+
fn extend<I: Iterator<Item=bool>>(&mut self, iterator: I) {
938938
let (min, _) = iterator.size_hint();
939939
self.reserve(min);
940940
for element in iterator {
@@ -976,7 +976,7 @@ impl Ord for Bitv {
976976
#[stable(feature = "rust1", since = "1.0.0")]
977977
impl fmt::Debug for Bitv {
978978
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
979-
for bit in self.iter() {
979+
for bit in self {
980980
try!(write!(fmt, "{}", if bit { 1u32 } else { 0u32 }));
981981
}
982982
Ok(())
@@ -1141,7 +1141,7 @@ impl FromIterator<uint> for BitvSet {
11411141
#[stable(feature = "rust1", since = "1.0.0")]
11421142
impl Extend<uint> for BitvSet {
11431143
#[inline]
1144-
fn extend<I: Iterator<Item=uint>>(&mut self, mut iterator: I) {
1144+
fn extend<I: Iterator<Item=uint>>(&mut self, iterator: I) {
11451145
for i in iterator {
11461146
self.insert(i);
11471147
}
@@ -1353,7 +1353,7 @@ impl BitvSet {
13531353
}
13541354

13551355
// virtually pad other with 0's for equal lengths
1356-
let mut other_words = {
1356+
let other_words = {
13571357
let (_, result) = match_words(self_bitv, other_bitv);
13581358
result
13591359
};
@@ -1743,7 +1743,7 @@ impl fmt::Debug for BitvSet {
17431743
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
17441744
try!(write!(fmt, "BitvSet {{"));
17451745
let mut first = true;
1746-
for n in self.iter() {
1746+
for n in self {
17471747
if !first {
17481748
try!(write!(fmt, ", "));
17491749
}
@@ -1756,7 +1756,7 @@ impl fmt::Debug for BitvSet {
17561756

17571757
impl<S: hash::Writer + hash::Hasher> hash::Hash<S> for BitvSet {
17581758
fn hash(&self, state: &mut S) {
1759-
for pos in self.iter() {
1759+
for pos in self {
17601760
pos.hash(state);
17611761
}
17621762
}
@@ -2600,7 +2600,7 @@ mod bitv_bench {
26002600
b.iter(|| {
26012601
let mut sum = 0u;
26022602
for _ in 0u..10 {
2603-
for pres in bitv.iter() {
2603+
for pres in &bitv {
26042604
sum += pres as uint;
26052605
}
26062606
}
@@ -2613,7 +2613,7 @@ mod bitv_bench {
26132613
let bitv = Bitv::from_elem(BENCH_BITS, false);
26142614
b.iter(|| {
26152615
let mut sum = 0u;
2616-
for pres in bitv.iter() {
2616+
for pres in &bitv {
26172617
sum += pres as uint;
26182618
}
26192619
sum
@@ -2674,8 +2674,8 @@ mod bitv_set_test {
26742674
fn test_bitv_set_frombitv_init() {
26752675
let bools = [true, false];
26762676
let lengths = [10, 64, 100];
2677-
for &b in bools.iter() {
2678-
for &l in lengths.iter() {
2677+
for &b in &bools {
2678+
for &l in &lengths {
26792679
let bitset = BitvSet::from_bitv(Bitv::from_elem(l, b));
26802680
assert_eq!(bitset.contains(&1u), b);
26812681
assert_eq!(bitset.contains(&(l-1u)), b);
@@ -3062,7 +3062,7 @@ mod bitv_set_bench {
30623062
|idx| {idx % 3 == 0}));
30633063
b.iter(|| {
30643064
let mut sum = 0u;
3065-
for idx in bitv.iter() {
3065+
for idx in &bitv {
30663066
sum += idx as uint;
30673067
}
30683068
sum

src/libcollections/btree/map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
197197
pub fn clear(&mut self) {
198198
let b = self.b;
199199
// avoid recursive destructors by manually traversing the tree
200-
for _ in mem::replace(self, BTreeMap::with_b(b)).into_iter() {};
200+
for _ in mem::replace(self, BTreeMap::with_b(b)) {};
201201
}
202202

203203
// Searching in a B-Tree is pretty straightforward.
@@ -846,7 +846,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
846846
#[stable(feature = "rust1", since = "1.0.0")]
847847
impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
848848
#[inline]
849-
fn extend<T: Iterator<Item=(K, V)>>(&mut self, mut iter: T) {
849+
fn extend<T: Iterator<Item=(K, V)>>(&mut self, iter: T) {
850850
for (k, v) in iter {
851851
self.insert(k, v);
852852
}
@@ -856,7 +856,7 @@ impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
856856
#[stable(feature = "rust1", since = "1.0.0")]
857857
impl<S: Hasher, K: Hash<S>, V: Hash<S>> Hash<S> for BTreeMap<K, V> {
858858
fn hash(&self, state: &mut S) {
859-
for elt in self.iter() {
859+
for elt in self {
860860
elt.hash(state);
861861
}
862862
}
@@ -1946,7 +1946,7 @@ mod bench {
19461946
}
19471947

19481948
b.iter(|| {
1949-
for entry in map.iter() {
1949+
for entry in &map {
19501950
black_box(entry);
19511951
}
19521952
});

src/libcollections/btree/node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,13 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> {
435435
let mut vals = RawItems::from_parts(ret.vals().as_ptr(), 0);
436436
let mut edges = RawItems::from_parts(ret.edges().as_ptr(), 0);
437437

438-
for key in self.keys().iter() {
438+
for key in self.keys() {
439439
keys.push(key.clone())
440440
}
441-
for val in self.vals().iter() {
441+
for val in self.vals() {
442442
vals.push(val.clone())
443443
}
444-
for edge in self.edges().iter() {
444+
for edge in self.edges() {
445445
edges.push(edge.clone())
446446
}
447447

src/libcollections/btree/set.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl<'a, T> IntoIterator for &'a BTreeSet<T> {
499499
#[stable(feature = "rust1", since = "1.0.0")]
500500
impl<T: Ord> Extend<T> for BTreeSet<T> {
501501
#[inline]
502-
fn extend<Iter: Iterator<Item=T>>(&mut self, mut iter: Iter) {
502+
fn extend<Iter: Iterator<Item=T>>(&mut self, iter: Iter) {
503503
for elem in iter {
504504
self.insert(elem);
505505
}
@@ -791,8 +791,8 @@ mod test {
791791
let mut set_a = BTreeSet::new();
792792
let mut set_b = BTreeSet::new();
793793

794-
for x in a.iter() { assert!(set_a.insert(*x)) }
795-
for y in b.iter() { assert!(set_b.insert(*y)) }
794+
for x in a { assert!(set_a.insert(*x)) }
795+
for y in b { assert!(set_b.insert(*y)) }
796796

797797
let mut i = 0;
798798
f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
@@ -894,7 +894,7 @@ mod test {
894894

895895
let set: BTreeSet<int> = xs.iter().map(|&x| x).collect();
896896

897-
for x in xs.iter() {
897+
for x in &xs {
898898
assert!(set.contains(x));
899899
}
900900
}

0 commit comments

Comments
 (0)