From e7273784c7a80d8099e495015753d70e63e6d432 Mon Sep 17 00:00:00 2001
From: Jorge Aparicio <japaricious@gmail.com>
Date: Fri, 13 Feb 2015 17:55:10 -0500
Subject: [PATCH] add an associated `Item` type to `IntoIterator`

---
 src/libcollections/binary_heap.rs  | 24 +++++++++++++++
 src/libcollections/bit.rs          | 24 +++++++++++++++
 src/libcollections/btree/map.rs    | 36 ++++++++++++++++++++++
 src/libcollections/btree/set.rs    | 24 +++++++++++++++
 src/libcollections/dlist.rs        | 36 ++++++++++++++++++++++
 src/libcollections/enum_set.rs     | 12 ++++++++
 src/libcollections/ring_buf.rs     | 36 ++++++++++++++++++++++
 src/libcollections/vec.rs          | 36 ++++++++++++++++++++++
 src/libcollections/vec_map.rs      | 36 ++++++++++++++++++++++
 src/libcore/array.rs               | 24 +++++++++++++++
 src/libcore/iter.rs                | 25 ++++++++++++++++
 src/libcore/slice.rs               | 24 +++++++++++++++
 src/librustc/middle/subst.rs       | 24 +++++++++++++++
 src/libstd/collections/hash/map.rs | 48 ++++++++++++++++++++++++++++++
 src/libstd/collections/hash/set.rs | 32 ++++++++++++++++++++
 15 files changed, 441 insertions(+)

diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs
index 11576fbb00c..e786027d73b 100644
--- a/src/libcollections/binary_heap.rs
+++ b/src/libcollections/binary_heap.rs
@@ -655,6 +655,8 @@ impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T: Ord> IntoIterator for BinaryHeap<T> {
     type IntoIter = IntoIter<T>;
 
@@ -663,6 +665,18 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T: Ord> IntoIterator for BinaryHeap<T> {
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
     type IntoIter = Iter<'a, T>;
 
@@ -671,6 +685,16 @@ impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
+    type Item = &'a T;
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.iter()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Ord> Extend<T> for BinaryHeap<T> {
     fn extend<Iter: Iterator<Item=T>>(&mut self, iter: Iter) {
diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs
index 6d15a264172..ca598a8d4d2 100644
--- a/src/libcollections/bit.rs
+++ b/src/libcollections/bit.rs
@@ -1070,6 +1070,8 @@ impl<'a> RandomAccessIterator for Iter<'a> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a> IntoIterator for &'a Bitv {
     type IntoIter = Iter<'a>;
 
@@ -1078,6 +1080,16 @@ impl<'a> IntoIterator for &'a Bitv {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a> IntoIterator for &'a Bitv {
+    type Item = bool;
+    type IntoIter = Iter<'a>;
+
+    fn into_iter(self) -> Iter<'a> {
+        self.iter()
+    }
+}
+
 /// An implementation of a set using a bit vector as an underlying
 /// representation for holding unsigned numerical elements.
 ///
@@ -1882,6 +1894,8 @@ impl<'a> Iterator for SymmetricDifference<'a> {
     #[inline] fn size_hint(&self) -> (usize, Option<usize>) { self.0.size_hint() }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a> IntoIterator for &'a BitvSet {
     type IntoIter = SetIter<'a>;
 
@@ -1890,6 +1904,16 @@ impl<'a> IntoIterator for &'a BitvSet {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a> IntoIterator for &'a BitvSet {
+    type Item = usize;
+    type IntoIter = SetIter<'a>;
+
+    fn into_iter(self) -> SetIter<'a> {
+        self.iter()
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use prelude::*;
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 0e4a4002d6a..e83ba478ada 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -462,6 +462,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<K, V> IntoIterator for BTreeMap<K, V> {
     type IntoIter = IntoIter<K, V>;
 
@@ -470,6 +472,18 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<K, V> IntoIterator for BTreeMap<K, V> {
+    type Item = (K, V);
+    type IntoIter = IntoIter<K, V>;
+
+    fn into_iter(self) -> IntoIter<K, V> {
+        self.into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
     type IntoIter = Iter<'a, K, V>;
 
@@ -478,6 +492,18 @@ impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, K, V> IntoIterator for &'a BTreeMap<K, V> {
+    type Item = (&'a K, &'a V);
+    type IntoIter = Iter<'a, K, V>;
+
+    fn into_iter(self) -> Iter<'a, K, V> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
     type IntoIter = IterMut<'a, K, V>;
 
@@ -486,6 +512,16 @@ impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
+    type Item = (&'a K, &'a mut V);
+    type IntoIter = IterMut<'a, K, V>;
+
+    fn into_iter(mut self) -> IterMut<'a, K, V> {
+        self.iter_mut()
+    }
+}
+
 /// A helper enum useful for deciding whether to continue a loop since we can't
 /// return from a closure
 enum Continuation<A, B> {
diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs
index 7cb31ab1f6d..ac2168db699 100644
--- a/src/libcollections/btree/set.rs
+++ b/src/libcollections/btree/set.rs
@@ -480,6 +480,8 @@ impl<T: Ord> FromIterator<T> for BTreeSet<T> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T> IntoIterator for BTreeSet<T> {
     type IntoIter = IntoIter<T>;
 
@@ -488,6 +490,18 @@ impl<T> IntoIterator for BTreeSet<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T> IntoIterator for BTreeSet<T> {
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a BTreeSet<T> {
     type IntoIter = Iter<'a, T>;
 
@@ -496,6 +510,16 @@ impl<'a, T> IntoIterator for &'a BTreeSet<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a BTreeSet<T> {
+    type Item = &'a T;
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.iter()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Ord> Extend<T> for BTreeSet<T> {
     #[inline]
diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs
index a080146e0ec..a6219a8faeb 100644
--- a/src/libcollections/dlist.rs
+++ b/src/libcollections/dlist.rs
@@ -830,6 +830,8 @@ impl<A> FromIterator<A> for DList<A> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T> IntoIterator for DList<T> {
     type IntoIter = IntoIter<T>;
 
@@ -838,6 +840,18 @@ impl<T> IntoIterator for DList<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T> IntoIterator for DList<T> {
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a DList<T> {
     type IntoIter = Iter<'a, T>;
 
@@ -846,6 +860,18 @@ impl<'a, T> IntoIterator for &'a DList<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a DList<T> {
+    type Item = &'a T;
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a mut DList<T> {
     type IntoIter = IterMut<'a, T>;
 
@@ -854,6 +880,16 @@ impl<'a, T> IntoIterator for &'a mut DList<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a mut DList<T> {
+    type Item = &'a mut T;
+    type IntoIter = IterMut<'a, T>;
+
+    fn into_iter(mut self) -> IterMut<'a, T> {
+        self.iter_mut()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<A> Extend<A> for DList<A> {
     fn extend<T: Iterator<Item=A>>(&mut self, iterator: T) {
diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs
index da533d34703..5c37be188fe 100644
--- a/src/libcollections/enum_set.rs
+++ b/src/libcollections/enum_set.rs
@@ -257,6 +257,8 @@ impl<E:CLike> FromIterator<E> for EnumSet<E> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
     type IntoIter = Iter<E>;
 
@@ -265,6 +267,16 @@ impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
+    type Item = E;
+    type IntoIter = Iter<E>;
+
+    fn into_iter(self) -> Iter<E> {
+        self.iter()
+    }
+}
+
 impl<E:CLike> Extend<E> for EnumSet<E> {
     fn extend<I: Iterator<Item=E>>(&mut self, iterator: I) {
         for element in iterator {
diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs
index 5f1dc1d2ef4..5d3a9e500b2 100644
--- a/src/libcollections/ring_buf.rs
+++ b/src/libcollections/ring_buf.rs
@@ -1607,6 +1607,8 @@ impl<A> FromIterator<A> for RingBuf<A> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T> IntoIterator for RingBuf<T> {
     type IntoIter = IntoIter<T>;
 
@@ -1615,6 +1617,18 @@ impl<T> IntoIterator for RingBuf<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T> IntoIterator for RingBuf<T> {
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a RingBuf<T> {
     type IntoIter = Iter<'a, T>;
 
@@ -1623,6 +1637,18 @@ impl<'a, T> IntoIterator for &'a RingBuf<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a RingBuf<T> {
+    type Item = &'a T;
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
     type IntoIter = IterMut<'a, T>;
 
@@ -1631,6 +1657,16 @@ impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
+    type Item = &'a mut T;
+    type IntoIter = IterMut<'a, T>;
+
+    fn into_iter(mut self) -> IterMut<'a, T> {
+        self.iter_mut()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<A> Extend<A> for RingBuf<A> {
     fn extend<T: Iterator<Item=A>>(&mut self, iterator: T) {
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 341d91538ad..20cdf7e0b96 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1393,6 +1393,8 @@ impl<T> FromIterator<T> for Vec<T> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T> IntoIterator for Vec<T> {
     type IntoIter = IntoIter<T>;
 
@@ -1401,6 +1403,18 @@ impl<T> IntoIterator for Vec<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T> IntoIterator for Vec<T> {
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a Vec<T> {
     type IntoIter = slice::Iter<'a, T>;
 
@@ -1409,6 +1423,18 @@ impl<'a, T> IntoIterator for &'a Vec<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a Vec<T> {
+    type Item = &'a T;
+    type IntoIter = slice::Iter<'a, T>;
+
+    fn into_iter(self) -> slice::Iter<'a, T> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a mut Vec<T> {
     type IntoIter = slice::IterMut<'a, T>;
 
@@ -1417,6 +1443,16 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a mut Vec<T> {
+    type Item = &'a mut T;
+    type IntoIter = slice::IterMut<'a, T>;
+
+    fn into_iter(mut self) -> slice::IterMut<'a, T> {
+        self.iter_mut()
+    }
+}
+
 #[unstable(feature = "collections", reason = "waiting on Extend stability")]
 impl<T> Extend<T> for Vec<T> {
     #[inline]
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs
index ba358ada0ad..7f9484c58a1 100644
--- a/src/libcollections/vec_map.rs
+++ b/src/libcollections/vec_map.rs
@@ -668,6 +668,8 @@ impl<V> FromIterator<(usize, V)> for VecMap<V> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T> IntoIterator for VecMap<T> {
     type IntoIter = IntoIter<T>;
 
@@ -676,6 +678,18 @@ impl<T> IntoIterator for VecMap<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T> IntoIterator for VecMap<T> {
+    type Item = (usize, T);
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a VecMap<T> {
     type IntoIter = Iter<'a, T>;
 
@@ -684,6 +698,18 @@ impl<'a, T> IntoIterator for &'a VecMap<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a VecMap<T> {
+    type Item = (usize, &'a T);
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a mut VecMap<T> {
     type IntoIter = IterMut<'a, T>;
 
@@ -692,6 +718,16 @@ impl<'a, T> IntoIterator for &'a mut VecMap<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a mut VecMap<T> {
+    type Item = (usize, &'a mut T);
+    type IntoIter = IterMut<'a, T>;
+
+    fn into_iter(mut self) -> IterMut<'a, T> {
+        self.iter_mut()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<V> Extend<(usize, V)> for VecMap<V> {
     fn extend<Iter: Iterator<Item=(usize, V)>>(&mut self, iter: Iter) {
diff --git a/src/libcore/array.rs b/src/libcore/array.rs
index a596fe4a588..abaa7594d04 100644
--- a/src/libcore/array.rs
+++ b/src/libcore/array.rs
@@ -48,6 +48,8 @@ macro_rules! array_impls {
                 }
             }
 
+            // NOTE(stage0): remove impl after a snapshot
+            #[cfg(stage0)]
             impl<'a, T> IntoIterator for &'a [T; $N] {
                 type IntoIter = Iter<'a, T>;
 
@@ -56,6 +58,18 @@ macro_rules! array_impls {
                 }
             }
 
+            #[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+            impl<'a, T> IntoIterator for &'a [T; $N] {
+                type Item = &'a T;
+                type IntoIter = Iter<'a, T>;
+
+                fn into_iter(self) -> Iter<'a, T> {
+                    self.iter()
+                }
+            }
+
+            // NOTE(stage0): remove impl after a snapshot
+            #[cfg(stage0)]
             impl<'a, T> IntoIterator for &'a mut [T; $N] {
                 type IntoIter = IterMut<'a, T>;
 
@@ -64,6 +78,16 @@ macro_rules! array_impls {
                 }
             }
 
+            #[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+            impl<'a, T> IntoIterator for &'a mut [T; $N] {
+                type Item = &'a mut T;
+                type IntoIter = IterMut<'a, T>;
+
+                fn into_iter(self) -> IterMut<'a, T> {
+                    self.iter_mut()
+                }
+            }
+
             #[stable(feature = "rust1", since = "1.0.0")]
             impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
                 #[inline]
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 7740cd6867c..9bd94fb06a2 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -118,6 +118,8 @@ pub trait FromIterator<A> {
     fn from_iter<T: Iterator<Item=A>>(iterator: T) -> Self;
 }
 
+// NOTE(stage0): remove trait after a snapshot
+#[cfg(stage0)]
 /// Conversion into an `Iterator`
 pub trait IntoIterator {
     type IntoIter: Iterator;
@@ -127,6 +129,19 @@ pub trait IntoIterator {
     fn into_iter(self) -> Self::IntoIter;
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+/// Conversion into an `Iterator`
+pub trait IntoIterator {
+    type Item;
+    type IntoIter: Iterator<Item=Self::Item>;
+
+    /// Consumes `Self` and returns an iterator over it
+    #[stable(feature = "rust1", since = "1.0.0")]
+    fn into_iter(self) -> Self::IntoIter;
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<I> IntoIterator for I where I: Iterator {
     type IntoIter = I;
 
@@ -135,6 +150,16 @@ impl<I> IntoIterator for I where I: Iterator {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<I: Iterator> IntoIterator for I {
+    type Item = I::Item;
+    type IntoIter = I;
+
+    fn into_iter(self) -> I {
+        self
+    }
+}
+
 /// A type growable from an `Iterator` implementation
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait Extend<A> {
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index cf1df4ac423..41721dacfb8 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -626,6 +626,8 @@ impl<'a, T> Default for &'a [T] {
 // Iterators
 //
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a [T] {
     type IntoIter = Iter<'a, T>;
 
@@ -634,6 +636,18 @@ impl<'a, T> IntoIterator for &'a [T] {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a [T] {
+    type Item = &'a T;
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T> IntoIterator for &'a mut [T] {
     type IntoIter = IterMut<'a, T>;
 
@@ -642,6 +656,16 @@ impl<'a, T> IntoIterator for &'a mut [T] {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T> IntoIterator for &'a mut [T] {
+    type Item = &'a mut T;
+    type IntoIter = IterMut<'a, T>;
+
+    fn into_iter(self) -> IterMut<'a, T> {
+        self.iter_mut()
+    }
+}
+
 // The shared definition of the `Iter` and `IterMut` iterators
 macro_rules! iterator {
     (struct $name:ident -> $ptr:ty, $elem:ty) => {
diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs
index e20968a9ac9..e27e7a80246 100644
--- a/src/librustc/middle/subst.rs
+++ b/src/librustc/middle/subst.rs
@@ -530,6 +530,8 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> {
     }
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T> IntoIterator for VecPerParamSpace<T> {
     type IntoIter = IntoIter<T>;
 
@@ -538,6 +540,18 @@ impl<T> IntoIterator for VecPerParamSpace<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T> IntoIterator for VecPerParamSpace<T> {
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_vec().into_iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
     type IntoIter = Iter<'a, T>;
 
@@ -546,6 +560,16 @@ impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> {
+    type Item = &'a T;
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.as_slice().into_iter()
+    }
+}
+
 
 ///////////////////////////////////////////////////////////////////////////
 // Public trait `Subst`
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 18dd122891d..241e409910f 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -1372,6 +1372,8 @@ enum VacantEntryState<K, V, M> {
     NoElem(EmptyBucket<K, V, M>),
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, K, V, S, H> IntoIterator for &'a HashMap<K, V, S>
     where K: Eq + Hash<H>,
           S: HashState<Hasher=H>,
@@ -1384,6 +1386,22 @@ impl<'a, K, V, S, H> IntoIterator for &'a HashMap<K, V, S>
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, K, V, S, H> IntoIterator for &'a HashMap<K, V, S>
+    where K: Eq + Hash<H>,
+          S: HashState<Hasher=H>,
+          H: hash::Hasher<Output=u64>
+{
+    type Item = (&'a K, &'a V);
+    type IntoIter = Iter<'a, K, V>;
+
+    fn into_iter(self) -> Iter<'a, K, V> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap<K, V, S>
     where K: Eq + Hash<H>,
           S: HashState<Hasher=H>,
@@ -1396,6 +1414,22 @@ impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap<K, V, S>
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, K, V, S, H> IntoIterator for &'a mut HashMap<K, V, S>
+    where K: Eq + Hash<H>,
+          S: HashState<Hasher=H>,
+          H: hash::Hasher<Output=u64>
+{
+    type Item = (&'a K, &'a mut V);
+    type IntoIter = IterMut<'a, K, V>;
+
+    fn into_iter(mut self) -> IterMut<'a, K, V> {
+        self.iter_mut()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<K, V, S, H> IntoIterator for HashMap<K, V, S>
     where K: Eq + Hash<H>,
           S: HashState<Hasher=H>,
@@ -1408,6 +1442,20 @@ impl<K, V, S, H> IntoIterator for HashMap<K, V, S>
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<K, V, S, H> IntoIterator for HashMap<K, V, S>
+    where K: Eq + Hash<H>,
+          S: HashState<Hasher=H>,
+          H: hash::Hasher<Output=u64>
+{
+    type Item = (K, V);
+    type IntoIter = IntoIter<K, V>;
+
+    fn into_iter(self) -> IntoIter<K, V> {
+        self.into_iter()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> Iterator for Iter<'a, K, V> {
     type Item = (&'a K, &'a V);
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs
index de3c0424c9a..7d735201bea 100644
--- a/src/libstd/collections/hash/set.rs
+++ b/src/libstd/collections/hash/set.rs
@@ -835,6 +835,8 @@ pub struct Union<'a, T: 'a, S: 'a> {
     iter: Chain<Iter<'a, T>, Difference<'a, T, S>>
 }
 
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<'a, T, S, H> IntoIterator for &'a HashSet<T, S>
     where T: Eq + Hash<H>,
           S: HashState<Hasher=H>,
@@ -847,6 +849,22 @@ impl<'a, T, S, H> IntoIterator for &'a HashSet<T, S>
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<'a, T, S, H> IntoIterator for &'a HashSet<T, S>
+    where T: Eq + Hash<H>,
+          S: HashState<Hasher=H>,
+          H: hash::Hasher<Output=u64>
+{
+    type Item = &'a T;
+    type IntoIter = Iter<'a, T>;
+
+    fn into_iter(self) -> Iter<'a, T> {
+        self.iter()
+    }
+}
+
+// NOTE(stage0): remove impl after a snapshot
+#[cfg(stage0)]
 impl<T, S, H> IntoIterator for HashSet<T, S>
     where T: Eq + Hash<H>,
           S: HashState<Hasher=H>,
@@ -859,6 +877,20 @@ impl<T, S, H> IntoIterator for HashSet<T, S>
     }
 }
 
+#[cfg(not(stage0))]  // NOTE(stage0): remove cfg after a snapshot
+impl<T, S, H> IntoIterator for HashSet<T, S>
+    where T: Eq + Hash<H>,
+          S: HashState<Hasher=H>,
+          H: hash::Hasher<Output=u64>
+{
+    type Item = T;
+    type IntoIter = IntoIter<T>;
+
+    fn into_iter(self) -> IntoIter<T> {
+        self.into_iter()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K> Iterator for Iter<'a, K> {
     type Item = &'a K;