]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #23419 - murarth:lookup-addr, r=alexcrichton
authorManish Goregaokar <manishsmail@gmail.com>
Fri, 27 Mar 2015 17:07:20 +0000 (22:37 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Fri, 27 Mar 2015 17:07:20 +0000 (22:37 +0530)
 Closes #22608

48 files changed:
src/driver/driver.rs
src/libcollections/bit.rs
src/libcollections/btree/map.rs
src/libcollections/btree/node.rs
src/libcollections/string.rs
src/libcollections/vec.rs
src/libcollections/vec_deque.rs
src/libcollections/vec_map.rs
src/libcore/intrinsics.rs
src/libcore/ops.rs
src/libcore/slice.rs
src/libcore/str/mod.rs
src/liblibc/lib.rs
src/librustc/lib.rs
src/librustc/metadata/loader.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/traits/fulfill.rs
src/librustc/middle/ty.rs
src/librustc/session/config.rs
src/librustc_borrowck/lib.rs
src/librustc_driver/lib.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/resolve_imports.rs
src/librustc_trans/lib.rs
src/librustc_typeck/check/mod.rs
src/librustdoc/html/render.rs
src/librustdoc/lib.rs
src/libserialize/json.rs
src/libstd/collections/hash/map.rs
src/libstd/collections/mod.rs
src/libstd/ffi/os_str.rs
src/libstd/io/impls.rs
src/libstd/lib.rs
src/libstd/old_io/mem.rs
src/libstd/sys/common/wtf8.rs
src/libsyntax/ext/deriving/generic/mod.rs
src/libsyntax/ext/mtwt.rs
src/libsyntax/ext/quote.rs
src/libsyntax/lib.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libtest/lib.rs
src/libunicode/char.rs
src/snapshots.txt
src/test/auxiliary/struct_variant_xc_aux.rs
src/test/compile-fail/borrowck-overloaded-index-autoderef.rs
src/test/compile-fail/derive-assoc-type-not-impl.rs [new file with mode: 0644]
src/test/run-pass/deriving-associated-types.rs [new file with mode: 0644]

index 6b56c2b630346ff32c1cf6650917017e0204fc1a..c5c58bb49ac361f34df30451b9badd02450acab9 100644 (file)
@@ -12,9 +12,9 @@
 #![cfg_attr(rustdoc, feature(rustdoc))]
 
 #[cfg(rustdoc)]
-extern crate "rustdoc" as this;
+extern crate rustdoc as this;
 
 #[cfg(rustc)]
-extern crate "rustc_driver" as this;
+extern crate rustc_driver as this;
 
 fn main() { this::main() }
index 377b52a3dbe292d4380c10816327493f3480e5f4..fcf8c8156944ca443c727d50c6a1aaa2e94ec64a 100644 (file)
@@ -171,18 +171,6 @@ pub struct BitVec {
 impl Index<usize> for BitVec {
     type Output = bool;
 
-
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, i: &usize) -> &bool {
-        if self.get(*i).expect("index out of bounds") {
-            &TRUE
-        } else {
-            &FALSE
-        }
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, i: usize) -> &bool {
         if self.get(i).expect("index out of bounds") {
index c2f6fbc0b2602cb62c537c23d9c2eb3c9e3905c9..11407b5e496f68dffd9c57b870e18d3fce3e8b46 100644 (file)
@@ -915,20 +915,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-#[cfg(stage0)]
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<K: Ord, Q: ?Sized, V> Index<Q> for BTreeMap<K, V>
-    where K: Borrow<Q>, Q: Ord
-{
-    type Output = V;
-
-    #[inline]
-    fn index(&self, key: &Q) -> &V {
-        self.get(key).expect("no entry found for key")
-    }
-}
-
-#[cfg(not(stage0))]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap<K, V>
     where K: Borrow<Q>, Q: Ord
@@ -1143,15 +1129,39 @@ fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next_back() }
 }
 
 impl<'a, K: Ord, V> Entry<'a, K, V> {
-    /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
     #[unstable(feature = "std_misc",
                reason = "will soon be replaced by or_insert")]
+    #[deprecated(since = "1.0",
+                reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
+    /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
     pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
         match self {
             Occupied(entry) => Ok(entry.into_mut()),
             Vacant(entry) => Err(entry),
         }
     }
+
+    #[unstable(feature = "collections",
+               reason = "matches entry v3 specification, waiting for dust to settle")]
+    /// Ensures a value is in the entry by inserting the default if empty, and returns
+    /// a mutable reference to the value in the entry.
+    pub fn or_insert(self, default: V) -> &'a mut V {
+        match self {
+            Occupied(entry) => entry.into_mut(),
+            Vacant(entry) => entry.insert(default),
+        }
+    }
+
+    #[unstable(feature = "collections",
+               reason = "matches entry v3 specification, waiting for dust to settle")]
+    /// Ensures a value is in the entry by inserting the result of the default function if empty,
+    /// and returns a mutable reference to the value in the entry.
+    pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
+        match self {
+            Occupied(entry) => entry.into_mut(),
+            Vacant(entry) => entry.insert(default()),
+        }
+    }
 }
 
 impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
@@ -1563,21 +1573,12 @@ pub fn range_mut<'a>(&'a mut self, min: Bound<&K>, max: Bound<&K>) -> RangeMut<'
     /// ```
     /// # #![feature(collections)]
     /// use std::collections::BTreeMap;
-    /// use std::collections::btree_map::Entry;
     ///
     /// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
     ///
     /// // count the number of occurrences of letters in the vec
-    /// for x in vec!["a","b","a","c","a","b"].iter() {
-    ///     match count.entry(*x) {
-    ///         Entry::Vacant(view) => {
-    ///             view.insert(1);
-    ///         },
-    ///         Entry::Occupied(mut view) => {
-    ///             let v = view.get_mut();
-    ///             *v += 1;
-    ///         },
-    ///     }
+    /// for x in vec!["a","b","a","c","a","b"] {
+    ///     *count.entry(x).or_insert(0) += 1;
     /// }
     ///
     /// assert_eq!(count["a"], 3);
index 23eafa41d8a01d4075737d74cae3b39171b6a5cd..66f04d94ca131cf972c42e378968fe4cde5dd1f2 100644 (file)
@@ -1524,36 +1524,6 @@ fn search_linear<Q: ?Sized>(&self, key: &Q) -> (usize, bool)
             }
 
             /// Returns a sub-slice with elements starting with `min_key`.
-            #[cfg(stage0)]
-            pub fn slice_from(self, min_key: &K) -> $NodeSlice<'a, K, V> {
-                //  _______________
-                // |_1_|_3_|_5_|_7_|
-                // |   |   |   |   |
-                // 0 0 1 1 2 2 3 3 4  index
-                // |   |   |   |   |
-                // \___|___|___|___/  slice_from(&0); pos = 0
-                //     \___|___|___/  slice_from(&2); pos = 1
-                //     |___|___|___/  slice_from(&3); pos = 1; result.head_is_edge = false
-                //         \___|___/  slice_from(&4); pos = 2
-                //             \___/  slice_from(&6); pos = 3
-                //                \|/ slice_from(&999); pos = 4
-                let (pos, pos_is_kv) = self.search_linear(min_key);
-                $NodeSlice {
-                    has_edges: self.has_edges,
-                    edges: if !self.has_edges {
-                        self.edges
-                    } else {
-                        self.edges.$index(&(pos ..))
-                    },
-                    keys: &self.keys[pos ..],
-                    vals: self.vals.$index(&(pos ..)),
-                    head_is_edge: !pos_is_kv,
-                    tail_is_edge: self.tail_is_edge,
-                }
-            }
-
-            /// Returns a sub-slice with elements starting with `min_key`.
-            #[cfg(not(stage0))]
             pub fn slice_from(self, min_key: &K) -> $NodeSlice<'a, K, V> {
                 //  _______________
                 // |_1_|_3_|_5_|_7_|
@@ -1582,37 +1552,6 @@ pub fn slice_from(self, min_key: &K) -> $NodeSlice<'a, K, V> {
             }
 
             /// Returns a sub-slice with elements up to and including `max_key`.
-            #[cfg(stage0)]
-            pub fn slice_to(self, max_key: &K) -> $NodeSlice<'a, K, V> {
-                //  _______________
-                // |_1_|_3_|_5_|_7_|
-                // |   |   |   |   |
-                // 0 0 1 1 2 2 3 3 4  index
-                // |   |   |   |   |
-                //\|/  |   |   |   |  slice_to(&0); pos = 0
-                // \___/   |   |   |  slice_to(&2); pos = 1
-                // \___|___|   |   |  slice_to(&3); pos = 1; result.tail_is_edge = false
-                // \___|___/   |   |  slice_to(&4); pos = 2
-                // \___|___|___/   |  slice_to(&6); pos = 3
-                // \___|___|___|___/  slice_to(&999); pos = 4
-                let (pos, pos_is_kv) = self.search_linear(max_key);
-                let pos = pos + if pos_is_kv { 1 } else { 0 };
-                $NodeSlice {
-                    has_edges: self.has_edges,
-                    edges: if !self.has_edges {
-                        self.edges
-                    } else {
-                        self.edges.$index(&(.. (pos + 1)))
-                    },
-                    keys: &self.keys[..pos],
-                    vals: self.vals.$index(&(.. pos)),
-                    head_is_edge: self.head_is_edge,
-                    tail_is_edge: !pos_is_kv,
-                }
-            }
-
-            /// Returns a sub-slice with elements up to and including `max_key`.
-            #[cfg(not(stage0))]
             pub fn slice_to(self, max_key: &K) -> $NodeSlice<'a, K, V> {
                 //  _______________
                 // |_1_|_3_|_5_|_7_|
