about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-25 02:21:14 +0000
committerbors <bors@rust-lang.org>2014-07-25 02:21:14 +0000
commitb9035c26e2c4368b39c8daa979f669d10d484825 (patch)
treeecaa8a3b6163ebbfe44c9dc85884e9f870d80f30 /src/libstd
parenta4553453a0f928a4d49492d87b352552919ae4c2 (diff)
parentcaa564bea3d5f5a24d0797c4769184c1ea0abaff (diff)
downloadrust-b9035c26e2c4368b39c8daa979f669d10d484825.tar.gz
rust-b9035c26e2c4368b39c8daa979f669d10d484825.zip
auto merge of #15809 : pcwalton/rust/dedesugar-for, r=pnkfelix
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/libstd')
-rw-r--r--src/libstd/io/tempfile.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs
index 5ca7e417af6..f580dfd80f0 100644
--- a/src/libstd/io/tempfile.rs
+++ b/src/libstd/io/tempfile.rs
@@ -12,7 +12,7 @@
 
 use io::{fs, IoResult};
 use io;
-use iter::{Iterator, range};
+use iter::range;
 use libc;
 use ops::Drop;
 use option::{Option, None, Some};
@@ -21,6 +21,9 @@ use path::{Path, GenericPath};
 use result::{Ok, Err};
 use sync::atomics;
 
+#[cfg(stage0)]
+use iter::Iterator; // NOTE(stage0): Remove after snapshot.
+
 /// A wrapper for a path to temporary directory implementing automatic
 /// scope-based deletion.
 pub struct TempDir {