about summary refs log tree commit diff
path: root/src/test/bench
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-07-21 20:54:28 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-07-24 18:58:12 -0700
commitcaa564bea3d5f5a24d0797c4769184c1ea0abaff (patch)
treef0f1b5d284efe24018586e85fb5b442e8b578283 /src/test/bench
parent7f2e63ec3f6f03ac9273a9f166a4ce8deff48097 (diff)
downloadrust-caa564bea3d5f5a24d0797c4769184c1ea0abaff.tar.gz
rust-caa564bea3d5f5a24d0797c4769184c1ea0abaff.zip
librustc: Stop desugaring `for` expressions and translate them directly.
This makes edge cases in which the `Iterator` trait was not in scope
and/or `Option` or its variants were not in scope work properly.

This breaks code that looks like:

    struct MyStruct { ... }

    impl MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

    for x in MyStruct { ... } { ... }

Change ad-hoc `next` methods like the above to implementations of the
`Iterator` trait. For example:

    impl Iterator<int> for MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

Closes #15392.

[breaking-change]
Diffstat (limited to 'src/test/bench')
-rw-r--r--src/test/bench/shootout-meteor.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs
index e13c53407e4..615dd1d69d5 100644
--- a/src/test/bench/shootout-meteor.rs
+++ b/src/test/bench/shootout-meteor.rs
@@ -297,10 +297,10 @@ fn search(
     // for every unused piece
     for id in range(0u, 10).filter(|id| board & (1 << (id + 50)) == 0) {
         // for each mask that fits on the board
-        for &m in masks_at.get(id).iter().filter(|&m| board & *m == 0) {
+        for m in masks_at.get(id).iter().filter(|&m| board & *m == 0) {
             // This check is too costy.
             //if is_board_unfeasible(board | m, masks) {continue;}
-            search(masks, board | m, i + 1, Cons(m, &cur), data);
+            search(masks, board | *m, i + 1, Cons(*m, &cur), data);
         }
     }
 }
@@ -311,9 +311,10 @@ fn par_search(masks: Vec<Vec<Vec<u64>>>) -> Data {
 
     // launching the search in parallel on every masks at minimum
     // coordinate (0,0)
-    for &m in masks.get(0).iter().flat_map(|masks_pos| masks_pos.iter()) {
+    for m in masks.get(0).iter().flat_map(|masks_pos| masks_pos.iter()) {
         let masks = masks.clone();
         let tx = tx.clone();
+        let m = *m;
         spawn(proc() {
             let mut data = Data::new();
             search(&*masks, m, 1, Cons(m, &Nil), &mut data);