index a61eaecd2b1ea36dcf2b892b05c0df9a6eac7f50..7131c1cd881b4ccf95ed043e792566279d95d388 100644 (file)
@@ -903,13 +903,6 @@ fn add(mut self, other: &str) -> String {
 impl ops::Index<ops::Range<usize>> for String {
     type Output = str;
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::Range<usize>) -> &str {
-        &self[..][*index]
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::Range<usize>) -> &str {
         &self[..][index]
@@ -919,13 +912,6 @@ fn index(&self, index: ops::Range<usize>) -> &str {
 impl ops::Index<ops::RangeTo<usize>> for String {
     type Output = str;
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeTo<usize>) -> &str {
-        &self[..][*index]
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeTo<usize>) -> &str {
         &self[..][index]
@@ -935,13 +921,6 @@ fn index(&self, index: ops::RangeTo<usize>) -> &str {
 impl ops::Index<ops::RangeFrom<usize>> for String {
     type Output = str;
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeFrom<usize>) -> &str {
-        &self[..][*index]
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeFrom<usize>) -> &str {
         &self[..][index]
@@ -951,13 +930,6 @@ fn index(&self, index: ops::RangeFrom<usize>) -> &str {
 impl ops::Index<ops::RangeFull> for String {
     type Output = str;
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, _index: &ops::RangeFull) -> &str {
-        unsafe { mem::transmute(&*self.vec) }
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, _index: ops::RangeFull) -> &str {
         unsafe { mem::transmute(&*self.vec) }
index e71077c96c774a4acbfb7bdf5174138ae39dd08e..ee528255ae7a5e931829b2865de1c3ecf1d97aff 100644 (file)
@@ -1343,15 +1343,6 @@ fn hash<H: hash::Hasher>(&self, state: &mut H) {
 impl<T> Index<usize> for Vec<T> {
     type Output = T;
 
-
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &usize) -> &T {
-        // NB built-in indexing via `&[T]`
-        &(**self)[*index]
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: usize) -> &T {
         // NB built-in indexing via `&[T]`
@@ -1361,15 +1352,6 @@ fn index(&self, index: usize) -> &T {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> IndexMut<usize> for Vec<T> {
-
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &usize) -> &mut T {
-        // NB built-in indexing via `&mut [T]`
-        &mut (**self)[*index]
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: usize) -> &mut T {
         // NB built-in indexing via `&mut [T]`
@@ -1382,13 +1364,6 @@ fn index_mut(&mut self, index: usize) -> &mut T {
 impl<T> ops::Index<ops::Range<usize>> for Vec<T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::Range<usize>) -> &[T] {
-        Index::index(&**self, index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::Range<usize>) -> &[T] {
         Index::index(&**self, index)
@@ -1398,13 +1373,6 @@ fn index(&self, index: ops::Range<usize>) -> &[T] {
 impl<T> ops::Index<ops::RangeTo<usize>> for Vec<T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeTo<usize>) -> &[T] {
-        Index::index(&**self, index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
         Index::index(&**self, index)
@@ -1414,13 +1382,6 @@ fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
 impl<T> ops::Index<ops::RangeFrom<usize>> for Vec<T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeFrom<usize>) -> &[T] {
-        Index::index(&**self, index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
         Index::index(&**self, index)
@@ -1430,13 +1391,6 @@ fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
 impl<T> ops::Index<ops::RangeFull> for Vec<T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, _index: &ops::RangeFull) -> &[T] {
-        self
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, _index: ops::RangeFull) -> &[T] {
         self
@@ -1446,13 +1400,6 @@ fn index(&self, _index: ops::RangeFull) -> &[T] {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<ops::Range<usize>> for Vec<T> {
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::Range<usize>) -> &mut [T] {
-        IndexMut::index_mut(&mut **self, index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
         IndexMut::index_mut(&mut **self, index)
@@ -1461,13 +1408,6 @@ fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<ops::RangeTo<usize>> for Vec<T> {
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::RangeTo<usize>) -> &mut [T] {
-        IndexMut::index_mut(&mut **self, index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
         IndexMut::index_mut(&mut **self, index)
@@ -1476,13 +1416,6 @@ fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<ops::RangeFrom<usize>> for Vec<T> {
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::RangeFrom<usize>) -> &mut [T] {
-        IndexMut::index_mut(&mut **self, index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
         IndexMut::index_mut(&mut **self, index)
@@ -1491,13 +1424,6 @@ fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> {
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, _index: &ops::RangeFull) -> &mut [T] {
-        self.as_mut_slice()
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, _index: ops::RangeFull) -> &mut [T] {
         self.as_mut_slice()
index af9db46f810b96b4a3fac3fcb3e97ef50f4cfb1f..f5702be2f4588ccb84220b80bf62cc439d764ce1 100644 (file)
@@ -1705,13 +1705,6 @@ fn hash<H: Hasher>(&self, state: &mut H) {
 impl<A> Index<usize> for VecDeque<A> {
     type Output = A;
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, i: &usize) -> &A {
-        self.get(*i).expect("Out of bounds access")
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, i: usize) -> &A {
         self.get(i).expect("Out of bounds access")
@@ -1720,13 +1713,6 @@ fn index(&self, i: usize) -> &A {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<A> IndexMut<usize> for VecDeque<A> {
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, i: &usize) -> &mut A {
-        self.get_mut(*i).expect("Out of bounds access")
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, i: usize) -> &mut A {
         self.get_mut(i).expect("Out of bounds access")
index c994064d34724e8917c809c7a20f23725b5b6f66..8900c7950458220f70c12816a5ea1d9995d15b60 100644 (file)
@@ -632,21 +632,12 @@ pub fn remove(&mut self, key: &usize) -> Option<V> {
     /// ```
     /// # #![feature(collections)]
     /// use std::collections::VecMap;
-    /// use std::collections::vec_map::Entry;
     ///
     /// let mut count: VecMap<u32> = VecMap::new();
     ///
     /// // count the number of occurrences of numbers in the vec
-    /// for x in vec![1, 2, 1, 2, 3, 4, 1, 2, 4].iter() {
-    ///     match count.entry(*x) {
-    ///         Entry::Vacant(view) => {
-    ///             view.insert(1);
-    ///         },
-    ///         Entry::Occupied(mut view) => {
-    ///             let v = view.get_mut();
-    ///             *v += 1;
-    ///         },
-    ///     }
+    /// for x in vec![1, 2, 1, 2, 3, 4, 1, 2, 4] {
+    ///     *count.entry(x).or_insert(0) += 1;
     /// }
     ///
     /// assert_eq!(count[1], 3);
@@ -675,6 +666,8 @@ pub fn entry(&mut self, key: usize) -> Entry<V> {
 impl<'a, V> Entry<'a, V> {
     #[unstable(feature = "collections",
                reason = "will soon be replaced by or_insert")]
+    #[deprecated(since = "1.0",
+                reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
     /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
     pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, V>> {
         match self {
@@ -682,6 +675,28 @@ pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, V>> {
             Vacant(entry) => Err(entry),
         }
     }
+
+    #[unstable(feature = "collections",
+               reason = "matches entry v3 specification, waiting for dust to settle")]
+    /// Ensures a value is in the entry by inserting the default if empty, and returns
+    /// a mutable reference to the value in the entry.
+    pub fn or_insert(self, default: V) -> &'a mut V {
+        match self {
+            Occupied(entry) => entry.into_mut(),
+            Vacant(entry) => entry.insert(default),
+        }
+    }
+
+    #[unstable(feature = "collections",
+               reason = "matches entry v3 specification, waiting for dust to settle")]
+    /// Ensures a value is in the entry by inserting the result of the default function if empty,
+    /// and returns a mutable reference to the value in the entry.
+    pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
+        match self {
+            Occupied(entry) => entry.into_mut(),
+            Vacant(entry) => entry.insert(default()),
+        }
+    }
 }
 
 impl<'a, V> VacantEntry<'a, V> {
@@ -821,17 +836,6 @@ fn extend<I: IntoIterator<Item=(usize, V)>>(&mut self, iter: I) {
     }
 }
 
-#[cfg(stage0)]
-impl<V> Index<usize> for VecMap<V> {
-    type Output = V;
-
-    #[inline]
-    fn index<'a>(&'a self, i: &usize) -> &'a V {
-        self.get(i).expect("key not present")
-    }
-}
-
-#[cfg(not(stage0))]
 impl<V> Index<usize> for VecMap<V> {
     type Output = V;
 
@@ -841,7 +845,6 @@ fn index<'a>(&'a self, i: usize) -> &'a V {
     }
 }
 
-#[cfg(not(stage0))]
 impl<'a,V> Index<&'a usize> for VecMap<V> {
     type Output = V;
 
@@ -851,16 +854,6 @@ fn index(&self, i: &usize) -> &V {
     }
 }
 
-#[cfg(stage0)]
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<V> IndexMut<usize> for VecMap<V> {
-    #[inline]
-    fn index_mut(&mut self, i: &usize) -> &mut V {
-        self.get_mut(&i).expect("key not present")
-    }
-}
-
-#[cfg(not(stage0))]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<V> IndexMut<usize> for VecMap<V> {
     #[inline]
@@ -869,7 +862,6 @@ fn index_mut(&mut self, i: usize) -> &mut V {
     }
 }
 
-#[cfg(not(stage0))]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, V> IndexMut<&'a usize> for VecMap<V> {
     #[inline]
index 1f1044b0b21520d0148877edbe132faf6e9c5a6e..211b0152c33cecbc37ead2b97c803ac2a1fdcda0 100644 (file)
 
 use marker::Sized;
 
-#[cfg(stage0)] pub use self::copy_memory as copy;
-#[cfg(stage0)] pub use self::set_memory as write_bytes;
-#[cfg(stage0)] pub use self::copy_nonoverlapping_memory as copy_nonoverlapping;
-
 extern "rust-intrinsic" {
 
     // NB: These intrinsics take unsafe pointers because they mutate aliased
     pub fn pref_align_of<T>() -> usize;
 
     /// Gets a static string slice containing the name of a type.
-    #[cfg(not(stage0))]
     pub fn type_name<T: ?Sized>() -> &'static str;
 
     /// Gets an identifier which is globally unique to the specified type. This
     /// }
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    #[cfg(not(stage0))]
     pub fn copy_nonoverlapping<T>(dst: *mut T, src: *const T, count: usize);
 
-    /// dox
-    #[stable(feature = "rust1", since = "1.0.0")]
-    #[cfg(stage0)]
-    pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: usize);
-
     /// Copies `count * size_of<T>` bytes from `src` to `dst`. The source
     /// and destination may overlap.
     ///
     /// }
     /// ```
     ///
-    #[cfg(not(stage0))]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn copy<T>(dst: *mut T, src: *const T, count: usize);
 
-    /// dox
-    #[cfg(stage0)]
-    #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn copy_memory<T>(dst: *mut T, src: *const T, count: usize);
-
     /// Invokes memset on the specified pointer, setting `count * size_of::<T>()`
     /// bytes of memory starting at `dst` to `c`.
-    #[cfg(not(stage0))]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
 
-    /// dox
-    #[cfg(stage0)]
-    #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn set_memory<T>(dst: *mut T, val: u8, count: usize);
-
     /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
     /// a size of `count` * `size_of::<T>()` and an alignment of
     /// `min_align_of::<T>()`
index 16d03901239b3ea417ba47c69c9987c13174933a..26deb80d8c51fb02e4f240193a145e5366301c1e 100644 (file)
@@ -917,12 +917,6 @@ pub trait Index<Idx: ?Sized> {
     type Output: ?Sized;
 
     /// The method for the indexing (`Foo[Bar]`) operation
-    #[cfg(stage0)]
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn index<'a>(&'a self, index: &Idx) -> &'a Self::Output;
-
-    /// The method for the indexing (`Foo[Bar]`) operation
-    #[cfg(not(stage0))]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn index<'a>(&'a self, index: Idx) -> &'a Self::Output;
 }
@@ -966,12 +960,6 @@ pub trait Index<Idx: ?Sized> {
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
     /// The method for the indexing (`Foo[Bar]`) operation
-    #[cfg(stage0)]
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn index_mut<'a>(&'a mut self, index: &Idx) -> &'a mut Self::Output;
-
-    /// The method for the indexing (`Foo[Bar]`) operation
-    #[cfg(not(stage0))]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn index_mut<'a>(&'a mut self, index: Idx) -> &'a mut Self::Output;
 }
@@ -1149,20 +1137,6 @@ fn deref_mut(&mut self) -> &mut T { *self }
 #[lang="fn"]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_paren_sugar]
-#[cfg(stage0)]
-pub trait Fn<Args> {
-    /// The returned type after the call operator is used.
-    type Output;
-
-    /// This is called when the call operator is used.
-    extern "rust-call" fn call(&self, args: Args) -> Self::Output;
-}
-
-/// A version of the call operator that takes an immutable receiver.
-#[lang="fn"]
-#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_paren_sugar]
-#[cfg(not(stage0))]
 pub trait Fn<Args> : FnMut<Args> {
     /// This is called when the call operator is used.
     extern "rust-call" fn call(&self, args: Args) -> Self::Output;
@@ -1172,20 +1146,6 @@ pub trait Fn<Args> : FnMut<Args> {
 #[lang="fn_mut"]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_paren_sugar]
-#[cfg(stage0)]
-pub trait FnMut<Args> {
-    /// The returned type after the call operator is used.
-    type Output;
-
-    /// This is called when the call operator is used.
-    extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
-}
-
-/// A version of the call operator that takes a mutable receiver.
-#[lang="fn_mut"]
-#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_paren_sugar]
-#[cfg(not(stage0))]
 pub trait FnMut<Args> : FnOnce<Args> {
     /// This is called when the call operator is used.
     extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
@@ -1202,25 +1162,3 @@ pub trait FnOnce<Args> {
     /// This is called when the call operator is used.
     extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
 }
-
-#[cfg(stage0)]
-impl<F: ?Sized, A> FnMut<A> for F
-    where F : Fn<A>
-{
-    type Output = <F as Fn<A>>::Output;
-
-    extern "rust-call" fn call_mut(&mut self, args: A) -> <F as Fn<A>>::Output {
-        self.call(args)
-    }
-}
-
-#[cfg(stage0)]
-impl<F,A> FnOnce<A> for F
-    where F : FnMut<A>
-{
-    type Output = <F as FnMut<A>>::Output;
-
-    extern "rust-call" fn call_once(mut self, args: A) -> <F as FnMut<A>>::Output {
-        self.call_mut(args)
-    }
-}
index fce29abed7300c161c416be5f78b8f379cb92594..d5e8b4ce81e5ceec9bc2a4238dbfe54c72f1454a 100644 (file)
@@ -263,18 +263,6 @@ fn get_mut(&mut self, index: usize) -> Option<&mut T> {
     #[inline]
     fn as_mut_slice(&mut self) -> &mut [T] { self }
 
-    #[cfg(stage0)]
-    #[inline]
-    fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
-        unsafe {
-            let self2: &mut [T] = mem::transmute_copy(&self);
-
-            (ops::IndexMut::index_mut(self, &ops::RangeTo { end: mid } ),
-             ops::IndexMut::index_mut(self2, &ops::RangeFrom { start: mid } ))
-        }
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
         unsafe {
@@ -507,14 +495,6 @@ fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone {
 impl<T> ops::Index<usize> for [T] {
     type Output = T;
 
-    #[cfg(stage0)]
-    fn index(&self, &index: &usize) -> &T {
-        assert!(index < self.len());
-
-        unsafe { mem::transmute(self.repr().data.offset(index as isize)) }
-    }
-
-    #[cfg(not(stage0))]
     fn index(&self, index: usize) -> &T {
         assert!(index < self.len());
 
@@ -524,15 +504,6 @@ fn index(&self, index: usize) -> &T {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<usize> for [T] {
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, &index: &usize) -> &mut T {
-        assert!(index < self.len());
-
-        unsafe { mem::transmute(self.repr().data.offset(index as isize)) }
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: usize) -> &mut T {
         assert!(index < self.len());
@@ -545,20 +516,6 @@ fn index_mut(&mut self, index: usize) -> &mut T {
 impl<T> ops::Index<ops::Range<usize>> for [T] {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::Range<usize>) -> &[T] {
-        assert!(index.start <= index.end);
-        assert!(index.end <= self.len());
-        unsafe {
-            from_raw_parts (
-                self.as_ptr().offset(index.start as isize),
-                index.end - index.start
-            )
-        }
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::Range<usize>) -> &[T] {
         assert!(index.start <= index.end);
@@ -575,13 +532,6 @@ fn index(&self, index: ops::Range<usize>) -> &[T] {
 impl<T> ops::Index<ops::RangeTo<usize>> for [T] {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeTo<usize>) -> &[T] {
-        self.index(&ops::Range{ start: 0, end: index.end })
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
         self.index(ops::Range{ start: 0, end: index.end })
@@ -591,13 +541,6 @@ fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
 impl<T> ops::Index<ops::RangeFrom<usize>> for [T] {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeFrom<usize>) -> &[T] {
-        self.index(&ops::Range{ start: index.start, end: self.len() })
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
         self.index(ops::Range{ start: index.start, end: self.len() })
@@ -607,13 +550,6 @@ fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
 impl<T> ops::Index<RangeFull> for [T] {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, _index: &RangeFull) -> &[T] {
-        self
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, _index: RangeFull) -> &[T] {
         self
@@ -622,20 +558,6 @@ fn index(&self, _index: RangeFull) -> &[T] {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<ops::Range<usize>> for [T] {
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::Range<usize>) -> &mut [T] {
-        assert!(index.start <= index.end);
-        assert!(index.end <= self.len());
-        unsafe {
-            from_raw_parts_mut(
-                self.as_mut_ptr().offset(index.start as isize),
-                index.end - index.start
-            )
-        }
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
         assert!(index.start <= index.end);
@@ -650,13 +572,6 @@ fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<ops::RangeTo<usize>> for [T] {
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::RangeTo<usize>) -> &mut [T] {
-        self.index_mut(&ops::Range{ start: 0, end: index.end })
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
         self.index_mut(ops::Range{ start: 0, end: index.end })
@@ -664,14 +579,6 @@ fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<ops::RangeFrom<usize>> for [T] {
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::RangeFrom<usize>) -> &mut [T] {
-        let len = self.len();
-        self.index_mut(&ops::Range{ start: index.start, end: len })
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
         let len = self.len();
@@ -680,14 +587,6 @@ fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ops::IndexMut<RangeFull> for [T] {
-
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, _index: &RangeFull) -> &mut [T] {
-        self
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, _index: RangeFull) -> &mut [T] {
         self
@@ -875,13 +774,6 @@ unsafe impl<'a, T: Sync> Send for Iter<'a, T> {}
 impl<'a, T> ops::Index<ops::Range<usize>> for Iter<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::Range<usize>) -> &[T] {
-        self.as_slice().index(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::Range<usize>) -> &[T] {
         self.as_slice().index(index)
@@ -892,13 +784,6 @@ fn index(&self, index: ops::Range<usize>) -> &[T] {
 impl<'a, T> ops::Index<ops::RangeTo<usize>> for Iter<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeTo<usize>) -> &[T] {
-        self.as_slice().index(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
         self.as_slice().index(index)
@@ -909,13 +794,6 @@ fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
 impl<'a, T> ops::Index<ops::RangeFrom<usize>> for Iter<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeFrom<usize>) -> &[T] {
-        self.as_slice().index(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
         self.as_slice().index(index)
@@ -926,13 +804,6 @@ fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
 impl<'a, T> ops::Index<RangeFull> for Iter<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, _index: &RangeFull) -> &[T] {
-        self.as_slice()
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, _index: RangeFull) -> &[T] {
         self.as_slice()
@@ -1000,13 +871,6 @@ unsafe impl<'a, T: Send> Send for IterMut<'a, T> {}
 impl<'a, T> ops::Index<ops::Range<usize>> for IterMut<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::Range<usize>) -> &[T] {
-        self.index(&RangeFull).index(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::Range<usize>) -> &[T] {
         self.index(RangeFull).index(index)
@@ -1016,13 +880,6 @@ fn index(&self, index: ops::Range<usize>) -> &[T] {
 impl<'a, T> ops::Index<ops::RangeTo<usize>> for IterMut<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeTo<usize>) -> &[T] {
-        self.index(&RangeFull).index(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
         self.index(RangeFull).index(index)
@@ -1032,13 +889,6 @@ fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
 impl<'a, T> ops::Index<ops::RangeFrom<usize>> for IterMut<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, index: &ops::RangeFrom<usize>) -> &[T] {
-        self.index(&RangeFull).index(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
         self.index(RangeFull).index(index)
@@ -1048,13 +898,6 @@ fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
 impl<'a, T> ops::Index<RangeFull> for IterMut<'a, T> {
     type Output = [T];
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index(&self, _index: &RangeFull) -> &[T] {
-        make_slice!(T => &[T]: self.ptr, self.end)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index(&self, _index: RangeFull) -> &[T] {
         make_slice!(T => &[T]: self.ptr, self.end)
@@ -1063,13 +906,6 @@ fn index(&self, _index: RangeFull) -> &[T] {
 
 #[unstable(feature = "core")]
 impl<'a, T> ops::IndexMut<ops::Range<usize>> for IterMut<'a, T> {
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::Range<usize>) -> &mut [T] {
-        self.index_mut(&RangeFull).index_mut(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
         self.index_mut(RangeFull).index_mut(index)
@@ -1078,13 +914,6 @@ fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
 #[unstable(feature = "core")]
 impl<'a, T> ops::IndexMut<ops::RangeTo<usize>> for IterMut<'a, T> {
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::RangeTo<usize>) -> &mut [T] {
-        self.index_mut(&RangeFull).index_mut(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
         self.index_mut(RangeFull).index_mut(index)
@@ -1093,13 +922,6 @@ fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
 #[unstable(feature = "core")]
 impl<'a, T> ops::IndexMut<ops::RangeFrom<usize>> for IterMut<'a, T> {
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, index: &ops::RangeFrom<usize>) -> &mut [T] {
-        self.index_mut(&RangeFull).index_mut(index)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
         self.index_mut(RangeFull).index_mut(index)
@@ -1108,13 +930,6 @@ fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
 #[unstable(feature = "core")]
 impl<'a, T> ops::IndexMut<RangeFull> for IterMut<'a, T> {
 
-    #[cfg(stage0)]
-    #[inline]
-    fn index_mut(&mut self, _index: &RangeFull) -> &mut [T] {
-        make_mut_slice!(T => &mut [T]: self.ptr, self.end)
-    }
-
-    #[cfg(not(stage0))]
     #[inline]
     fn index_mut(&mut self, _index: RangeFull) -> &mut [T] {
         make_mut_slice!(T => &mut [T]: self.ptr, self.end)
index a629e0308e98299611940545977f165618499ac2..7fe3758ed9554bac88f78a54b589531c841b3e77 100644 (file)
@@ -541,17 +541,6 @@ fn next_back(&mut self) -> Option<(usize, char)> {
 #[derive(Copy, Clone)]
 struct BytesDeref;
 
-#[cfg(stage0)]
-impl<'a> Fn<(&'a u8,)> for BytesDeref {
-    type Output = u8;
-
-    #[inline]
-    extern "rust-call" fn call(&self, (ptr,): (&'a u8,)) -> u8 {
-        *ptr
-    }
-}
-
-#[cfg(not(stage0))]
 impl<'a> Fn<(&'a u8,)> for BytesDeref {
     #[inline]
     extern "rust-call" fn call(&self, (ptr,): (&'a u8,)) -> u8 {
@@ -559,7 +548,6 @@ extern "rust-call" fn call(&self, (ptr,): (&'a u8,)) -> u8 {
     }
 }
 
-#[cfg(not(stage0))]
 impl<'a> FnMut<(&'a u8,)> for BytesDeref {
     #[inline]
     extern "rust-call" fn call_mut(&mut self, (ptr,): (&'a u8,)) -> u8 {
@@ -567,7 +555,6 @@ extern "rust-call" fn call_mut(&mut self, (ptr,): (&'a u8,)) -> u8 {
     }
 }
 
-#[cfg(not(stage0))]
 impl<'a> FnOnce<(&'a u8,)> for BytesDeref {
     type Output = u8;
 
@@ -1319,50 +1306,6 @@ fn partial_cmp(&self, other: &str) -> Option<Ordering> {
     /// // byte 100 is outside the string
     /// // &s[3 .. 100];
     /// ```
-    #[cfg(stage0)]
-    #[stable(feature = "rust1", since = "1.0.0")]
-    impl ops::Index<ops::Range<usize>> for str {
-        type Output = str;
-        #[inline]
-        fn index(&self, index: &ops::Range<usize>) -> &str {
-            // is_char_boundary checks that the index is in [0, .len()]
-            if index.start <= index.end &&
-               self.is_char_boundary(index.start) &&
-               self.is_char_boundary(index.end) {
-                unsafe { self.slice_unchecked(index.start, index.end) }
-            } else {
-                super::slice_error_fail(self, index.start, index.end)
-            }
-        }
-    }
-
-    /// Returns a slice of the given string from the byte range
-    /// [`begin`..`end`).
-    ///
-    /// This operation is `O(1)`.
-    ///
-    /// Panics when `begin` and `end` do not point to valid characters
-    /// or point beyond the last character of the string.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// let s = "Löwe 老虎 Léopard";
-    /// assert_eq!(&s[0 .. 1], "L");
-    ///
-    /// assert_eq!(&s[1 .. 9], "öwe 老");
-    ///
-    /// // these will panic:
-    /// // byte 2 lies within `ö`:
-    /// // &s[2 ..3];
-    ///
-    /// // byte 8 lies within `老`
-    /// // &s[1 .. 8];
-    ///
-    /// // byte 100 is outside the string
-    /// // &s[3 .. 100];
-    /// ```
-    #[cfg(not(stage0))]
     #[stable(feature = "rust1", since = "1.0.0")]
     impl ops::Index<ops::Range<usize>> for str {
         type Output = str;
@@ -1390,18 +1333,6 @@ fn index(&self, index: ops::Range<usize>) -> &str {
     impl ops::Index<ops::RangeTo<usize>> for str {
         type Output = str;
 
-        #[cfg(stage0)]
-        #[inline]
-        fn index(&self, index: &ops::RangeTo<usize>) -> &str {
-            // is_char_boundary checks that the index is in [0, .len()]
-            if self.is_char_boundary(index.end) {
-                unsafe { self.slice_unchecked(0, index.end) }
-            } else {
-                super::slice_error_fail(self, 0, index.end)
-            }
-        }
-
-        #[cfg(not(stage0))]
         #[inline]
         fn index(&self, index: ops::RangeTo<usize>) -> &str {
             // is_char_boundary checks that the index is in [0, .len()]
@@ -1423,18 +1354,6 @@ fn index(&self, index: ops::RangeTo<usize>) -> &str {
     impl ops::Index<ops::RangeFrom<usize>> for str {
         type Output = str;
 
-        #[cfg(stage0)]
-        #[inline]
-        fn index(&self, index: &ops::RangeFrom<usize>) -> &str {
-            // is_char_boundary checks that the index is in [0, .len()]
-            if self.is_char_boundary(index.start) {
-                unsafe { self.slice_unchecked(index.start, self.len()) }
-            } else {
-                super::slice_error_fail(self, index.start, self.len())
-            }
-        }
-
-        #[cfg(not(stage0))]
         #[inline]
         fn index(&self, index: ops::RangeFrom<usize>) -> &str {
             // is_char_boundary checks that the index is in [0, .len()]
@@ -1450,13 +1369,6 @@ fn index(&self, index: ops::RangeFrom<usize>) -> &str {
     impl ops::Index<ops::RangeFull> for str {
         type Output = str;
 
-        #[cfg(stage0)]
-        #[inline]
-        fn index(&self, _index: &ops::RangeFull) -> &str {
-            self
-        }
-
-        #[cfg(not(stage0))]
         #[inline]
         fn index(&self, _index: ops::RangeFull) -> &str {
             self
index 89843979cd01583346aef92808b3edafe843d9b0..7174b2d2c29fed2016fef4f8f478e20b5fbb0971 100644 (file)
@@ -76,7 +76,7 @@
 
 #![allow(bad_style, raw_pointer_derive)]
 #![cfg_attr(target_os = "nacl", allow(unused_imports))]
-#[cfg(feature = "cargo-build")] extern crate "std" as core;
+#[cfg(feature = "cargo-build")] extern crate std as core;
 #[cfg(not(feature = "cargo-build"))] extern crate core;
 
 #[cfg(test)] extern crate std;
index e8af07e43815919ef4a23410a662770d90047409..90d9324b9090c54e147cf9bbeac985f2f23fedf8 100644 (file)
@@ -65,7 +65,7 @@
 #[macro_use] extern crate syntax;
 #[macro_use] #[no_link] extern crate rustc_bitflags;
 
-extern crate "serialize" as rustc_serialize; // used by deriving
+extern crate serialize as rustc_serialize; // used by deriving
 
 #[cfg(test)]
 extern crate test;
index 7854db811466517bbd3f675ab3ac0e80b9edc643..80fc3769453427f4815464ccbca410dd2c4129d4 100644 (file)
@@ -426,8 +426,8 @@ fn find_library_crate(&mut self) -> Option<Library> {
             info!("lib candidate: {}", path.display());
 
             let hash_str = hash.to_string();
-            let slot = candidates.entry(hash_str).get().unwrap_or_else(
-                |vacant_entry| vacant_entry.insert((HashMap::new(), HashMap::new())));
+            let slot = candidates.entry(hash_str)
+                                 .or_insert_with(|| (HashMap::new(), HashMap::new()));
             let (ref mut rlibs, ref mut dylibs) = *slot;
             if rlib {
                 rlibs.insert(fs::realpath(path).unwrap(), kind);
index a1ce8d18184e3e47af087755ad6192fff48bc8c9..0d58fd2702f680e692933464c594e232ec1d1188 100644 (file)
@@ -160,12 +160,7 @@ fn build_nodeid_to_index(decl: Option<&ast::FnDecl>,
 
     cfg.graph.each_node(|node_idx, node| {
         if let cfg::CFGNodeData::AST(id) = node.data {
-            match index.entry(id).get() {
-                Ok(v) => v.push(node_idx),
-                Err(e) => {
-                    e.insert(vec![node_idx]);
-                }
-            }
+            index.entry(id).or_insert(vec![]).push(node_idx);
         }
         true
     });
@@ -185,12 +180,7 @@ struct Formals<'a> {
         visit::walk_fn_decl(&mut formals, decl);
         impl<'a, 'v> visit::Visitor<'v> for Formals<'a> {
             fn visit_pat(&mut self, p: &ast::Pat) {
-                match self.index.entry(p.id).get() {
-                    Ok(v) => v.push(self.entry),
-                    Err(e) => {
-                        e.insert(vec![self.entry]);
-                    }
-                }
+                self.index.entry(p.id).or_insert(vec![]).push(self.entry);
                 visit::walk_pat(self, p)
             }
         }
index c1066aa899eaea4fe4f7e34ea89b319a443c4e8f..3d46f93914a589c53d21354b1aeff8fde7c63deb 100644 (file)
@@ -11,7 +11,6 @@
 use middle::infer::{InferCtxt};
 use middle::ty::{self, RegionEscape, Ty};
 use std::collections::HashSet;
-use std::collections::hash_map::Entry::{Occupied, Vacant};
 use std::default::Default;
 use syntax::ast;
 use util::common::ErrorReported;
@@ -437,9 +436,7 @@ fn register_region_obligation<'tcx>(tcx: &ty::ctxt<'tcx>,
     debug!("register_region_obligation({})",
            region_obligation.repr(tcx));
 
-    match region_obligations.entry(region_obligation.cause.body_id) {
-        Vacant(entry) => { entry.insert(vec![region_obligation]); },
-        Occupied(mut entry) => { entry.get_mut().push(region_obligation); },
-    }
+    region_obligations.entry(region_obligation.cause.body_id).or_insert(vec![])
+        .push(region_obligation);
 
 }
index 92b444e85d8c3f5fa713bfc632c1272b50acf01f..23fba5ead22598df14a75fa8eced8f960053ed28 100644 (file)
@@ -5669,9 +5669,7 @@ pub fn lookup_field_type<'tcx>(tcx: &ctxt<'tcx>,
         node_id_to_type(tcx, id.node)
     } else {
         let mut tcache = tcx.tcache.borrow_mut();
-        let pty = tcache.entry(id).get().unwrap_or_else(
-            |vacant_entry| vacant_entry.insert(csearch::get_field_type(tcx, struct_id, id)));
-        pty.ty
+        tcache.entry(id).or_insert_with(|| csearch::get_field_type(tcx, struct_id, id)).ty
     };
     ty.subst(tcx, substs)
 }
@@ -6819,9 +6817,7 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
         debug!("region={}", region.repr(tcx));
         match region {
             ty::ReLateBound(debruijn, br) if debruijn.depth == current_depth => {
-                let region =
-                    * map.entry(br).get().unwrap_or_else(
-                        |vacant_entry| vacant_entry.insert(mapf(br)));
+                let region = *map.entry(br).or_insert_with(|| mapf(br));
 
                 if let ty::ReLateBound(debruijn1, br) = region {
                     // If the callback returns a late-bound region,
index a7c67a0863182e6af468f5e4ba104a01b3c5a50c..931cfc7999281cecd767328b1b6a47126f958d47 100644 (file)
@@ -35,7 +35,6 @@
 
 use getopts;
 use std::collections::HashMap;
-use std::collections::hash_map::Entry::{Occupied, Vacant};
 use std::env;
 use std::fmt;
 use std::path::PathBuf;
@@ -1037,10 +1036,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             None => early_error("--extern value must be of the format `foo=bar`"),
         };
 
-        match externs.entry(name.to_string()) {
-            Vacant(entry) => { entry.insert(vec![location.to_string()]); },
-            Occupied(mut entry) => { entry.get_mut().push(location.to_string()); },
-        }
+        externs.entry(name.to_string()).or_insert(vec![]).push(location.to_string());
     }
 
     let crate_name = matches.opt_str("crate-name");
index e927ea5b86cdd27bc3416ced57069c96bf3b5e22..99f19ad7110869b34056f0a59ae287944520c1bc 100644 (file)
@@ -35,7 +35,7 @@
 
 // for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
 // refers to the borrowck-specific graphviz adapter traits.
-extern crate "graphviz" as dot;
+extern crate graphviz as dot;
 extern crate rustc;
 
 pub use borrowck::check_crate;
index 5e6f2fb835bb2a01787ebf36f027bcf5e1a4ed58..c433aed4ae94a053b8c01e3e87f81a2aa0c57d3c 100644 (file)
@@ -55,7 +55,7 @@
 extern crate rustc_trans;
 extern crate rustc_typeck;
 extern crate serialize;
-extern crate "rustc_llvm" as llvm;
+extern crate rustc_llvm as llvm;
 #[macro_use] extern crate log;
 #[macro_use] extern crate syntax;
 
index 566af2590e6c07cd0ec1a256856951ee36478222..5bf561c218d044365f88de58687a99b0a078a6ac 100644 (file)
@@ -26,7 +26,6 @@
 #![feature(rustc_diagnostic_macros)]
 #![feature(rustc_private)]
 #![feature(staged_api)]
-#![feature(std_misc)]
 
 #[macro_use] extern crate log;
 #[macro_use] extern crate syntax;
index 46451019760dd478aa179449473532a32d15fe63..662b5a366431ca785460742cc0775e2fb0ca6f42 100644 (file)
@@ -836,11 +836,8 @@ fn merge_import_resolution(&mut self,
         let is_public = import_directive.is_public;
 
         let mut import_resolutions = module_.import_resolutions.borrow_mut();
-        let dest_import_resolution = import_resolutions.entry(name).get().unwrap_or_else(
-            |vacant_entry| {
-                // Create a new import resolution from this child.
-                vacant_entry.insert(ImportResolution::new(id, is_public))
-            });
+        let dest_import_resolution = import_resolutions.entry(name)
+            .or_insert_with(|| ImportResolution::new(id, is_public));
 
         debug!("(resolving glob import) writing resolution `{}` in `{}` \
                to `{}`",
index 99a64156d667b96d89a3cef297d4500ed0f6c33c..83525dffaaeb7834ddd5a85ba30a819c7d99e0c3 100644 (file)
@@ -54,7 +54,7 @@
 extern crate rustc;
 extern crate rustc_back;
 extern crate serialize;
-extern crate "rustc_llvm" as llvm;
+extern crate rustc_llvm as llvm;
 
 #[macro_use] extern crate log;
 #[macro_use] extern crate syntax;
index 1e38a7d2d9f944222403095c82f24ddf733b20d1..0f9836bc0734606cd504c05f52229fe9010f5ab5 100644 (file)
 use util::lev_distance::lev_distance;
 
 use std::cell::{Cell, Ref, RefCell};
-use std::collections::hash_map::Entry::{Occupied, Vacant};
 use std::mem::replace;
 use std::rc::Rc;
 use std::iter::repeat;
@@ -1362,11 +1361,7 @@ fn record_deferred_call_resolution(&self,
                                        closure_def_id: ast::DefId,
                                        r: DeferredCallResolutionHandler<'tcx>) {
         let mut deferred_call_resolutions = self.inh.deferred_call_resolutions.borrow_mut();
-        let mut vec = match deferred_call_resolutions.entry(closure_def_id) {
-            Occupied(entry) => entry.into_mut(),
-            Vacant(entry) => entry.insert(Vec::new()),
-        };
-        vec.push(r);
+        deferred_call_resolutions.entry(closure_def_id).or_insert(vec![]).push(r);
     }
 
     fn remove_deferred_call_resolutions(&self,
index d57739c4002494165c4f48cf4fbc7abbce720425..d36124247945bf936f473641e49f704e82a0c7e7 100644 (file)
@@ -876,9 +876,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
         if let clean::ImplItem(ref i) = item.inner {
             match i.trait_ {
                 Some(clean::ResolvedPath{ did, .. }) => {
-                    let v = self.implementors.entry(did).get().unwrap_or_else(
-                        |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
-                    v.push(Implementor {
+                    self.implementors.entry(did).or_insert(vec![]).push(Implementor {
                         def_id: item.def_id,
                         generics: i.generics.clone(),
                         trait_: i.trait_.as_ref().unwrap().clone(),
@@ -1080,9 +1078,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                         };
 
                         if let Some(did) = did {
-                            let v = self.impls.entry(did).get().unwrap_or_else(
-                                |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
-                            v.push(Impl {
+                            self.impls.entry(did).or_insert(vec![]).push(Impl {
                                 impl_: i,
                                 dox: dox,
                                 stability: item.stability.clone(),
@@ -1334,9 +1330,8 @@ fn build_sidebar_items(&self, m: &clean::Module) -> HashMap<String, Vec<NameDoc>
                 Some(ref s) => s.to_string(),
             };
             let short = short.to_string();
-            let v = map.entry(short).get().unwrap_or_else(
-                |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
-            v.push((myname, Some(plain_summary_line(item.doc_value()))));
+            map.entry(short).or_insert(vec![])
+                .push((myname, Some(plain_summary_line(item.doc_value()))));
         }
 
         for (_, items) in &mut map {
index 9f1d876432c389c55cdf55e6c8d18f1fb25dfda5..12c71b1437ac4a898c008ee474b5a6119364e9f8 100644 (file)
 extern crate rustc_back;
 extern crate serialize;
 extern crate syntax;
-extern crate "test" as testing;
+extern crate test as testing;
 extern crate unicode;
 #[macro_use] extern crate log;
 
-extern crate "serialize" as rustc_serialize; // used by deriving
+extern crate serialize as rustc_serialize; // used by deriving
 
 use std::cell::RefCell;
 use std::collections::HashMap;
@@ -352,9 +352,7 @@ fn parse_externs(matches: &getopts::Matches) -> Result<core::Externs, String> {
             }
         };
         let name = name.to_string();
-        let locs = externs.entry(name).get().unwrap_or_else(
-            |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
-        locs.push(location.to_string());
+        externs.entry(name).or_insert(vec![]).push(location.to_string());
     }
     Ok(externs)
 }
index 0d6ed91d5298139b1cdf5800d3e6ac20c08aaab4..d5f494d2ae98e3df45ab7d6809dc0bffb71089dc 100644 (file)
@@ -1218,16 +1218,6 @@ pub fn as_null(&self) -> Option<()> {
     }
 }
 
-#[cfg(stage0)]
-impl<'a> Index<&'a str>  for Json {
-    type Output = Json;
-
-    fn index(&self, idx: & &str) -> &Json {
-        self.find(*idx).unwrap()
-    }
-}
-
-#[cfg(not(stage0))]
 impl<'a> Index<&'a str>  for Json {
     type Output = Json;
 
@@ -1236,19 +1226,6 @@ fn index(&self, idx: &'a str) -> &Json {
     }
 }
 
-#[cfg(stage0)]
-impl Index<uint> for Json {
-    type Output = Json;
-
-    fn index<'a>(&'a self, idx: &uint) -> &'a Json {
-        match self {
-            &Json::Array(ref v) => &v[*idx],
-            _ => panic!("can only index Json with uint if it is an array")
-        }
-    }
-}
-
-#[cfg(not(stage0))]
 impl Index<uint> for Json {
     type Output = Json;
 
index f9558b85825d2ee03ebacde2850aa347441a4d3e..06d1e69fff051cd0800a0a3da6ca4fec4cf1c42a 100644 (file)
@@ -23,7 +23,7 @@
 use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map};
 use marker::Sized;
 use mem::{self, replace};
-use ops::{Deref, FnMut, Index};
+use ops::{Deref, FnMut, FnOnce, Index};
 use option::Option::{self, Some, None};
 use rand::{self, Rng};
 use result::Result::{self, Ok, Err};
@@ -1247,22 +1247,6 @@ fn default() -> HashMap<K, V, S> {
     }
 }
 
-#[cfg(stage0)]
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<K, Q: ?Sized, V, S> Index<Q> for HashMap<K, V, S>
-    where K: Eq + Hash + Borrow<Q>,
-          Q: Eq + Hash,
-          S: HashState,
-{
-    type Output = V;
-
-    #[inline]
-    fn index<'a>(&'a self, index: &Q) -> &'a V {
-        self.get(index).expect("no entry found for key")
-    }
-}
-
-#[cfg(not(stage0))]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap<K, V, S>
     where K: Eq + Hash + Borrow<Q>,
@@ -1488,12 +1472,37 @@ impl<'a, K, V> Entry<'a, K, V> {
     /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant.
     #[unstable(feature = "std_misc",
                reason = "will soon be replaced by or_insert")]
+    #[deprecated(since = "1.0",
+                reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
+    /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
     pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
         match self {
             Occupied(entry) => Ok(entry.into_mut()),
             Vacant(entry) => Err(entry),
         }
     }
+
+    #[unstable(feature = "collections",
+               reason = "matches entry v3 specification, waiting for dust to settle")]
+    /// Ensures a value is in the entry by inserting the default if empty, and returns
+    /// a mutable reference to the value in the entry.
+    pub fn or_insert(self, default: V) -> &'a mut V {
+        match self {
+            Occupied(entry) => entry.into_mut(),
+            Vacant(entry) => entry.insert(default),
+        }
+    }
+
+    #[unstable(feature = "collections",
+               reason = "matches entry v3 specification, waiting for dust to settle")]
+    /// Ensures a value is in the entry by inserting the result of the default function if empty,
+    /// and returns a mutable reference to the value in the entry.
+    pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
+        match self {
+            Occupied(entry) => entry.into_mut(),
+            Vacant(entry) => entry.insert(default()),
+        }
+    }
 }
 
 impl<'a, K, V> OccupiedEntry<'a, K, V> {
index 8d24f6b191659f622aa6379aa4dc968ed8a2e499..0ac97b71298b85df6c737c6bec041bb512522544 100644 (file)
 //! let message = "she sells sea shells by the sea shore";
 //!
 //! for c in message.chars() {
-//!     match count.entry(c) {
-//!         Entry::Vacant(entry) => { entry.insert(1); },
-//!         Entry::Occupied(mut entry) => *entry.get_mut() += 1,
-//!     }
+//!     *count.entry(c).or_insert(0) += 1;
 //! }
 //!
 //! assert_eq!(count.get(&'s'), Some(&8));
 //! for id in orders.into_iter() {
 //!     // If this is the first time we've seen this customer, initialize them
 //!     // with no blood alcohol. Otherwise, just retrieve them.
-//!     let person = match blood_alcohol.entry(id) {
-//!         Entry::Vacant(entry) => entry.insert(Person{id: id, blood_alcohol: 0.0}),
-//!         Entry::Occupied(entry) => entry.into_mut(),
-//!     };
+//!     let person = blood_alcohol.entry(id).or_insert(Person{id: id, blood_alcohol: 0.0});
 //!
 //!     // Reduce their blood alcohol level. It takes time to order and drink a beer!
 //!     person.blood_alcohol *= 0.9;
index 5851c6e2998095923c744da0d01fceeb6556355b..99cbd26bcd1a86f8f8443110a74ba52151735373 100644 (file)
@@ -133,18 +133,6 @@ fn from(s: &'a OsStr) -> OsString {
     }
 }
 
-#[cfg(stage0)]
-#[stable(feature = "rust1", since = "1.0.0")]
-impl ops::Index<ops::RangeFull> for OsString {
-    type Output = OsStr;
-
-    #[inline]
-    fn index(&self, _index: &ops::RangeFull) -> &OsStr {
-        unsafe { mem::transmute(self.inner.as_slice()) }
-    }
-}
-
-#[cfg(not(stage0))]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl ops::Index<ops::RangeFull> for OsString {
     type Output = OsStr;
index 16298240acfbed7e9968ade38f5f875c7f70e9a2..ce03e26866b7dd1376393290fc2f29ef078ce09a 100644 (file)
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, R: Read + ?Sized> Read for &'a mut R {
+    #[inline]
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
         (**self).read(buf)
     }
+
+    #[inline]
     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
         (**self).read_to_end(buf)
     }
+
+    #[inline]
     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
         (**self).read_to_string(buf)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, W: Write + ?Sized> Write for &'a mut W {
+    #[inline]
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) }
+
+    #[inline]
     fn flush(&mut self) -> io::Result<()> { (**self).flush() }
+
+    #[inline]
     fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
         (**self).write_all(buf)
     }
+
+    #[inline]
     fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> {
         (**self).write_fmt(fmt)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, S: Seek + ?Sized> Seek for &'a mut S {
+    #[inline]
     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B {
+    #[inline]
     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
+
+    #[inline]
     fn consume(&mut self, amt: usize) { (**self).consume(amt) }
+
+    #[inline]
     fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> io::Result<usize> {
         (**self).read_until(byte, buf)
     }
+
+    #[inline]
     fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
         (**self).read_line(buf)
     }
@@ -63,38 +83,58 @@ fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<R: Read + ?Sized> Read for Box<R> {
+    #[inline]
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
         (**self).read(buf)
     }
+
+    #[inline]
     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
         (**self).read_to_end(buf)
     }
+
+    #[inline]
     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
         (**self).read_to_string(buf)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<W: Write + ?Sized> Write for Box<W> {
+    #[inline]
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) }
+
+    #[inline]
     fn flush(&mut self) -> io::Result<()> { (**self).flush() }
+
+    #[inline]
     fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
         (**self).write_all(buf)
     }
+
+    #[inline]
     fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> {
         (**self).write_fmt(fmt)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<S: Seek + ?Sized> Seek for Box<S> {
+    #[inline]
     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<B: BufRead + ?Sized> BufRead for Box<B> {
+    #[inline]
     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
+
+    #[inline]
     fn consume(&mut self, amt: usize) { (**self).consume(amt) }
+
+    #[inline]
     fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> io::Result<usize> {
         (**self).read_until(byte, buf)
     }
+
+    #[inline]
     fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
         (**self).read_line(buf)
     }
@@ -105,6 +145,7 @@ fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> Read for &'a [u8] {
+    #[inline]
     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
         let amt = cmp::min(buf.len(), self.len());
         let (a, b) = self.split_at(amt);
@@ -116,12 +157,16 @@ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> BufRead for &'a [u8] {
+    #[inline]
     fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) }
+
+    #[inline]
     fn consume(&mut self, amt: usize) { *self = &self[amt..]; }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> Write for &'a mut [u8] {
+    #[inline]
     fn write(&mut self, data: &[u8]) -> io::Result<usize> {
         let amt = cmp::min(data.len(), self.len());
         let (a, b) = mem::replace(self, &mut []).split_at_mut(amt);
@@ -130,6 +175,7 @@ fn write(&mut self, data: &[u8]) -> io::Result<usize> {
         Ok(amt)
     }
 
+    #[inline]
     fn write_all(&mut self, data: &[u8]) -> io::Result<()> {
         if try!(self.write(data)) == data.len() {
             Ok(())
@@ -138,20 +184,87 @@ fn write_all(&mut self, data: &[u8]) -> io::Result<()> {
         }
     }
 
+    #[inline]
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Write for Vec<u8> {
+    #[inline]
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
         self.push_all(buf);
         Ok(buf.len())
     }
 
+    #[inline]
     fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
         self.push_all(buf);
         Ok(())
     }
 
+    #[inline]
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
+
+#[cfg(test)]
+mod tests {
+    use io::prelude::*;
+    use vec::Vec;
+    use test;
+
+    #[bench]
+    fn bench_read_slice(b: &mut test::Bencher) {
+        let buf = [5; 1024];
+        let mut dst = [0; 128];
+
+        b.iter(|| {
+            let mut rd = &buf[..];
+            for _ in (0 .. 8) {
+                let _ = rd.read(&mut dst);
+                test::black_box(&dst);
+            }
+        })
+    }
+
+    #[bench]
+    fn bench_write_slice(b: &mut test::Bencher) {
+        let mut buf = [0; 1024];
+        let src = [5; 128];
+
+        b.iter(|| {
+            let mut wr = &mut buf[..];
+            for _ in (0 .. 8) {
+                let _ = wr.write_all(&src);
+                test::black_box(&wr);
+            }
+        })
+    }
+
+    #[bench]
+    fn bench_read_vec(b: &mut test::Bencher) {
+        let buf = vec![5; 1024];
+        let mut dst = [0; 128];
+
+        b.iter(|| {
+            let mut rd = &buf[..];
+            for _ in (0 .. 8) {
+                let _ = rd.read(&mut dst);
+                test::black_box(&dst);
+            }
+        })
+    }
+
+    #[bench]
+    fn bench_write_vec(b: &mut test::Bencher) {
+        let mut buf = Vec::with_capacity(1024);
+        let src = [5; 128];
+
+        b.iter(|| {
+            let mut wr = &mut buf[..];
+            for _ in (0 .. 8) {
+                let _ = wr.write_all(&src);
+                test::black_box(&wr);
+            }
+        })
+    }
+}
index cca6bb747d43c5f2e66f0f43dcd2883fbc18345b..7eb575a3a689b4ed9105a6aa0e57173e0d8ca5fa 100644 (file)
 
 #[macro_use]
 #[macro_reexport(vec, format)]
-extern crate "collections" as core_collections;
+extern crate collections as core_collections;
 
-#[allow(deprecated)] extern crate "rand" as core_rand;
+#[allow(deprecated)] extern crate rand as core_rand;
 extern crate alloc;
 extern crate unicode;
 extern crate libc;
 #[macro_use] #[no_link] extern crate rustc_bitflags;
 
 // Make std testable by not duplicating lang items. See #2912
-#[cfg(test)] extern crate "std" as realstd;
+#[cfg(test)] extern crate std as realstd;
 #[cfg(test)] pub use realstd::marker;
 #[cfg(test)] pub use realstd::ops;
 #[cfg(test)] pub use realstd::cmp;
index d877a60b079d7f6c8b8e1f2986c6055ea1d22f67..298085806bdecb66b74ff2225c2f5a262022f196 100644 (file)
@@ -397,7 +397,7 @@ fn fill_buf(&mut self) -> IoResult<&[u8]> {
 
 #[cfg(test)]
 mod test {
-    extern crate "test" as test_crate;
+    extern crate test as test_crate;
     use old_io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek, Buffer};
     use prelude::v1::{Ok, Err, Vec,  AsSlice};
     use prelude::v1::IteratorExt;
index 9f3dae34c7a4bff3a127111110fa955d335748e3..0d83e4497f7e2145ff86cc3e5b83ee814a9b1931 100644 (file)
@@ -634,30 +634,6 @@ fn initial_trail_surrogate(&self) -> Option<u16> {
 ///
 /// Panics when `begin` and `end` do not point to code point boundaries,
 /// or point beyond the end of the string.
-#[cfg(stage0)]
-impl ops::Index<ops::Range<usize>> for Wtf8 {
-    type Output = Wtf8;
-
-    #[inline]
-    fn index(&self, range: &ops::Range<usize>) -> &Wtf8 {
-        // is_code_point_boundary checks that the index is in [0, .len()]
-        if range.start <= range.end &&
-           is_code_point_boundary(self, range.start) &&
-           is_code_point_boundary(self, range.end) {
-            unsafe { slice_unchecked(self, range.start, range.end) }
-        } else {
-            slice_error_fail(self, range.start, range.end)
-        }
-    }
-}
-
-/// Return a slice of the given string for the byte range [`begin`..`end`).
-///
-/// # Panics
-///
-/// Panics when `begin` and `end` do not point to code point boundaries,
-/// or point beyond the end of the string.
-#[cfg(not(stage0))]
 impl ops::Index<ops::Range<usize>> for Wtf8 {
     type Output = Wtf8;
 
@@ -680,28 +656,6 @@ fn index(&self, range: ops::Range<usize>) -> &Wtf8 {
 ///
 /// Panics when `begin` is not at a code point boundary,
 /// or is beyond the end of the string.
-#[cfg(stage0)]
-impl ops::Index<ops::RangeFrom<usize>> for Wtf8 {
-    type Output = Wtf8;
-
-    #[inline]
-    fn index(&self, range: &ops::RangeFrom<usize>) -> &Wtf8 {
-        // is_code_point_boundary checks that the index is in [0, .len()]
-        if is_code_point_boundary(self, range.start) {
-            unsafe { slice_unchecked(self, range.start, self.len()) }
-        } else {
-            slice_error_fail(self, range.start, self.len())
-        }
-    }
-}
-
-/// Return a slice of the given string from byte `begin` to its end.
-///
-/// # Panics
-///
-/// Panics when `begin` is not at a code point boundary,
-/// or is beyond the end of the string.
-#[cfg(not(stage0))]
 impl ops::Index<ops::RangeFrom<usize>> for Wtf8 {
     type Output = Wtf8;
 
@@ -722,28 +676,6 @@ fn index(&self, range: ops::RangeFrom<usize>) -> &Wtf8 {
 ///
 /// Panics when `end` is not at a code point boundary,
 /// or is beyond the end of the string.
-#[cfg(stage0)]
-impl ops::Index<ops::RangeTo<usize>> for Wtf8 {
-    type Output = Wtf8;
-
-    #[inline]
-    fn index(&self, range: &ops::RangeTo<usize>) -> &Wtf8 {
-        // is_code_point_boundary checks that the index is in [0, .len()]
-        if is_code_point_boundary(self, range.end) {
-            unsafe { slice_unchecked(self, 0, range.end) }
-        } else {
-            slice_error_fail(self, 0, range.end)
-        }
-    }
-}
-
-/// Return a slice of the given string from its beginning to byte `end`.
-///
-/// # Panics
-///
-/// Panics when `end` is not at a code point boundary,
-/// or is beyond the end of the string.
-#[cfg(not(stage0))]
 impl ops::Index<ops::RangeTo<usize>> for Wtf8 {
     type Output = Wtf8;
 
@@ -758,17 +690,6 @@ fn index(&self, range: ops::RangeTo<usize>) -> &Wtf8 {
     }
 }
 
-#[cfg(stage0)]
-impl ops::Index<ops::RangeFull> for Wtf8 {
-    type Output = Wtf8;
-
-    #[inline]
-    fn index(&self, _range: &ops::RangeFull) -> &Wtf8 {
-        self
-    }
-}
-
-#[cfg(not(stage0))]
 impl ops::Index<ops::RangeFull> for Wtf8 {
     type Output = Wtf8;
 
index 58b6d96607df777454cb9b841e60fddc4c77848e..0c5e4d67642acc08a82fdbd838ef4dbf21de7dec 100644 (file)
@@ -332,6 +332,46 @@ pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>)
     RefCell::new(f)
 }
 
+/// This method helps to extract all the type parameters referenced from a
+/// type. For a type parameter `<T>`, it looks for either a `TyPath` that
+/// is not global and starts with `T`, or a `TyQPath`.
+fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec<P<ast::Ty>> {
+    use visit;
+
+    struct Visitor<'a> {
+        ty_param_names: &'a [ast::Name],
+        types: Vec<P<ast::Ty>>,
+    }
+
+    impl<'a> visit::Visitor<'a> for Visitor<'a> {
+        fn visit_ty(&mut self, ty: &'a ast::Ty) {
+            match ty.node {
+                ast::TyPath(_, ref path) if !path.global => {
+                    match path.segments.first() {
+                        Some(segment) => {
+                            if self.ty_param_names.contains(&segment.identifier.name) {
+                                self.types.push(P(ty.clone()));
+                            }
+                        }
+                        None => {}
+                    }
+                }
+                _ => {}
+            }
+
+            visit::walk_ty(self, ty)
+        }
+    }
+
+    let mut visitor = Visitor {
+        ty_param_names: ty_param_names,
+        types: Vec::new(),
+    };
+
+    visit::Visitor::visit_ty(&mut visitor, ty);
+
+    visitor.types
+}
 
 impl<'a> TraitDef<'a> {
     pub fn expand<F>(&self,
@@ -374,18 +414,42 @@ pub fn expand<F>(&self,
         }))
     }
 
-    /// Given that we are deriving a trait `Tr` for a type `T<'a, ...,
-    /// 'z, A, ..., Z>`, creates an impl like:
+    /// Given that we are deriving a trait `DerivedTrait` for a type like:
     ///
     /// ```ignore
-    /// impl<'a, ..., 'z, A:Tr B1 B2, ..., Z: Tr B1 B2> Tr for T<A, ..., Z> { ... }
+    /// struct Struct<'a, ..., 'z, A, B: DeclaredTrait, C, ..., Z> where C: WhereTrait {
+    ///     a: A,
+    ///     b: B::Item,
+    ///     b1: <B as DeclaredTrait>::Item,
+    ///     c1: <C as WhereTrait>::Item,
+    ///     c2: Option<<C as WhereTrait>::Item>,
+    ///     ...
+    /// }
+    /// ```
+    ///
+    /// create an impl like:
+    ///
+    /// ```ignore
+    /// impl<'a, ..., 'z, A, B: DeclaredTrait, C, ...  Z> where
+    ///     C:                       WhereTrait,
+    ///     A: DerivedTrait + B1 + ... + BN,
+    ///     B: DerivedTrait + B1 + ... + BN,
+    ///     C: DerivedTrait + B1 + ... + BN,
+    ///     B::Item:                 DerivedTrait + B1 + ... + BN,
+    ///     <C as WhereTrait>::Item: DerivedTrait + B1 + ... + BN,
+    ///     ...
+    /// {
+    ///     ...
+    /// }
     /// ```
     ///
-    /// where B1, B2, ... are the bounds given by `bounds_paths`.'
+    /// where B1, ..., BN are the bounds given by `bounds_paths`.'. Z is a phantom type, and
+    /// therefore does not get bound by the derived trait.
     fn create_derived_impl(&self,
                            cx: &mut ExtCtxt,
                            type_ident: Ident,
                            generics: &Generics,
+                           field_tys: Vec<P<ast::Ty>>,
                            methods: Vec<P<ast::ImplItem>>) -> P<ast::Item> {
         let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
 
@@ -466,6 +530,35 @@ fn create_derived_impl(&self,
             }
         }));
 
+        if !ty_params.is_empty() {
+            let ty_param_names: Vec<ast::Name> = ty_params.iter()
+                .map(|ty_param| ty_param.ident.name)
+                .collect();
+
+            for field_ty in field_tys.into_iter() {
+                let tys = find_type_parameters(&*field_ty, &ty_param_names);
+
+                for ty in tys.into_iter() {
+                    let mut bounds: Vec<_> = self.additional_bounds.iter().map(|p| {
+                        cx.typarambound(p.to_path(cx, self.span, type_ident, generics))
+                    }).collect();
+
+                    // require the current trait
+                    bounds.push(cx.typarambound(trait_path.clone()));
+
+                    let predicate = ast::WhereBoundPredicate {
+                        span: self.span,
+                        bound_lifetimes: vec![],
+                        bounded_ty: ty,
+                        bounds: OwnedSlice::from_vec(bounds),
+                    };
+
+                    let predicate = ast::WherePredicate::BoundPredicate(predicate);
+                    where_clause.predicates.push(predicate);
+                }
+            }
+        }
+
         let trait_generics = Generics {
             lifetimes: lifetimes,
             ty_params: OwnedSlice::from_vec(ty_params),
@@ -518,6 +611,10 @@ fn expand_struct_def(&self,
                          struct_def: &StructDef,
                          type_ident: Ident,
                          generics: &Generics) -> P<ast::Item> {
+        let field_tys: Vec<P<ast::Ty>> = struct_def.fields.iter()
+            .map(|field| field.node.ty.clone())
+            .collect();
+
         let methods = self.methods.iter().map(|method_def| {
             let (explicit_self, self_args, nonself_args, tys) =
                 method_def.split_self_nonself_args(
@@ -550,7 +647,7 @@ fn expand_struct_def(&self,
                                      body)
         }).collect();
 
-        self.create_derived_impl(cx, type_ident, generics, methods)
+        self.create_derived_impl(cx, type_ident, generics, field_tys, methods)
     }
 
     fn expand_enum_def(&self,
@@ -558,6 +655,21 @@ fn expand_enum_def(&self,
                        enum_def: &EnumDef,
                        type_ident: Ident,
                        generics: &Generics) -> P<ast::Item> {
+        let mut field_tys = Vec::new();
+
+        for variant in enum_def.variants.iter() {
+            match variant.node.kind {
+                ast::VariantKind::TupleVariantKind(ref args) => {
+                    field_tys.extend(args.iter()
+                        .map(|arg| arg.ty.clone()));
+                }
+                ast::VariantKind::StructVariantKind(ref args) => {
+                    field_tys.extend(args.fields.iter()
+                        .map(|field| field.node.ty.clone()));
+                }
+            }
+        }
+
         let methods = self.methods.iter().map(|method_def| {
             let (explicit_self, self_args, nonself_args, tys) =
                 method_def.split_self_nonself_args(cx, self,
@@ -590,7 +702,7 @@ fn expand_enum_def(&self,
                                      body)
         }).collect();
 
-        self.create_derived_impl(cx, type_ident, generics, methods)
+        self.create_derived_impl(cx, type_ident, generics, field_tys, methods)
     }
 }
 
index 72431d8e6aa2c317ccd23aa9449193f01445c344..a2023d6832efbce2fe48cf33ed7e85962fc9c431 100644 (file)
@@ -66,9 +66,8 @@ pub fn apply_mark(m: Mrk, ctxt: SyntaxContext) -> SyntaxContext {
 /// Extend a syntax context with a given mark and sctable (explicit memoization)
 fn apply_mark_internal(m: Mrk, ctxt: SyntaxContext, table: &SCTable) -> SyntaxContext {
     let key = (ctxt, m);
-    * table.mark_memo.borrow_mut().entry(key).get().unwrap_or_else(
-          |vacant_entry|
-              vacant_entry.insert(idx_push(&mut *table.table.borrow_mut(), Mark(m, ctxt))))
+    * table.mark_memo.borrow_mut().entry(key)
+        .or_insert_with(|| idx_push(&mut *table.table.borrow_mut(), Mark(m, ctxt)))
 }
 
 /// Extend a syntax context with a given rename
@@ -84,9 +83,8 @@ fn apply_rename_internal(id: Ident,
                        table: &SCTable) -> SyntaxContext {
     let key = (ctxt, id, to);
 
-    * table.rename_memo.borrow_mut().entry(key).get().unwrap_or_else(
-          |vacant_entry|
-              vacant_entry.insert(idx_push(&mut *table.table.borrow_mut(), Rename(id, to, ctxt))))
+    * table.rename_memo.borrow_mut().entry(key)
+        .or_insert_with(|| idx_push(&mut *table.table.borrow_mut(), Rename(id, to, ctxt)))
 }
 
 /// Apply a list of renamings to a context
index a25a6451918d72e671784b951fab29d2a3b4c75b..5bbcdea879dff3d90d64303daa33c0fdb71ff40a 100644 (file)
@@ -171,10 +171,12 @@ fn to_source_with_hygiene(&self) -> String {
         }
     }
 
+    impl_to_source! { ast::Path, path_to_string }
     impl_to_source! { ast::Ty, ty_to_string }
     impl_to_source! { ast::Block, block_to_string }
     impl_to_source! { ast::Arg, arg_to_string }
     impl_to_source! { Generics, generics_to_string }
+    impl_to_source! { ast::WhereClause, where_clause_to_string }
     impl_to_source! { P<ast::Item>, item_to_string }
     impl_to_source! { P<ast::ImplItem>, impl_item_to_string }
     impl_to_source! { P<ast::TraitItem>, trait_item_to_string }
@@ -310,6 +312,7 @@ fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
     }
 
     impl_to_tokens! { ast::Ident }
+    impl_to_tokens! { ast::Path }
     impl_to_tokens! { P<ast::Item> }
     impl_to_tokens! { P<ast::ImplItem> }
     impl_to_tokens! { P<ast::TraitItem> }
@@ -319,6 +322,7 @@ fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
     impl_to_tokens! { ast::Ty }
     impl_to_tokens_lifetime! { &'a [ast::Ty] }
     impl_to_tokens! { Generics }
+    impl_to_tokens! { ast::WhereClause }
     impl_to_tokens! { P<ast::Stmt> }
     impl_to_tokens! { P<ast::Expr> }
     impl_to_tokens! { ast::Block }
index 9af7b9ab633116619c2e9ff3cc12b4ad28e5ad74..cf4594f514b1a15d3f7035f3c94f5ef5e54342dc 100644 (file)
@@ -35,7 +35,6 @@
 #![feature(quote, unsafe_destructor)]
 #![feature(rustc_private)]
 #![feature(staged_api)]
-#![feature(std_misc)]
 #![feature(unicode)]
 #![feature(path_ext)]
 #![feature(str_char)]
@@ -50,7 +49,7 @@
 #[macro_use] extern crate log;
 #[macro_use] #[no_link] extern crate rustc_bitflags;
 
-extern crate "serialize" as rustc_serialize; // used by deriving
+extern crate serialize as rustc_serialize; // used by deriving
 
 pub mod util {
     pub mod interner;
index 220ea30256e03cba2014e41a1bdb663671b95e49..786970ce252965f652cedb01d6c2c5e419e159ac 100644 (file)
@@ -1126,7 +1126,7 @@ pub fn parse_trait_items(&mut self) -> Vec<P<TraitItem>> {
                     p.parse_arg_general(false)
                 });
 
-                p.parse_where_clause(&mut generics);
+                generics.where_clause = p.parse_where_clause();
                 let sig = ast::MethodSig {
                     unsafety: style,
                     decl: d,
@@ -3932,9 +3932,14 @@ fn forbid_lifetime(&mut self) {
     /// ```
     /// where T : Trait<U, V> + 'b, 'a : 'b
     /// ```
-    fn parse_where_clause(&mut self, generics: &mut ast::Generics) {
+    fn parse_where_clause(&mut self) -> ast::WhereClause {
+        let mut where_clause = WhereClause {
+            id: ast::DUMMY_NODE_ID,
+            predicates: Vec::new(),
+        };
+
         if !self.eat_keyword(keywords::Where) {
-            return
+            return where_clause;
         }
 
         let mut parsed_something = false;
@@ -3957,7 +3962,7 @@ fn parse_where_clause(&mut self, generics: &mut ast::Generics) {
                     let hi = self.span.hi;
                     let span = mk_sp(lo, hi);
 
-                    generics.where_clause.predicates.push(ast::WherePredicate::RegionPredicate(
+                    where_clause.predicates.push(ast::WherePredicate::RegionPredicate(
                         ast::WhereRegionPredicate {
                             span: span,
                             lifetime: bounded_lifetime,
@@ -3992,7 +3997,7 @@ fn parse_where_clause(&mut self, generics: &mut ast::Generics) {
                                            at least one bound in it");
                         }
 
-                        generics.where_clause.predicates.push(ast::WherePredicate::BoundPredicate(
+                        where_clause.predicates.push(ast::WherePredicate::BoundPredicate(
                                 ast::WhereBoundPredicate {
                                     span: span,
                                     bound_lifetimes: bound_lifetimes,
@@ -4005,7 +4010,7 @@ fn parse_where_clause(&mut self, generics: &mut ast::Generics) {
                         // let ty = self.parse_ty();
                         let hi = self.span.hi;
                         let span = mk_sp(lo, hi);
-                        // generics.where_clause.predicates.push(
+                        // where_clause.predicates.push(
                         //     ast::WherePredicate::EqPredicate(ast::WhereEqPredicate {
                         //         id: ast::DUMMY_NODE_ID,
                         //         span: span,
@@ -4036,6 +4041,8 @@ fn parse_where_clause(&mut self, generics: &mut ast::Generics) {
                           "a `where` clause must have at least one predicate \
                            in it");
         }
+
+        where_clause
     }
 
     fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
@@ -4354,7 +4361,7 @@ fn mk_item(&mut self, lo: BytePos, hi: BytePos, ident: Ident,
     fn parse_item_fn(&mut self, unsafety: Unsafety, abi: abi::Abi) -> ItemInfo {
         let (ident, mut generics) = self.parse_fn_header();
         let decl = self.parse_fn_decl(false);
-        self.parse_where_clause(&mut generics);
+        generics.where_clause = self.parse_where_clause();
         let (inner_attrs, body) = self.parse_inner_attrs_and_block();
         (ident, ItemFn(decl, unsafety, abi, generics, body), Some(inner_attrs))
     }
@@ -4439,7 +4446,7 @@ fn parse_impl_method(&mut self, vis: Visibility)
             let (explicit_self, decl) = self.parse_fn_decl_with_self(|p| {
                     p.parse_arg()
                 });
-            self.parse_where_clause(&mut generics);
+            generics.where_clause = self.parse_where_clause();
             let (inner_attrs, body) = self.parse_inner_attrs_and_block();
             (ident, inner_attrs, MethodImplItem(ast::MethodSig {
                 generics: generics,
@@ -4460,7 +4467,7 @@ fn parse_item_trait(&mut self, unsafety: Unsafety) -> ItemInfo {
         // Parse supertrait bounds.
         let bounds = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare);
 
-        self.parse_where_clause(&mut tps);
+        tps.where_clause = self.parse_where_clause();
 
         let meths = self.parse_trait_items();
         (ident, ItemTrait(unsafety, tps, bounds, meths), None)
@@ -4531,7 +4538,7 @@ fn parse_item_impl(&mut self, unsafety: ast::Unsafety) -> ItemInfo {
             if opt_trait.is_some() {
                 ty = self.parse_ty_sum();
             }
-            self.parse_where_clause(&mut generics);
+            generics.where_clause = self.parse_where_clause();
 
             self.expect(&token::OpenDelim(token::Brace));
             let attrs = self.parse_inner_attributes();
@@ -4603,7 +4610,7 @@ fn parse_item_struct(&mut self) -> ItemInfo {
         // struct.
 
         let (fields, ctor_id) = if self.token.is_keyword(keywords::Where) {
-            self.parse_where_clause(&mut generics);
+            generics.where_clause = self.parse_where_clause();
             if self.eat(&token::Semi) {
                 // If we see a: `struct Foo<T> where T: Copy;` style decl.
                 (Vec::new(), Some(ast::DUMMY_NODE_ID))
@@ -4684,12 +4691,12 @@ pub fn parse_tuple_struct_body(&mut self,
                     token::get_ident(class_name.clone())));
             }
 
-            self.parse_where_clause(generics);
+            generics.where_clause = self.parse_where_clause();
             self.expect(&token::Semi);
             fields
         // This is the case where we just see struct Foo<T> where T: Copy;
         } else if self.token.is_keyword(keywords::Where) {
-            self.parse_where_clause(generics);
+            generics.where_clause = self.parse_where_clause();
             self.expect(&token::Semi);
             Vec::new()
         // This case is where we see: `struct Foo<T>;`
@@ -4937,7 +4944,7 @@ fn parse_item_foreign_fn(&mut self, vis: ast::Visibility,
 
         let (ident, mut generics) = self.parse_fn_header();
         let decl = self.parse_fn_decl(true);
-        self.parse_where_clause(&mut generics);
+        generics.where_clause = self.parse_where_clause();
         let hi = self.span.hi;
         self.expect(&token::Semi);
         P(ast::ForeignItem {
@@ -5074,7 +5081,7 @@ fn parse_item_foreign_mod(&mut self,
     fn parse_item_type(&mut self) -> ItemInfo {
         let ident = self.parse_ident();
         let mut tps = self.parse_generics();
-        self.parse_where_clause(&mut tps);
+        tps.where_clause = self.parse_where_clause();
         self.expect(&token::Eq);
         let ty = self.parse_ty_sum();
         self.expect(&token::Semi);
@@ -5174,7 +5181,7 @@ fn parse_enum_def(&mut self, _generics: &ast::Generics) -> EnumDef {
     fn parse_item_enum(&mut self) -> ItemInfo {
         let id = self.parse_ident();
         let mut generics = self.parse_generics();
-        self.parse_where_clause(&mut generics);
+        generics.where_clause = self.parse_where_clause();
         self.expect(&token::OpenDelim(token::Brace));
 
         let enum_definition = self.parse_enum_def(&generics);
index 2bc3fc1017ae6808e7940d2e7b75822fe8f8408d..da1b7a7bdde50e93ec50a11aac7702b4db45b759 100644 (file)
@@ -367,6 +367,10 @@ pub fn generics_to_string(generics: &ast::Generics) -> String {
     $to_string(|s| s.print_generics(generics))
 }
 
+pub fn where_clause_to_string(i: &ast::WhereClause) -> String {
+    $to_string(|s| s.print_where_clause(i))
+}
+
 pub fn fn_block_to_string(p: &ast::FnDecl) -> String {
     $to_string(|s| s.print_fn_block_args(p))
 }
@@ -917,7 +921,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> io::Result<()> {
                 try!(space(&mut self.s));
                 try!(self.word_space("="));
                 try!(self.print_type(&**ty));
-                try!(self.print_where_clause(params));
+                try!(self.print_where_clause(&params.where_clause));
                 try!(word(&mut self.s, ";"));
                 try!(self.end()); // end the outer ibox
             }
@@ -980,7 +984,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> io::Result<()> {
                 }
 
                 try!(self.print_type(&**ty));
-                try!(self.print_where_clause(generics));
+                try!(self.print_where_clause(&generics.where_clause));
 
                 try!(space(&mut self.s));
                 try!(self.bopen());
@@ -1008,7 +1012,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> io::Result<()> {
                     }
                 }
                 try!(self.print_bounds(":", &real_bounds[..]));
-                try!(self.print_where_clause(generics));
+                try!(self.print_where_clause(&generics.where_clause));
                 try!(word(&mut self.s, " "));
                 try!(self.bopen());
                 for trait_item in trait_items {
@@ -1066,7 +1070,7 @@ pub fn print_enum_def(&mut self, enum_definition: &ast::EnumDef,
         try!(self.head(&visibility_qualified(visibility, "enum")));
         try!(self.print_ident(ident));
         try!(self.print_generics(generics));
-        try!(self.print_where_clause(generics));
+        try!(self.print_where_clause(&generics.where_clause));
         try!(space(&mut self.s));
         self.print_variants(&enum_definition.variants, span)
     }
@@ -1120,12 +1124,12 @@ pub fn print_struct(&mut self,
                 ));
                 try!(self.pclose());
             }
-            try!(self.print_where_clause(generics));
+            try!(self.print_where_clause(&generics.where_clause));
             try!(word(&mut self.s, ";"));
             try!(self.end());
             self.end() // close the outer-box
         } else {
-            try!(self.print_where_clause(generics));
+            try!(self.print_where_clause(&generics.where_clause));
             try!(self.nbsp());
             try!(self.bopen());
             try!(self.hardbreak_if_not_bol());
@@ -2348,7 +2352,7 @@ pub fn print_fn(&mut self,
         }
         try!(self.print_generics(generics));
         try!(self.print_fn_args_and_ret(decl, opt_explicit_self));
-        self.print_where_clause(generics)
+        self.print_where_clause(&generics.where_clause)
     }
 
     pub fn print_fn_args(&mut self, decl: &ast::FnDecl,
@@ -2531,19 +2535,16 @@ pub fn print_ty_param(&mut self, param: &ast::TyParam) -> io::Result<()> {
         }
     }
 
-    pub fn print_where_clause(&mut self, generics: &ast::Generics)
+    pub fn print_where_clause(&mut self, where_clause: &ast::WhereClause)
                               -> io::Result<()> {
-        if generics.where_clause.predicates.len() == 0 {
+        if where_clause.predicates.len() == 0 {
             return Ok(())
         }
 
         try!(space(&mut self.s));
         try!(self.word_space("where"));
 
-        for (i, predicate) in generics.where_clause
-                                      .predicates
-                                      .iter()
-                                      .enumerate() {
+        for (i, predicate) in where_clause.predicates.iter().enumerate() {
             if i != 0 {
                 try!(self.word_space(","));
             }
index c48c7e413d03baa961ec62c60a07b19e82da678c..3e26a68d5909edb9796532e0f6b249c0ae181030 100644 (file)
@@ -50,7 +50,7 @@
 
 extern crate getopts;
 extern crate serialize;
-extern crate "serialize" as rustc_serialize;
+extern crate serialize as rustc_serialize;
 extern crate term;
 extern crate libc;
 
index db5a25b9bedcaf9e2352a9284566ba2626e99c14..2aeade5066fde0630cc7cfa2b0500dc0a74228ee 100644 (file)
 pub use tables::normalization::canonical_combining_class;
 pub use tables::UNICODE_VERSION;
 
-#[cfg(stage0)]
-/// Functionality for manipulating `char`.
-#[stable(feature = "rust1", since = "1.0.0")]
-pub trait CharExt {
-    /// Checks if a `char` parses as a numeric digit in the given radix.
-    ///
-    /// Compared to `is_numeric()`, this function only recognizes the characters
-    /// `0-9`, `a-z` and `A-Z`.
-    ///
-    /// # Return value
-    ///
-    /// Returns `true` if `c` is a valid digit under `radix`, and `false`
-    /// otherwise.
-    ///
-    /// # Panics
-    ///
-    /// Panics if given a radix > 36.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// let c = '1';
-    ///
-    /// assert!(c.is_digit(10));
-    ///
-    /// assert!('f'.is_digit(16));
-    /// ```
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_digit(self, radix: u32) -> bool;
-
-    /// Converts a character to the corresponding digit.
-    ///
-    /// # Return value
-    ///
-    /// If `c` is between '0' and '9', the corresponding value between 0 and
-    /// 9. If `c` is 'a' or 'A', 10. If `c` is 'b' or 'B', 11, etc. Returns
-    /// none if the character does not refer to a digit in the given radix.
-    ///
-    /// # Panics
-    ///
-    /// Panics if given a radix outside the range [0..36].
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// let c = '1';
-    ///
-    /// assert_eq!(c.to_digit(10), Some(1));
-    ///
-    /// assert_eq!('f'.to_digit(16), Some(15));
-    /// ```
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn to_digit(self, radix: u32) -> Option<u32>;
-
-    /// Returns an iterator that yields the hexadecimal Unicode escape of a
-    /// character, as `char`s.
-    ///
-    /// All characters are escaped with Rust syntax of the form `\\u{NNNN}`
-    /// where `NNNN` is the shortest hexadecimal representation of the code
-    /// point.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// for i in '❤'.escape_unicode() {
-    ///     println!("{}", i);
-    /// }
-    /// ```
-    ///
-    /// This prints:
-    ///
-    /// ```text
-    /// \
-    /// u
-    /// {
-    /// 2
-    /// 7
-    /// 6
-    /// 4
-    /// }
-    /// ```
-    ///
-    /// Collecting into a `String`:
-    ///
-    /// ```
-    /// let heart: String = '❤'.escape_unicode().collect();
-    ///
-    /// assert_eq!(heart, r"\u{2764}");
-    /// ```
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn escape_unicode(self) -> EscapeUnicode;
-
-    /// Returns an iterator that yields the 'default' ASCII and
-    /// C++11-like literal escape of a character, as `char`s.
-    ///
-    /// The default is chosen with a bias toward producing literals that are
-    /// legal in a variety of languages, including C++11 and similar C-family
-    /// languages. The exact rules are:
-    ///
-    /// * Tab, CR and LF are escaped as '\t', '\r' and '\n' respectively.
-    /// * Single-quote, double-quote and backslash chars are backslash-
-    ///   escaped.
-    /// * Any other chars in the range [0x20,0x7e] are not escaped.
-    /// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// for i in '"'.escape_default() {
-    ///     println!("{}", i);
-    /// }
-    /// ```
-    ///
-    /// This prints:
-    ///
-    /// ```text
-    /// \
-    /// "
-    /// ```
-    ///
-    /// Collecting into a `String`:
-    ///
-    /// ```
-    /// let quote: String = '"'.escape_default().collect();
-    ///
-    /// assert_eq!(quote, "\\\"");
-    /// ```
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn escape_default(self) -> EscapeDefault;
-
-    /// Returns the number of bytes this character would need if encoded in
-    /// UTF-8.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// let n = 'ß'.len_utf8();
-    ///
-    /// assert_eq!(n, 2);
-    /// ```
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn len_utf8(self) -> usize;
-
-    /// Returns the number of 16-bit code units this character would need if
-    /// encoded in UTF-16.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// let n = 'ß'.len_utf16();
-    ///
-    /// assert_eq!(n, 1);
-    /// ```
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn len_utf16(self) -> usize;
-
-    /// Encodes this character as UTF-8 into the provided byte buffer, and then
-    /// returns the number of bytes written.
-    ///
-    /// If the buffer is not large enough, nothing will be written into it and a
-    /// `None` will be returned. A buffer of length four is large enough to
-    /// encode any `char`.
-    ///
-    /// # Examples
-    ///
-    /// In both of these examples, 'ß' takes two bytes to encode.
-    ///
-    /// ```
-    /// # #![feature(unicode)]
-    /// let mut b = [0; 2];
-    ///
-    /// let result = 'ß'.encode_utf8(&mut b);
-    ///
-    /// assert_eq!(result, Some(2));
-    /// ```
-    ///
-    /// A buffer that's too small:
-    ///
-    /// ```
-    /// # #![feature(unicode)]
-    /// let mut b = [0; 1];
-    ///
-    /// let result = 'ß'.encode_utf8(&mut b);
-    ///
-    /// assert_eq!(result, None);
-    /// ```
-    #[unstable(feature = "unicode",
-               reason = "pending decision about Iterator/Writer/Reader")]
-    fn encode_utf8(self, dst: &mut [u8]) -> Option<usize>;
-
-    /// Encodes this character as UTF-16 into the provided `u16` buffer, and
-    /// then returns the number of `u16`s written.
-    ///
-    /// If the buffer is not large enough, nothing will be written into it and a
-    /// `None` will be returned. A buffer of length 2 is large enough to encode
-    /// any `char`.
-    ///
-    /// # Examples
-    ///
-    /// In both of these examples, 'ß' takes one `u16` to encode.
-    ///
-    /// ```
-    /// # #![feature(unicode)]
-    /// let mut b = [0; 1];
-    ///
-    /// let result = 'ß'.encode_utf16(&mut b);
-    ///
-    /// assert_eq!(result, Some(1));
-    /// ```
-    ///
-    /// A buffer that's too small:
-    ///
-    /// ```
-    /// # #![feature(unicode)]
-    /// let mut b = [0; 0];
-    ///
-    /// let result = 'ß'.encode_utf8(&mut b);
-    ///
-    /// assert_eq!(result, None);
-    /// ```
-    #[unstable(feature = "unicode",
-               reason = "pending decision about Iterator/Writer/Reader")]
-    fn encode_utf16(self, dst: &mut [u16]) -> Option<usize>;
-
-    /// Returns whether the specified character is considered a Unicode
-    /// alphabetic code point.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_alphabetic(self) -> bool;
-
-    /// Returns whether the specified character satisfies the 'XID_Start'
-    /// Unicode property.
-    ///
-    /// 'XID_Start' is a Unicode Derived Property specified in
-    /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
-    /// mostly similar to ID_Start but modified for closure under NFKx.
-    #[unstable(feature = "unicode",
-               reason = "mainly needed for compiler internals")]
-    fn is_xid_start(self) -> bool;
-
-    /// Returns whether the specified `char` satisfies the 'XID_Continue'
-    /// Unicode property.
-    ///
-    /// 'XID_Continue' is a Unicode Derived Property specified in
-    /// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
-    /// mostly similar to 'ID_Continue' but modified for closure under NFKx.
-    #[unstable(feature = "unicode",
-               reason = "mainly needed for compiler internals")]
-    fn is_xid_continue(self) -> bool;
-
-    /// Indicates whether a character is in lowercase.
-    ///
-    /// This is defined according to the terms of the Unicode Derived Core
-    /// Property `Lowercase`.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_lowercase(self) -> bool;
-
-    /// Indicates whether a character is in uppercase.
-    ///
-    /// This is defined according to the terms of the Unicode Derived Core
-    /// Property `Uppercase`.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_uppercase(self) -> bool;
-
-    /// Indicates whether a character is whitespace.
-    ///
-    /// Whitespace is defined in terms of the Unicode Property `White_Space`.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_whitespace(self) -> bool;
-
-    /// Indicates whether a character is alphanumeric.
-    ///
-    /// Alphanumericness is defined in terms of the Unicode General Categories
-    /// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_alphanumeric(self) -> bool;
-
-    /// Indicates whether a character is a control code point.
-    ///
-    /// Control code points are defined in terms of the Unicode General
-    /// Category `Cc`.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_control(self) -> bool;
-
-    /// Indicates whether the character is numeric (Nd, Nl, or No).
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn is_numeric(self) -> bool;
-
-    /// Converts a character to its lowercase equivalent.
-    ///
-    /// The case-folding performed is the common or simple mapping. See
-    /// `to_uppercase()` for references and more information.
-    ///
-    /// # Return value
-    ///
-    /// Returns an iterator which yields the characters corresponding to the
-    /// lowercase equivalent of the character. If no conversion is possible then
-    /// the input character is returned.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn to_lowercase(self) -> ToLowercase;
-
-    /// Converts a character to its uppercase equivalent.
-    ///
-    /// The case-folding performed is the common or simple mapping: it maps
-    /// one Unicode codepoint to its uppercase equivalent according to the
-    /// Unicode database [1]. The additional [`SpecialCasing.txt`] is not yet
-    /// considered here, but the iterator returned will soon support this form
-    /// of case folding.
-    ///
-    /// A full reference can be found here [2].
-    ///
-    /// # Return value
-    ///
-    /// Returns an iterator which yields the characters corresponding to the
-    /// uppercase equivalent of the character. If no conversion is possible then
-    /// the input character is returned.
-    ///
-    /// [1]: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
-    ///
-    /// [`SpecialCasing`.txt`]: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt
-    ///
-    /// [2]: http://www.unicode.org/versions/Unicode4.0.0/ch03.pdf#G33992
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn to_uppercase(self) -> ToUppercase;
-
-    /// Returns this character's displayed width in columns, or `None` if it is a
-    /// control character other than `'\x00'`.
-    ///
-    /// `is_cjk` determines behavior for characters in the Ambiguous category:
-    /// if `is_cjk` is `true`, these are 2 columns wide; otherwise, they are 1.
-    /// In CJK contexts, `is_cjk` should be `true`, else it should be `false`.
-    /// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
-    /// recommends that these characters be treated as 1 column (i.e.,
-    /// `is_cjk` = `false`) if the context cannot be reliably determined.
-    #[unstable(feature = "unicode",
-               reason = "needs expert opinion. is_cjk flag stands out as ugly")]
-    fn width(self, is_cjk: bool) -> Option<usize>;
-}
-
-#[cfg(stage0)]
-#[stable(feature = "rust1", since = "1.0.0")]
-impl CharExt for char {
-    #[inline]
-    fn is_digit(self, radix: u32) -> bool { C::is_digit(self, radix) }
-    fn to_digit(self, radix: u32) -> Option<u32> { C::to_digit(self, radix) }
-    fn escape_unicode(self) -> EscapeUnicode { C::escape_unicode(self) }
-    fn escape_default(self) -> EscapeDefault { C::escape_default(self) }
-    fn len_utf8(self) -> usize { C::len_utf8(self) }
-    fn len_utf16(self) -> usize { C::len_utf16(self) }
-    fn encode_utf8(self, dst: &mut [u8]) -> Option<usize> { C::encode_utf8(self, dst) }
-    fn encode_utf16(self, dst: &mut [u16]) -> Option<usize> { C::encode_utf16(self, dst) }
-
-    #[inline]
-    fn is_alphabetic(self) -> bool {
-        match self {
-            'a' ... 'z' | 'A' ... 'Z' => true,
-            c if c > '\x7f' => derived_property::Alphabetic(c),
-            _ => false
-        }
-    }
-
-    #[inline]
-    fn is_xid_start(self) -> bool { derived_property::XID_Start(self) }
-
-    #[inline]
-    fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) }
-
-    #[inline]
-    fn is_lowercase(self) -> bool {
-        match self {
-            'a' ... 'z' => true,
-            c if c > '\x7f' => derived_property::Lowercase(c),
-            _ => false
-        }
-    }
-
-    #[inline]
-    fn is_uppercase(self) -> bool {
-        match self {
-            'A' ... 'Z' => true,
-            c if c > '\x7f' => derived_property::Uppercase(c),
-            _ => false
-        }
-    }
-
-    #[inline]
-    fn is_whitespace(self) -> bool {
-        match self {
-            ' ' | '\x09' ... '\x0d' => true,
-            c if c > '\x7f' => property::White_Space(c),
-            _ => false
-        }
-    }
-
-    #[inline]
-    fn is_alphanumeric(self) -> bool {
-        self.is_alphabetic() || self.is_numeric()
-    }
-
-    #[inline]
-    fn is_control(self) -> bool { general_category::Cc(self) }
-
-    #[inline]
-    fn is_numeric(self) -> bool {
-        match self {
-            '0' ... '9' => true,
-            c if c > '\x7f' => general_category::N(c),
-            _ => false
-        }
-    }
-
-    #[inline]
-    fn to_lowercase(self) -> ToLowercase {
-        ToLowercase(Some(conversions::to_lower(self)))
-    }
-
-    #[inline]
-    fn to_uppercase(self) -> ToUppercase {
-        ToUppercase(Some(conversions::to_upper(self)))
-    }
-
-    #[inline]
-    fn width(self, is_cjk: bool) -> Option<usize> { charwidth::width(self, is_cjk) }
-}
-
 /// An iterator over the lowercase mapping of a given character, returned from
 /// the [`to_lowercase` method](../primitive.char.html#method.to_lowercase) on
 /// characters.
index 141ddba7db620dd02d763e4b73bbad6b1b7bea10..8b05f7c895527887e68a2a8169c6d44e14110214 100644 (file)
@@ -1,3 +1,13 @@
+S 2015-03-25 a923278
+  bitrig-x86_64 41de2c7a69a1ac648d3fa3b65e96a29bdc122163
+  freebsd-x86_64 cd02c86a9218da73b2a45aff293787010d33bf3e
+  linux-i386 da50141558eed6dabab97b79b2c6a7de4f2d2c5e
+  linux-x86_64 bca03458d28d07506bad4b80e5770b2117286244
+  macos-i386 522d59b23dd885a45e2c5b33e80e76240bb2d9af
+  macos-x86_64 82df09d51d73d119a2f4e4d8041879615cb22081
+  winnt-i386 5056e8def5ab4f4283b8f3aab160cc10231bb28d
+  winnt-x86_64 3f6b35ac12625b4b4b42dfd5eee5f6cbf122794e
+
 S 2015-03-17 c64d671
   bitrig-x86_64 41de2c7a69a1ac648d3fa3b65e96a29bdc122163
   freebsd-x86_64 14ced24e1339a4dd8baa9db69995daa52a948d54
index 76fd619f689648adba8e8cc2c444c3e50c8f3099..8670cd96fc6de7f406f85439d8532b21a9464089 100644 (file)
@@ -11,6 +11,7 @@
 #![crate_name="struct_variant_xc_aux"]
 #![crate_type = "lib"]
 
+#[derive(Copy)]
 pub enum Enum {
     Variant(u8),
     StructVariant { arg: u8 }
index 55a6e2ac7b8d6755f8bd2bcac6da1e07105a5d8e..b726c46d5d533c8681b8a4ad65bf94a9057f921a 100644 (file)
@@ -18,19 +18,6 @@ struct Foo {
     y: isize,
 }
 
-#[cfg(stage0)]
-impl Index<String> for Foo {
-    type Output = isize;
-
-    fn index<'a>(&'a self, z: &String) -> &'a isize {
-        if *z == "x" {
-            &self.x
-        } else {
-            &self.y
-        }
-    }
-}
-
 impl<'a> Index<&'a String> for Foo {
     type Output = isize;
 
diff --git a/src/test/compile-fail/derive-assoc-type-not-impl.rs b/src/test/compile-fail/derive-assoc-type-not-impl.rs
new file mode 100644 (file)
index 0000000..3799f2f
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+trait Foo {
+    type X;
+    fn method(&self) {}
+}
+
+#[derive(Clone)]
+struct Bar<T: Foo> {
+    x: T::X,
+}
+
+struct NotClone;
+
+impl Foo for NotClone {
+    type X = i8;
+}
+
+fn main() {
+    Bar::<NotClone> { x: 1 }.clone(); //~ ERROR
+}
diff --git a/src/test/run-pass/deriving-associated-types.rs b/src/test/run-pass/deriving-associated-types.rs
new file mode 100644 (file)
index 0000000..59eb550
--- /dev/null
@@ -0,0 +1,210 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(core, debug_builders)]
+
+pub trait DeclaredTrait {
+    type Type;
+}
+
+impl DeclaredTrait for i32 {
+    type Type = i32;
+}
+
+pub trait WhereTrait {
+    type Type;
+}
+
+impl WhereTrait for i32 {
+    type Type = i32;
+}
+
+// Make sure we don't add a bound that just shares a name with an associated
+// type.
+pub mod module {
+    pub type Type = i32;
+}
+
+#[derive(PartialEq, Debug)]
+struct PrivateStruct<T>(T);
+
+#[derive(PartialEq, Debug)]
+struct TupleStruct<A, B: DeclaredTrait, C>(
+    module::Type,
+    Option<module::Type>,
+    A,
+    PrivateStruct<A>,
+    B,
+    B::Type,
+    Option<B::Type>,
+    <B as DeclaredTrait>::Type,
+    Option<<B as DeclaredTrait>::Type>,
+    C,
+    C::Type,
+    Option<C::Type>,
+    <C as WhereTrait>::Type,
+    Option<<C as WhereTrait>::Type>,
+    <i32 as DeclaredTrait>::Type,
+) where C: WhereTrait;
+
+#[derive(PartialEq, Debug)]
+pub struct Struct<A, B: DeclaredTrait, C> where C: WhereTrait {
+    m1: module::Type,
+    m2: Option<module::Type>,
+    a1: A,
+    a2: PrivateStruct<A>,
+    b: B,
+    b1: B::Type,
+    b2: Option<B::Type>,
+    b3: <B as DeclaredTrait>::Type,
+    b4: Option<<B as DeclaredTrait>::Type>,
+    c: C,
+    c1: C::Type,
+    c2: Option<C::Type>,
+    c3: <C as WhereTrait>::Type,
+    c4: Option<<C as WhereTrait>::Type>,
+    d: <i32 as DeclaredTrait>::Type,
+}
+
+#[derive(PartialEq, Debug)]
+enum Enum<A, B: DeclaredTrait, C> where C: WhereTrait {
+    Unit,
+    Seq(
+        module::Type,
+        Option<module::Type>,
+        A,
+        PrivateStruct<A>,
+        B,
+        B::Type,
+        Option<B::Type>,
+        <B as DeclaredTrait>::Type,
+        Option<<B as DeclaredTrait>::Type>,
+        C,
+        C::Type,
+        Option<C::Type>,
+        <C as WhereTrait>::Type,
+        Option<<C as WhereTrait>::Type>,
+        <i32 as DeclaredTrait>::Type,
+    ),
+    Map {
+        m1: module::Type,
+        m2: Option<module::Type>,
+        a1: A,
+        a2: PrivateStruct<A>,
+        b: B,
+        b1: B::Type,
+        b2: Option<B::Type>,
+        b3: <B as DeclaredTrait>::Type,
+        b4: Option<<B as DeclaredTrait>::Type>,
+        c: C,
+        c1: C::Type,
+        c2: Option<C::Type>,
+        c3: <C as WhereTrait>::Type,
+        c4: Option<<C as WhereTrait>::Type>,
+        d: <i32 as DeclaredTrait>::Type,
+    },
+}
+
+fn main() {
+    let e: TupleStruct<
+        i32,
+        i32,
+        i32,
+    > = TupleStruct(
+        0,
+        None,
+        0,
+        PrivateStruct(0),
+        0,
+        0,
+        None,
+        0,
+        None,
+        0,
+        0,
+        None,
+        0,
+        None,
+        0,
+    );
+    assert_eq!(e, e);
+
+    let e: Struct<
+        i32,
+        i32,
+        i32,
+    > = Struct {
+        m1: 0,
+        m2: None,
+        a1: 0,
+        a2: PrivateStruct(0),
+        b: 0,
+        b1: 0,
+        b2: None,
+        b3: 0,
+        b4: None,
+        c: 0,
+        c1: 0,
+        c2: None,
+        c3: 0,
+        c4: None,
+        d: 0,
+    };
+    assert_eq!(e, e);
+
+    let e = Enum::Unit::<i32, i32, i32>;
+    assert_eq!(e, e);
+
+    let e: Enum<
+        i32,
+        i32,
+        i32,
+    > = Enum::Seq(
+        0,
+        None,
+        0,
+        PrivateStruct(0),
+        0,
+        0,
+        None,
+        0,
+        None,
+        0,
+        0,
+        None,
+        0,
+        None,
+        0,
+    );
+    assert_eq!(e, e);
+
+    let e: Enum<
+        i32,
+        i32,
+        i32,
+    > = Enum::Map {
+        m1: 0,
+        m2: None,
+        a1: 0,
+        a2: PrivateStruct(0),
+        b: 0,
+        b1: 0,
+        b2: None,
+        b3: 0,
+        b4: None,
+        c: 0,
+        c1: 0,
+        c2: None,
+        c3: 0,
+        c4: None,
+        d: 0,
+    };
+    assert_eq!(e, e);
+}