summary refs log tree commit diff
path: root/src/libcoretest
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/libcoretest
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/libcoretest')
-rw-r--r--src/libcoretest/iter.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs
index 64c33609399..cadbc238e67 100644
--- a/src/libcoretest/iter.rs
+++ b/src/libcoretest/iter.rs
@@ -137,8 +137,8 @@ fn test_iterator_take_while() {
     let ys = [0u, 1, 2, 3, 5, 13];
     let mut it = xs.iter().take_while(|&x| *x < 15u);
     let mut i = 0;
-    for &x in it {
-        assert_eq!(x, ys[i]);
+    for x in it {
+        assert_eq!(*x, ys[i]);
         i += 1;
     }
     assert_eq!(i, ys.len());
@@ -150,8 +150,8 @@ fn test_iterator_skip_while() {
     let ys = [15, 16, 17, 19];
     let mut it = xs.iter().skip_while(|&x| *x < 15u);
     let mut i = 0;
-    for &x in it {
-        assert_eq!(x, ys[i]);
+    for x in it {
+        assert_eq!(*x, ys[i]);
         i += 1;
     }
     assert_eq!(i, ys.len());