]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #23811 - alexcrichton:libc-stable, r=Manishearth
authorManish Goregaokar <manishsmail@gmail.com>
Sun, 29 Mar 2015 12:52:15 +0000 (18:22 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Sun, 29 Mar 2015 12:52:15 +0000 (18:22 +0530)
Right now the `std::isize::BYTES` typedef is `#[unstable]`, but liblibc is using
this, preventing it from compiling on stable Rust.

51 files changed:
src/doc/trpl/SUMMARY.md
src/doc/trpl/standard-input.md [deleted file]
src/libcollections/btree/map.rs
src/libcollections/btree/set.rs
src/libcollections/lib.rs
src/libcollections/linked_list.rs
src/libcollections/slice.rs
src/libcollections/str.rs
src/libcollections/vec_deque.rs
src/libcollectionstest/bench.rs
src/libcore/fmt/builders.rs
src/libcore/fmt/float.rs
src/libcore/fmt/mod.rs
src/libcore/fmt/num.rs
src/libcore/iter.rs
src/libcore/num/mod.rs
src/libcore/option.rs
src/libcore/prelude.rs
src/libcore/result.rs
src/libcore/str/mod.rs
src/libcoretest/fmt/builders.rs
src/librustc_typeck/check/wf.rs
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/set.rs
src/libstd/collections/hash/table.rs
src/libstd/dynamic_lib.rs
src/libstd/ffi/c_str.rs
src/libstd/io/mod.rs
src/libstd/lib.rs
src/libstd/old_io/buffered.rs
src/libstd/old_io/mem.rs
src/libstd/old_io/mod.rs
src/libstd/old_io/net/addrinfo.rs
src/libstd/old_io/net/ip.rs
src/libstd/old_io/tempfile.rs
src/libstd/old_path/mod.rs
src/libstd/old_path/posix.rs
src/libstd/old_path/windows.rs
src/libstd/os.rs
src/libstd/prelude/v1.rs
src/libstd/rand/mod.rs
src/libstd/sys/unix/backtrace.rs
src/libstd/sys/unix/os.rs
src/libstd/sys/windows/process2.rs
src/libsyntax/feature_gate.rs
src/test/compile-fail/gated-unsafe-destructor.rs
src/test/compile-fail/issue-13853-3.rs [deleted file]
src/test/compile-fail/issue-13853-4.rs [deleted file]
src/test/compile-fail/issue-16465.rs [deleted file]
src/test/compile-fail/kindck-destructor-owned.rs [deleted file]
src/test/compile-fail/unsafe-destructor-check-crash.rs [deleted file]

index 140086e32d080e6f819d43326782a7244c56fe83..d31348d667b57e56e996ca86e2e64e4505f8fdde 100644 (file)
@@ -13,7 +13,6 @@
     * [Looping](looping.md)
     * [Strings](strings.md)
     * [Arrays, Vectors, and Slices](arrays-vectors-and-slices.md)
-    * [Standard Input](standard-input.md)
 * [Intermediate Rust](intermediate.md)
     * [Crates and Modules](crates-and-modules.md)
     * [Testing](testing.md)
diff --git a/src/doc/trpl/standard-input.md b/src/doc/trpl/standard-input.md
deleted file mode 100644 (file)
index 38af0c9..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-% Standard Input
-
-Getting input from the keyboard is pretty easy, but uses some things
-we haven't seen before. Here's a simple program that reads some input,
-and then prints it back out:
-
-```{rust,ignore}
-# #![feature(old_io)]
-fn main() {
-    println!("Type something!");
-
-    let input = std::old_io::stdin().read_line().ok().expect("Failed to read line");
-
-    println!("{}", input);
-}
-```
-
-Let's go over these chunks, one by one:
-
-```{rust,ignore}
-std::old_io::stdin();
-```
-
-This calls a function, `stdin()`, that lives inside the `std::old_io` module. As
-you can imagine, everything in `std` is provided by Rust, the 'standard
-library.' We'll talk more about the module system later.
-
-Since writing the fully qualified name all the time is annoying, we can use
-the `use` statement to import it in:
-
-```{rust}
-# #![feature(old_io)]
-use std::old_io::stdin;
-
-stdin();
-```
-
-However, it's considered better practice to not import individual functions, but
-to import the module, and only use one level of qualification:
-
-```{rust}
-# #![feature(old_io)]
-use std::old_io;
-
-old_io::stdin();
-```
-
-Let's update our example to use this style:
-
-```{rust,ignore}
-use std::old_io;
-
-fn main() {
-    println!("Type something!");
-
-    let input = old_io::stdin().read_line().ok().expect("Failed to read line");
-
-    println!("{}", input);
-}
-```
-
-Next up:
-
-```{rust,ignore}
-.read_line()
-```
-
-The `read_line()` method can be called on the result of `stdin()` to return
-a full line of input. Nice and easy.
-
-```{rust,ignore}
-.ok().expect("Failed to read line");
-```
-
-Do you remember this code?
-
-```{rust}
-enum OptionalInt {
-    Value(i32),
-    Missing,
-}
-
-fn main() {
-    let x = OptionalInt::Value(5);
-    let y = OptionalInt::Missing;
-
-    match x {
-        OptionalInt::Value(n) => println!("x is {}", n),
-        OptionalInt::Missing => println!("x is missing!"),
-    }
-
-    match y {
-        OptionalInt::Value(n) => println!("y is {}", n),
-        OptionalInt::Missing => println!("y is missing!"),
-    }
-}
-```
-
-We had to match each time to see if we had a value or not. In this case,
-though, we _know_ that `x` has a `Value`, but `match` forces us to handle
-the `missing` case. This is what we want 99% of the time, but sometimes, we
-know better than the compiler.
-
-Likewise, `read_line()` does not return a line of input. It _might_ return a
-line of input, though it might also fail to do so. This could happen if our program
-isn't running in a terminal, but as part of a cron job, or some other context
-where there's no standard input. Because of this, `read_line` returns a type
-very similar to our `OptionalInt`: an `IoResult<T>`. We haven't talked about
-`IoResult<T>` yet because it is the *generic* form of our `OptionalInt`.
-Until then, you can think of it as being the same thing, just for any type –
-not just `i32`s.
-
-Rust provides a method on these `IoResult<T>`s called `ok()`, which does the
-same thing as our `match` statement but assumes that we have a valid value.
-We then call `expect()` on the result, which will terminate our program if we
-don't have a valid value. In this case, if we can't get input, our program
-doesn't work, so we're okay with that. In most cases, we would want to handle
-the error case explicitly. `expect()` allows us to give an error message if
-this crash happens.
-
-We will cover the exact details of how all of this works later in the Guide in
-[Error Handling]. For now, this gives you enough of a basic understanding to
-work with.
-
-Back to the code we were working on! Here's a refresher:
-
-```{rust,ignore}
-use std::old_io;
-
-fn main() {
-    println!("Type something!");
-
-    let input = old_io::stdin().read_line().ok().expect("Failed to read line");
-
-    println!("{}", input);
-}
-```
-
-With long lines like this, Rust gives you some flexibility with the whitespace.
-We _could_ write the example like this:
-
-```{rust,ignore}
-use std::old_io;
-
-fn main() {
-    println!("Type something!");
-
-    // here, we'll show the types at each step
-
-    let input = old_io::stdin() // std::old_io::stdio::StdinReader
-                  .read_line() // IoResult<String>
-                  .ok() // Option<String>
-                  .expect("Failed to read line"); // String
-
-    println!("{}", input);
-}
-```
-
-Sometimes, this makes things more readable – sometimes, less. Use your judgement
-here.
-
-That's all you need to get basic input from the standard input! It's not too
-complicated, but there are a number of small parts.
-
-
-[Error Handling]: ./error-handling.html
index d2b45f4b0492bf74c160ace5671a3bb2a24be2eb..e1d007f0ac49739e21a33f60929e5fa0b7f5b19a 100644 (file)
@@ -904,14 +904,7 @@ fn cmp(&self, other: &BTreeMap<K, V>) -> Ordering {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<K: Debug, V: Debug> Debug for BTreeMap<K, V> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
-
-        for (i, (k, v)) in self.iter().enumerate() {
-            if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{:?}: {:?}", *k, *v));
-        }
-
-        write!(f, "}}")
+        self.iter().fold(f.debug_map(), |b, (k, v)| b.entry(k, v)).finish()
     }
 }
 
index 08ee5801482fdb44e81a4531142527c987315401..840110b5b276fffc7822d69d345db5e7ed9894d9 100644 (file)
@@ -628,14 +628,7 @@ fn bitor(self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Debug> Debug for BTreeSet<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
-
-        for (i, x) in self.iter().enumerate() {
-            if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{:?}", *x));
-        }
-
-        write!(f, "}}")
+        self.iter().fold(f.debug_set(), |b, e| b.entry(e)).finish()
     }
 }
 
index f774c1505b82ba8a4f2818517bcb446c95852f45..c769b3df37f627548150961962c00aa8500c6c39 100644 (file)
@@ -40,6 +40,7 @@
 #![feature(str_char)]
 #![feature(convert)]
 #![feature(slice_patterns)]
+#![feature(debug_builders)]
 #![cfg_attr(test, feature(rand, rustc_private, test, hash, collections))]
 #![cfg_attr(test, allow(deprecated))] // rand
 
index 908c78a17f4f96ef2743f5b9a52dc3e56a5d4952..52da4902b758cf1c31721072a8c6636ed2ed6a70 100644 (file)
@@ -927,14 +927,7 @@ fn clone(&self) -> LinkedList<A> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<A: fmt::Debug> fmt::Debug for LinkedList<A> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "["));
-
-        for (i, e) in self.iter().enumerate() {
-            if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{:?}", *e));
-        }
-
-        write!(f, "]")
+        self.iter().fold(f.debug_list(), |b, e| b.entry(e)).finish()
     }
 }
 
@@ -951,7 +944,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
 #[cfg(test)]
 mod test {
     use std::clone::Clone;
-    use std::iter::{Iterator, IteratorExt};
+    use std::iter::Iterator;
     use std::option::Option::{Some, None, self};
     use std::rand;
     use std::thread;
index 83e632e6c9676fef00036319fc5cd7c652c16e0a..ba1ab75de803a432e33e9775d98abcc77a26216a 100644 (file)
@@ -76,7 +76,6 @@
 //!   iterators.
 //! * Further methods that return iterators are `.split()`, `.splitn()`,
 //!   `.chunks()`, `.windows()` and more.
-
 #![doc(primitive = "slice")]
 #![stable(feature = "rust1", since = "1.0.0")]
 
@@ -85,7 +84,7 @@
 use core::clone::Clone;
 use core::cmp::Ordering::{self, Greater, Less};
 use core::cmp::{self, Ord, PartialEq};
-use core::iter::{Iterator, IteratorExt};
+use core::iter::Iterator;
 use core::iter::MultiplicativeIterator;
 use core::marker::Sized;
 use core::mem::size_of;
@@ -131,7 +130,7 @@ mod hack {
     use alloc::boxed::Box;
     use core::clone::Clone;
     #[cfg(test)]
-    use core::iter::{Iterator, IteratorExt};
+    use core::iter::Iterator;
     use core::mem;
     #[cfg(test)]
     use core::option::Option::{Some, None};
index aaa73badcac99a1b0c21bf7794b803a82317549f..0665abc9e9585fb12db8cb4c913cddddf777a5e0 100644 (file)
@@ -58,7 +58,7 @@
 
 use core::clone::Clone;
 use core::iter::AdditiveIterator;
-use core::iter::{Iterator, IteratorExt, Extend};
+use core::iter::{Iterator, Extend};
 use core::option::Option::{self, Some, None};
 use core::result::Result;
 use core::str as core_str;
index 944908e7b4e3dc69cf2bf6638333a787047e630a..8f3f4e6b890e0d75a602394c8b54aa2d55895a27 100644 (file)
@@ -1785,7 +1785,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 #[cfg(test)]
 mod test {
-    use core::iter::{IteratorExt, self};
+    use core::iter::{Iterator, self};
     use core::option::Option::Some;
 
     use test;
index 2396a577589f2ee94f7a847372b68c4263bc3fd3..e883b07dc5a48fde17e02877d35858e79071c8ec 100644 (file)
@@ -66,7 +66,7 @@ macro_rules! map_find_rand_bench {
     ($name: ident, $n: expr, $map: ident) => (
         #[bench]
         pub fn $name(b: &mut ::test::Bencher) {
-            use std::iter::IteratorExt;
+            use std::iter::Iterator;
             use std::rand::Rng;
             use std::rand;
             use std::vec::Vec;
index 07f029cc15e2f219172350e7a6c15484f32271df..f61a7f2d30c62cd418b949bd0b301b2ee13a06d3 100644 (file)
@@ -177,22 +177,54 @@ fn is_pretty(&self) -> bool {
     }
 }
 
+struct DebugInner<'a, 'b: 'a> {
+    fmt: &'a mut fmt::Formatter<'b>,
+    result: fmt::Result,
+    has_fields: bool,
+}
+
+impl<'a, 'b: 'a> DebugInner<'a, 'b> {
+    fn entry(&mut self, entry: &fmt::Debug) {
+        self.result = self.result.and_then(|_| {
+            if self.is_pretty() {
+                let mut writer = PadAdapter::new(self.fmt);
+                let prefix = if self.has_fields { "," } else { "" };
+                fmt::write(&mut writer, format_args!("{}\n{:#?}", prefix, entry))
+            } else {
+                let prefix = if self.has_fields { ", " } else { "" };
+                write!(self.fmt, "{}{:?}", prefix, entry)
+            }
+        });
+
+        self.has_fields = true;
+    }
+
+    pub fn finish(&mut self) {
+        let prefix = if self.is_pretty() && self.has_fields { "\n" } else { "" };
+        self.result = self.result.and_then(|_| self.fmt.write_str(prefix));
+    }
+
+    fn is_pretty(&self) -> bool {
+        self.fmt.flags() & (1 << (FlagV1::Alternate as usize)) != 0
+    }
+}
+
 /// A struct to help with `fmt::Debug` implementations.
 ///
 /// Constructed by the `Formatter::debug_set` method.
 #[must_use]
 pub struct DebugSet<'a, 'b: 'a> {
-    fmt: &'a mut fmt::Formatter<'b>,
-    result: fmt::Result,
-    has_fields: bool,
+    inner: DebugInner<'a, 'b>,
 }
 
-pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> DebugSet<'a, 'b> {
-    let result = write!(fmt, "{} {{", name);
+pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b> {
+    let result = write!(fmt, "{{");
     DebugSet {
-        fmt: fmt,
-        result: result,
-        has_fields: false,
+        inner: DebugInner {
+            fmt: fmt,
+            result: result,
+            has_fields: false,
+        }
     }
 }
 
@@ -200,41 +232,52 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
     /// Adds a new entry to the set output.
     #[unstable(feature = "debug_builders", reason = "method was just created")]
     pub fn entry(mut self, entry: &fmt::Debug) -> DebugSet<'a, 'b> {
-        self.result = self.result.and_then(|_| {
-            let prefix = if self.has_fields {
-                ","
-            } else {
-                ""
-            };
-
-            if self.is_pretty() {
-                let mut writer = PadAdapter::new(self.fmt);
-                fmt::write(&mut writer, format_args!("{}\n{:#?}", prefix, entry))
-            } else {
-                write!(self.fmt, "{} {:?}", prefix, entry)
-            }
-        });
-
-        self.has_fields = true;
+        self.inner.entry(entry);
         self
     }
 
     /// Consumes the `DebugSet`, finishing output and returning any error
     /// encountered.
     #[unstable(feature = "debug_builders", reason = "method was just created")]
-    pub fn finish(self) -> fmt::Result {
-        self.result.and_then(|_| {
-            let end = match (self.has_fields, self.is_pretty()) {
-                (false, _) => "}",
-                (true, false) => " }",
-                (true, true) => "\n}",
-            };
-            self.fmt.write_str(end)
-        })
+    pub fn finish(mut self) -> fmt::Result {
+        self.inner.finish();
+        self.inner.result.and_then(|_| self.inner.fmt.write_str("}"))
     }
+}
 
-    fn is_pretty(&self) -> bool {
-        self.fmt.flags() & (1 << (FlagV1::Alternate as usize)) != 0
+/// A struct to help with `fmt::Debug` implementations.
+///
+/// Constructed by the `Formatter::debug_list` method.
+#[must_use]
+pub struct DebugList<'a, 'b: 'a> {
+    inner: DebugInner<'a, 'b>,
+}
+
+pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a, 'b> {
+    let result = write!(fmt, "[");
+    DebugList {
+        inner: DebugInner {
+            fmt: fmt,
+            result: result,
+            has_fields: false,
+        }
+    }
+}
+
+impl<'a, 'b: 'a> DebugList<'a, 'b> {
+    /// Adds a new entry to the set output.
+    #[unstable(feature = "debug_builders", reason = "method was just created")]
+    pub fn entry(mut self, entry: &fmt::Debug) -> DebugList<'a, 'b> {
+        self.inner.entry(entry);
+        self
+    }
+
+    /// Consumes the `DebugSet`, finishing output and returning any error
+    /// encountered.
+    #[unstable(feature = "debug_builders", reason = "method was just created")]
+    pub fn finish(mut self) -> fmt::Result {
+        self.inner.finish();
+        self.inner.result.and_then(|_| self.inner.fmt.write_str("]"))
     }
 }
 
@@ -248,8 +291,8 @@ pub struct DebugMap<'a, 'b: 'a> {
     has_fields: bool,
 }
 
-pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> DebugMap<'a, 'b> {
-    let result = write!(fmt, "{} {{", name);
+pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b> {
+    let result = write!(fmt, "{{");
     DebugMap {
         fmt: fmt,
         result: result,
@@ -262,22 +305,17 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
     #[unstable(feature = "debug_builders", reason = "method was just created")]
     pub fn entry(mut self, key: &fmt::Debug, value: &fmt::Debug) -> DebugMap<'a, 'b> {
         self.result = self.result.and_then(|_| {
-            let prefix = if self.has_fields {
-                ","
-            } else {
-                ""
-            };
-
             if self.is_pretty() {
                 let mut writer = PadAdapter::new(self.fmt);
+                let prefix = if self.has_fields { "," } else { "" };
                 fmt::write(&mut writer, format_args!("{}\n{:#?}: {:#?}", prefix, key, value))
             } else {
-                write!(self.fmt, "{} {:?}: {:?}", prefix, key, value)
+                let prefix = if self.has_fields { ", " } else { "" };
+                write!(self.fmt, "{}{:?}: {:?}", prefix, key, value)
             }
         });
 
         self.has_fields = true;
-
         self
     }
 
@@ -285,14 +323,8 @@ pub fn entry(mut self, key: &fmt::Debug, value: &fmt::Debug) -> DebugMap<'a, 'b>
     /// encountered.
     #[unstable(feature = "debug_builders", reason = "method was just created")]
     pub fn finish(self) -> fmt::Result {
-        self.result.and_then(|_| {
-            let end = match (self.has_fields, self.is_pretty()) {
-                (false, _) => "}",
-                (true, false) => " }",
-                (true, true) => "\n}",
-            };
-            self.fmt.write_str(end)
-        })
+        let prefix = if self.is_pretty() && self.has_fields { "\n" } else { "" };
+        self.result.and_then(|_| write!(self.fmt, "{}}}", prefix))
     }
 
     fn is_pretty(&self) -> bool {
index ee2951602c71e39ad6cce9a36c7cc844ce214143..6e82b18abc6aedc9533b7c8453262c68291c4bce 100644 (file)
@@ -17,7 +17,7 @@
 use char;
 use char::CharExt;
 use fmt;
-use iter::IteratorExt;
+use iter::Iterator;
 use num::{cast, Float, ToPrimitive};
 use num::FpCategory as Fp;
 use ops::FnOnce;
index aa0d0a1539a30e045ba424a52b1f4861da689629..ffb358cdac84d90854623e1dc969473269edeb09 100644 (file)
@@ -15,7 +15,7 @@
 use any;
 use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
 use char::CharExt;
-use iter::{Iterator, IteratorExt};
+use iter::Iterator;
 use marker::{Copy, PhantomData, Sized};
 use mem;
 use option::Option;
@@ -32,7 +32,7 @@
 pub use self::num::Radix;
 pub use self::num::RadixFmt;
 
-pub use self::builders::{DebugStruct, DebugTuple, DebugSet, DebugMap};
+pub use self::builders::{DebugStruct, DebugTuple, DebugSet, DebugList, DebugMap};
 
 mod num;
 mod float;
@@ -644,7 +644,7 @@ pub fn precision(&self) -> Option<usize> { self.precision }
     /// // prints "Foo { bar: 10, baz: "Hello World" }"
     /// println!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() });
     /// ```
-    #[unstable(feature = "core", reason = "method was just created")]
+    #[unstable(feature = "debug_builders", reason = "method was just created")]
     #[inline]
     pub fn debug_struct<'b>(&'b mut self, name: &str) -> DebugStruct<'b, 'a> {
         builders::debug_struct_new(self, name)
@@ -673,12 +673,38 @@ pub fn debug_struct<'b>(&'b mut self, name: &str) -> DebugStruct<'b, 'a> {
     /// // prints "Foo(10, "Hello World")"
     /// println!("{:?}", Foo(10, "Hello World".to_string()));
     /// ```
-    #[unstable(feature = "core", reason = "method was just created")]
+    #[unstable(feature = "debug_builders", reason = "method was just created")]
     #[inline]
     pub fn debug_tuple<'b>(&'b mut self, name: &str) -> DebugTuple<'b, 'a> {
         builders::debug_tuple_new(self, name)
     }
 
+    /// Creates a `DebugList` builder designed to assist with creation of
+    /// `fmt::Debug` implementations for list-like structures.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// # #![feature(debug_builders, core)]
+    /// use std::fmt;
+    ///
+    /// struct Foo(Vec<i32>);
+    ///
+    /// impl fmt::Debug for Foo {
+    ///     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    ///         self.0.iter().fold(fmt.debug_list(), |b, e| b.entry(e)).finish()
+    ///     }
+    /// }
+    ///
+    /// // prints "[10, 11]"
+    /// println!("{:?}", Foo(vec![10, 11]));
+    /// ```
+    #[unstable(feature = "debug_builders", reason = "method was just created")]
+    #[inline]
+    pub fn debug_list<'b>(&'b mut self) -> DebugList<'b, 'a> {
+        builders::debug_list_new(self)
+    }
+
     /// Creates a `DebugSet` builder designed to assist with creation of
     /// `fmt::Debug` implementations for set-like structures.
     ///
@@ -692,21 +718,17 @@ pub fn debug_tuple<'b>(&'b mut self, name: &str) -> DebugTuple<'b, 'a> {
     ///
     /// impl fmt::Debug for Foo {
     ///     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-    ///         let mut builder = fmt.debug_set("Foo");
-    ///         for i in &self.0 {
-    ///             builder = builder.entry(i);
-    ///         }
-    ///         builder.finish()
+    ///         self.0.iter().fold(fmt.debug_set(), |b, e| b.entry(e)).finish()
     ///     }
     /// }
     ///
-    /// // prints "Foo { 10, 11 }"
+    /// // prints "{10, 11}"
     /// println!("{:?}", Foo(vec![10, 11]));
     /// ```
-    #[unstable(feature = "core", reason = "method was just created")]
+    #[unstable(feature = "debug_builders", reason = "method was just created")]
     #[inline]
-    pub fn debug_set<'b>(&'b mut self, name: &str) -> DebugSet<'b, 'a> {
-        builders::debug_set_new(self, name)
+    pub fn debug_set<'b>(&'b mut self) -> DebugSet<'b, 'a> {
+        builders::debug_set_new(self)
     }
 
     /// Creates a `DebugMap` builder designed to assist with creation of
@@ -722,21 +744,17 @@ pub fn debug_set<'b>(&'b mut self, name: &str) -> DebugSet<'b, 'a> {
     ///
     /// impl fmt::Debug for Foo {
     ///     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-    ///         let mut builder = fmt.debug_map("Foo");
-    ///         for &(ref key, ref value) in &self.0 {
-    ///             builder = builder.entry(key, value);
-    ///         }
-    ///         builder.finish()
+    ///         self.0.iter().fold(fmt.debug_map(), |b, &(ref k, ref v)| b.entry(k, v)).finish()
     ///     }
     /// }
     ///
-    /// // prints "Foo { "A": 10, "B": 11 }"
+    /// // prints "{"A": 10, "B": 11}"
     /// println!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)]));
     /// ```
-    #[unstable(feature = "core", reason = "method was just created")]
+    #[unstable(feature = "debug_builders", reason = "method was just created")]
     #[inline]
-    pub fn debug_map<'b>(&'b mut self, name: &str) -> DebugMap<'b, 'a> {
-        builders::debug_map_new(self, name)
+    pub fn debug_map<'b>(&'b mut self) -> DebugMap<'b, 'a> {
+        builders::debug_map_new(self)
     }
 }
 
@@ -987,22 +1005,7 @@ fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Debug> Debug for [T] {
     fn fmt(&self, f: &mut Formatter) -> Result {
-        if f.flags & (1 << (FlagV1::Alternate as u32)) == 0 {
-            try!(write!(f, "["));
-        }
-        let mut is_first = true;
-        for x in self {
-            if is_first {
-                is_first = false;
-            } else {
-                try!(write!(f, ", "));
-            }
-            try!(write!(f, "{:?}", *x))
-        }
-        if f.flags & (1 << (FlagV1::Alternate as u32)) == 0 {
-            try!(write!(f, "]"));
-        }
-        Ok(())
+        self.iter().fold(f.debug_list(), |b, e| b.entry(e)).finish()
     }
 }
 
index 49da99b97cb206571b768a1e88e94b6ae86a6d1e..974252a92af22296479dfa57fcc9265153c14b7c 100644 (file)
@@ -15,7 +15,7 @@
 #![allow(unsigned_negation)]
 
 use fmt;
-use iter::IteratorExt;
+use iter::Iterator;
 use num::{Int, cast};
 use slice::SliceExt;
 use str;
index da89dda3af191085a7c82c05e68a2ca976f69adc..bb057c553db05af4726e6a062c4e0a4caeca30e1 100644 (file)
@@ -71,6 +71,8 @@
 use marker::Sized;
 use usize;
 
+fn _assert_is_object_safe(_: &Iterator) {}
+
 /// An interface for dealing with "external iterators". These types of iterators
 /// can be resumed at any time as all state is stored internally as opposed to
 /// being located on the call stack.
@@ -101,62 +103,7 @@ pub trait Iterator {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn size_hint(&self) -> (usize, Option<usize>) { (0, None) }
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I {
-    type Item = I::Item;
-    fn next(&mut self) -> Option<I::Item> { (**self).next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() }
-}
-
-/// Conversion from an `Iterator`
-#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \
-                          built from an iterator over elements of type `{A}`"]
-pub trait FromIterator<A> {
-    /// Build a container with elements from something iterable.
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn from_iter<T: IntoIterator<Item=A>>(iterator: T) -> Self;
-}
-
-/// Conversion into an `Iterator`
-#[stable(feature = "rust1", since = "1.0.0")]
-pub trait IntoIterator {
-    /// The type of the elements being iterated
-    #[stable(feature = "rust1", since = "1.0.0")]
-    type Item;
-
-    /// A container for iterating over elements of type Item
-    #[stable(feature = "rust1", since = "1.0.0")]
-    type IntoIter: Iterator<Item=Self::Item>;
-
-    /// Consumes `Self` and returns an iterator over it
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn into_iter(self) -> Self::IntoIter;
-}
 
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<I: Iterator> IntoIterator for I {
-    type Item = I::Item;
-    type IntoIter = I;
-
-    fn into_iter(self) -> I {
-        self
-    }
-}
-
-/// A type growable from an `Iterator` implementation
-#[stable(feature = "rust1", since = "1.0.0")]
-pub trait Extend<A> {
-    /// Extend a container with the elements yielded by an arbitrary iterator
-    #[stable(feature = "rust1", since = "1.0.0")]
-    fn extend<T: IntoIterator<Item=A>>(&mut self, iterable: T);
-}
-
-/// An extension trait providing numerous methods applicable to all iterators.
-#[stable(feature = "rust1", since = "1.0.0")]
-pub trait IteratorExt: Iterator + Sized {
     /// Counts the number of elements in this iterator.
     ///
     /// # Examples
@@ -167,7 +114,7 @@ pub trait IteratorExt: Iterator + Sized {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn count(self) -> usize {
+    fn count(self) -> usize where Self: Sized {
         self.fold(0, |cnt, _x| cnt + 1)
     }
 
@@ -181,7 +128,7 @@ fn count(self) -> usize {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn last(self) -> Option<Self::Item> {
+    fn last(self) -> Option<Self::Item> where Self: Sized {
         let mut last = None;
         for x in self { last = Some(x); }
         last
@@ -200,7 +147,7 @@ fn last(self) -> Option<Self::Item> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn nth(&mut self, mut n: usize) -> Option<Self::Item> {
+    fn nth(&mut self, mut n: usize) -> Option<Self::Item> where Self: Sized {
         for x in self.by_ref() {
             if n == 0 { return Some(x) }
             n -= 1;
@@ -225,7 +172,7 @@ fn nth(&mut self, mut n: usize) -> Option<Self::Item> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn chain<U>(self, other: U) -> Chain<Self, U> where
-        U: Iterator<Item=Self::Item>,
+        Self: Sized, U: Iterator<Item=Self::Item>,
     {
         Chain{a: self, b: other, flag: false}
     }
@@ -260,7 +207,7 @@ fn chain<U>(self, other: U) -> Chain<Self, U> where
     /// both produce the same output.
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> {
+    fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> where Self: Sized {
         Zip{a: self, b: other}
     }
 
@@ -279,7 +226,7 @@ fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn map<B, F>(self, f: F) -> Map<Self, F> where
-        F: FnMut(Self::Item) -> B,
+        Self: Sized, F: FnMut(Self::Item) -> B,
     {
         Map{iter: self, f: f}
     }
@@ -299,7 +246,7 @@ fn map<B, F>(self, f: F) -> Map<Self, F> where
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn filter<P>(self, predicate: P) -> Filter<Self, P> where
-        P: FnMut(&Self::Item) -> bool,
+        Self: Sized, P: FnMut(&Self::Item) -> bool,
     {
         Filter{iter: self, predicate: predicate}
     }
@@ -319,7 +266,7 @@ fn filter<P>(self, predicate: P) -> Filter<Self, P> where
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
-        F: FnMut(Self::Item) -> Option<B>,
+        Self: Sized, F: FnMut(Self::Item) -> Option<B>,
     {
         FilterMap { iter: self, f: f }
     }
@@ -341,7 +288,7 @@ fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn enumerate(self) -> Enumerate<Self> {
+    fn enumerate(self) -> Enumerate<Self> where Self: Sized {
         Enumerate{iter: self, count: 0}
     }
 
@@ -365,7 +312,7 @@ fn enumerate(self) -> Enumerate<Self> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn peekable(self) -> Peekable<Self> {
+    fn peekable(self) -> Peekable<Self> where Self: Sized {
         Peekable{iter: self, peeked: None}
     }
 
@@ -386,7 +333,7 @@ fn peekable(self) -> Peekable<Self> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
-        P: FnMut(&Self::Item) -> bool,
+        Self: Sized, P: FnMut(&Self::Item) -> bool,
     {
         SkipWhile{iter: self, flag: false, predicate: predicate}
     }
@@ -407,7 +354,7 @@ fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
-        P: FnMut(&Self::Item) -> bool,
+        Self: Sized, P: FnMut(&Self::Item) -> bool,
     {
         TakeWhile{iter: self, flag: false, predicate: predicate}
     }
@@ -426,7 +373,7 @@ fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn skip(self, n: usize) -> Skip<Self> {
+    fn skip(self, n: usize) -> Skip<Self> where Self: Sized {
         Skip{iter: self, n: n}
     }
 
@@ -445,7 +392,7 @@ fn skip(self, n: usize) -> Skip<Self> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn take(self, n: usize) -> Take<Self> {
+    fn take(self, n: usize) -> Take<Self> where Self: Sized, {
         Take{iter: self, n: n}
     }
 
@@ -472,7 +419,7 @@ fn take(self, n: usize) -> Take<Self> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
-        where F: FnMut(&mut St, Self::Item) -> Option<B>,
+        where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,
     {
         Scan{iter: self, f: f, state: initial_state}
     }
@@ -495,7 +442,7 @@ fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
-        where U: Iterator, F: FnMut(Self::Item) -> U,
+        where Self: Sized, U: Iterator, F: FnMut(Self::Item) -> U,
     {
         FlatMap{iter: self, f: f, frontiter: None, backiter: None }
     }
@@ -529,7 +476,7 @@ fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn fuse(self) -> Fuse<Self> {
+    fn fuse(self) -> Fuse<Self> where Self: Sized {
         Fuse{iter: self, done: false}
     }
 
@@ -555,7 +502,7 @@ fn fuse(self) -> Fuse<Self> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn inspect<F>(self, f: F) -> Inspect<Self, F> where
-        F: FnMut(&Self::Item),
+        Self: Sized, F: FnMut(&Self::Item),
     {
         Inspect{iter: self, f: f}
     }
@@ -575,7 +522,7 @@ fn inspect<F>(self, f: F) -> Inspect<Self, F> where
     /// assert!(it.next() == Some(5));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn by_ref(&mut self) -> &mut Self { self }
+    fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
 
     /// Loops through the entire iterator, collecting all of the elements into
     /// a container implementing `FromIterator`.
@@ -590,7 +537,7 @@ fn by_ref(&mut self) -> &mut Self { self }
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn collect<B: FromIterator<Self::Item>>(self) -> B {
+    fn collect<B: FromIterator<Self::Item>>(self) -> B where Self: Sized {
         FromIterator::from_iter(self)
     }
 
@@ -609,6 +556,7 @@ fn collect<B: FromIterator<Self::Item>>(self) -> B {
     #[unstable(feature = "core",
                reason = "recently added as part of collections reform")]
     fn partition<B, F>(self, mut f: F) -> (B, B) where
+        Self: Sized,
         B: Default + Extend<Self::Item>,
         F: FnMut(&Self::Item) -> bool
     {
@@ -638,7 +586,7 @@ fn partition<B, F>(self, mut f: F) -> (B, B) where
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn fold<B, F>(self, init: B, mut f: F) -> B where
-        F: FnMut(B, Self::Item) -> B,
+        Self: Sized, F: FnMut(B, Self::Item) -> B,
     {
         let mut accum = init;
         for x in self {
@@ -658,7 +606,9 @@ fn fold<B, F>(self, init: B, mut f: F) -> B where
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn all<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
+    fn all<F>(&mut self, mut f: F) -> bool where
+        Self: Sized, F: FnMut(Self::Item) -> bool
+    {
         for x in self.by_ref() { if !f(x) { return false; } }
         true
     }
@@ -679,7 +629,10 @@ fn all<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
+    fn any<F>(&mut self, mut f: F) -> bool where
+        Self: Sized,
+        F: FnMut(Self::Item) -> bool
+    {
         for x in self.by_ref() { if f(x) { return true; } }
         false
     }
@@ -699,6 +652,7 @@ fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
+        Self: Sized,
         P: FnMut(&Self::Item) -> bool,
     {
         for x in self.by_ref() {
@@ -722,6 +676,7 @@ fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
+        Self: Sized,
         P: FnMut(Self::Item) -> bool,
     {
         let mut i = 0;
@@ -752,7 +707,7 @@ fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
     #[stable(feature = "rust1", since = "1.0.0")]
     fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
         P: FnMut(Self::Item) -> bool,
-        Self: ExactSizeIterator + DoubleEndedIterator
+        Self: Sized + ExactSizeIterator + DoubleEndedIterator
     {
         let mut i = self.len();
 
@@ -775,7 +730,7 @@ fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn max(self) -> Option<Self::Item> where Self::Item: Ord
+    fn max(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
     {
         self.fold(None, |max, x| {
             match max {
@@ -795,7 +750,7 @@ fn max(self) -> Option<Self::Item> where Self::Item: Ord
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn min(self) -> Option<Self::Item> where Self::Item: Ord
+    fn min(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
     {
         self.fold(None, |min, x| {
             match min {
@@ -837,7 +792,7 @@ fn min(self) -> Option<Self::Item> where Self::Item: Ord
     /// assert!(a.iter().min_max() == MinMax(&1, &1));
     /// ```
     #[unstable(feature = "core", reason = "return type may change")]
-    fn min_max(mut self) -> MinMaxResult<Self::Item> where Self::Item: Ord
+    fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord
     {
         let (mut min, mut max) = match self.next() {
             None => return NoElements,
@@ -897,6 +852,7 @@ fn min_max(mut self) -> MinMaxResult<Self::Item> where Self::Item: Ord
     #[unstable(feature = "core",
                reason = "may want to produce an Ordering directly; see #15311")]
     fn max_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
+        Self: Sized,
         F: FnMut(&Self::Item) -> B,
     {
         self.fold(None, |max: Option<(Self::Item, B)>, x| {
@@ -928,6 +884,7 @@ fn max_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
     #[unstable(feature = "core",
                reason = "may want to produce an Ordering directly; see #15311")]
     fn min_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
+        Self: Sized,
         F: FnMut(&Self::Item) -> B,
     {
         self.fold(None, |min: Option<(Self::Item, B)>, x| {
@@ -957,7 +914,7 @@ fn min_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
     /// `std::usize::MAX` elements of the original iterator.
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn rev(self) -> Rev<Self> {
+    fn rev(self) -> Rev<Self> where Self: Sized {
         Rev{iter: self}
     }
 
@@ -979,7 +936,7 @@ fn rev(self) -> Rev<Self> {
     fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
         FromA: Default + Extend<A>,
         FromB: Default + Extend<B>,
-        Self: Iterator<Item=(A, B)>,
+        Self: Sized + Iterator<Item=(A, B)>,
     {
         struct SizeHint<A>(usize, Option<usize>, marker::PhantomData<A>);
         impl<A> Iterator for SizeHint<A> {
@@ -1010,7 +967,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
     /// converting an Iterator<&T> to an Iterator<T>.
     #[stable(feature = "rust1", since = "1.0.0")]
     fn cloned<'a, T: 'a>(self) -> Cloned<Self>
-        where Self: Iterator<Item=&'a T>, T: Clone
+        where Self: Sized + Iterator<Item=&'a T>, T: Clone
     {
         Cloned { it: self }
     }
@@ -1028,7 +985,7 @@ fn cloned<'a, T: 'a>(self) -> Cloned<Self>
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
-    fn cycle(self) -> Cycle<Self> where Self: Clone {
+    fn cycle(self) -> Cycle<Self> where Self: Sized + Clone {
         Cycle{orig: self.clone(), iter: self}
     }
 
@@ -1036,7 +993,7 @@ fn cycle(self) -> Cycle<Self> where Self: Clone {
     #[unstable(feature = "core",
                reason = "uncertain about placement or widespread use")]
     fn reverse_in_place<'a, T: 'a>(&mut self) where
-        Self: Iterator<Item=&'a mut T> + DoubleEndedIterator
+        Self: Sized + Iterator<Item=&'a mut T> + DoubleEndedIterator
     {
         loop {
             match (self.next(), self.next_back()) {
@@ -1048,7 +1005,55 @@ fn reverse_in_place<'a, T: 'a>(&mut self) where
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<I> IteratorExt for I where I: Iterator {}
+impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I {
+    type Item = I::Item;
+    fn next(&mut self) -> Option<I::Item> { (**self).next() }
+    fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() }
+}
+
+/// Conversion from an `Iterator`
+#[stable(feature = "rust1", since = "1.0.0")]
+#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \
+                          built from an iterator over elements of type `{A}`"]
+pub trait FromIterator<A> {
+    /// Build a container with elements from something iterable.
+    #[stable(feature = "rust1", since = "1.0.0")]
+    fn from_iter<T: IntoIterator<Item=A>>(iterator: T) -> Self;
+}
+
+/// Conversion into an `Iterator`
+#[stable(feature = "rust1", since = "1.0.0")]
+pub trait IntoIterator {
+    /// The type of the elements being iterated
+    #[stable(feature = "rust1", since = "1.0.0")]
+    type Item;
+
+    /// A container for iterating over elements of type Item
+    #[stable(feature = "rust1", since = "1.0.0")]
+    type IntoIter: Iterator<Item=Self::Item>;
+
+    /// Consumes `Self` and returns an iterator over it
+    #[stable(feature = "rust1", since = "1.0.0")]
+    fn into_iter(self) -> Self::IntoIter;
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl<I: Iterator> IntoIterator for I {
+    type Item = I::Item;
+    type IntoIter = I;
+
+    fn into_iter(self) -> I {
+        self
+    }
+}
+
+/// A type growable from an `Iterator` implementation
+#[stable(feature = "rust1", since = "1.0.0")]
+pub trait Extend<A> {
+    /// Extend a container with the elements yielded by an arbitrary iterator
+    #[stable(feature = "rust1", since = "1.0.0")]
+    fn extend<T: IntoIterator<Item=A>>(&mut self, iterable: T);
+}
 
 /// A range iterator able to yield elements from both ends
 ///
@@ -1256,7 +1261,7 @@ fn product(self) -> $A {
 impl_multiplicative! { f32,  1.0 }
 impl_multiplicative! { f64,  1.0 }
 
-/// `MinMaxResult` is an enum returned by `min_max`. See `IteratorOrdExt::min_max` for more detail.
+/// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for more detail.
 #[derive(Clone, PartialEq, Debug)]
 #[unstable(feature = "core",
            reason = "unclear whether such a fine-grained result is widely useful")]
index 745a1213ad5b747a276aa65f7467e753c8c7b3bf..dc98bb8e6035f31062b3ae9f191e751e4caf252b 100644 (file)
@@ -23,7 +23,7 @@
 use error::Error;
 use fmt;
 use intrinsics;
-use iter::IteratorExt;
+use iter::Iterator;
 use marker::Copy;
 use mem::size_of;
 use ops::{Add, Sub, Mul, Div, Rem, Neg};
index b3bb4a980ebe39efc2c46752872f5d5abe06db14..cd82936b0b3ee414b1041794b9caee6692a16648 100644 (file)
 use cmp::{Eq, Ord};
 use default::Default;
 use iter::ExactSizeIterator;
-use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, IntoIterator};
+use iter::{Iterator, DoubleEndedIterator, FromIterator, IntoIterator};
 use mem;
 use ops::FnOnce;
 use result::Result::{Ok, Err};
index 424829939b92e89fbea8898bdcb7b71ff09dba54..448b90c0dbdaf5af2074f9df5ef6fc1e0290bd48 100644 (file)
@@ -37,7 +37,7 @@
 pub use clone::Clone;
 pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
 pub use convert::{AsRef, AsMut, Into, From};
-pub use iter::{Extend, IteratorExt};
+pub use iter::Extend;
 pub use iter::{Iterator, DoubleEndedIterator};
 pub use iter::{ExactSizeIterator};
 pub use option::Option::{self, Some, None};
index c7e166b49be17e68bc4888a16d017c693e5a31aa..eff04dd5903936f997ff147a76d39b530349cb63 100644 (file)
 
 use clone::Clone;
 use fmt;
-use iter::{Iterator, IteratorExt, DoubleEndedIterator,
-           FromIterator, ExactSizeIterator, IntoIterator};
+use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator};
 use ops::{FnMut, FnOnce};
 use option::Option::{self, None, Some};
 #[allow(deprecated)]
index 13075fd5ee991fae5eec064ebe9037e24db5c313..189cf3d3498919aa3ae6775bda99b3b0ca895965 100644 (file)
@@ -25,7 +25,7 @@
 use error::Error;
 use fmt;
 use iter::ExactSizeIterator;
-use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
+use iter::{Map, Iterator, DoubleEndedIterator};
 use marker::Sized;
 use mem;
 #[allow(deprecated)]
@@ -1237,7 +1237,7 @@ pub struct CharRange {
 mod traits {
     use cmp::{Ordering, Ord, PartialEq, PartialOrd, Eq};
     use cmp::Ordering::{Less, Equal, Greater};
-    use iter::IteratorExt;
+    use iter::Iterator;
     use option::Option;
     use option::Option::Some;
     use ops;
index b2fbc90be591423ce50d5406fbf5f72e7f931914..885ee3f9c3be2e19ba39c658719e0a899b578f2b 100644 (file)
@@ -211,12 +211,12 @@ fn test_empty() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_map("Foo").finish()
+                fmt.debug_map().finish()
             }
         }
 
-        assert_eq!("Foo {}", format!("{:?}", Foo));
-        assert_eq!("Foo {}", format!("{:#?}", Foo));
+        assert_eq!("{}", format!("{:?}", Foo));
+        assert_eq!("{}", format!("{:#?}", Foo));
     }
 
     #[test]
@@ -225,15 +225,15 @@ fn test_single() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_map("Foo")
+                fmt.debug_map()
                     .entry(&"bar", &true)
                     .finish()
             }
         }
 
-        assert_eq!("Foo { \"bar\": true }", format!("{:?}", Foo));
+        assert_eq!("{\"bar\": true}", format!("{:?}", Foo));
         assert_eq!(
-"Foo {
+"{
     \"bar\": true
 }",
                    format!("{:#?}", Foo));
@@ -245,16 +245,16 @@ fn test_multiple() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_map("Foo")
+                fmt.debug_map()
                     .entry(&"bar", &true)
                     .entry(&10i32, &format_args!("{}/{}", 10i32, 20i32))
                     .finish()
             }
         }
 
-        assert_eq!("Foo { \"bar\": true, 10: 10/20 }", format!("{:?}", Foo));
+        assert_eq!("{\"bar\": true, 10: 10/20}", format!("{:?}", Foo));
         assert_eq!(
-"Foo {
+"{
     \"bar\": true,
     10: 10/20
 }",
@@ -267,7 +267,7 @@ fn test_nested() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_map("Foo")
+                fmt.debug_map()
                     .entry(&"bar", &true)
                     .entry(&10i32, &format_args!("{}/{}", 10i32, 20i32))
                     .finish()
@@ -278,23 +278,23 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 
         impl fmt::Debug for Bar {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_map("Bar")
+                fmt.debug_map()
                     .entry(&"foo", &Foo)
                     .entry(&Foo, &"world")
                     .finish()
             }
         }
 
-        assert_eq!("Bar { \"foo\": Foo { \"bar\": true, 10: 10/20 }, \
-                    Foo { \"bar\": true, 10: 10/20 }: \"world\" }",
+        assert_eq!("{\"foo\": {\"bar\": true, 10: 10/20}, \
+                    {\"bar\": true, 10: 10/20}: \"world\"}",
                    format!("{:?}", Bar));
         assert_eq!(
-"Bar {
-    \"foo\": Foo {
+"{
+    \"foo\": {
         \"bar\": true,
         10: 10/20
     },
-    Foo {
+    {
         \"bar\": true,
         10: 10/20
     }: \"world\"
@@ -312,12 +312,12 @@ fn test_empty() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_set("Foo").finish()
+                fmt.debug_set().finish()
             }
         }
 
-        assert_eq!("Foo {}", format!("{:?}", Foo));
-        assert_eq!("Foo {}", format!("{:#?}", Foo));
+        assert_eq!("{}", format!("{:?}", Foo));
+        assert_eq!("{}", format!("{:#?}", Foo));
     }
 
     #[test]
@@ -326,15 +326,15 @@ fn test_single() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_set("Foo")
+                fmt.debug_set()
                     .entry(&true)
                     .finish()
             }
         }
 
-        assert_eq!("Foo { true }", format!("{:?}", Foo));
+        assert_eq!("{true}", format!("{:?}", Foo));
         assert_eq!(
-"Foo {
+"{
     true
 }",
                    format!("{:#?}", Foo));
@@ -346,16 +346,16 @@ fn test_multiple() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_set("Foo")
+                fmt.debug_set()
                     .entry(&true)
                     .entry(&format_args!("{}/{}", 10i32, 20i32))
                     .finish()
             }
         }
 
-        assert_eq!("Foo { true, 10/20 }", format!("{:?}", Foo));
+        assert_eq!("{true, 10/20}", format!("{:?}", Foo));
         assert_eq!(
-"Foo {
+"{
     true,
     10/20
 }",
@@ -368,7 +368,7 @@ fn test_nested() {
 
         impl fmt::Debug for Foo {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_set("Foo")
+                fmt.debug_set()
                     .entry(&true)
                     .entry(&format_args!("{}/{}", 10i32, 20i32))
                     .finish()
@@ -379,18 +379,18 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 
         impl fmt::Debug for Bar {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-                fmt.debug_set("Bar")
+                fmt.debug_set()
                     .entry(&Foo)
                     .entry(&"world")
                     .finish()
             }
         }
 
-        assert_eq!("Bar { Foo { true, 10/20 }, \"world\" }",
+        assert_eq!("{{true, 10/20}, \"world\"}",
                    format!("{:?}", Bar));
         assert_eq!(
-"Bar {
-    Foo {
+"{
+    {
         true,
         10/20
     },
@@ -399,3 +399,100 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
                    format!("{:#?}", Bar));
     }
 }
+
+mod debug_list {
+    use std::fmt;
+
+    #[test]
+    fn test_empty() {
+        struct Foo;
+
+        impl fmt::Debug for Foo {
+            fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+                fmt.debug_list().finish()
+            }
+        }
+
+        assert_eq!("[]", format!("{:?}", Foo));
+        assert_eq!("[]", format!("{:#?}", Foo));
+    }
+
+    #[test]
+    fn test_single() {
+        struct Foo;
+
+        impl fmt::Debug for Foo {
+            fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+                fmt.debug_list()
+                    .entry(&true)
+                    .finish()
+            }
+        }
+
+        assert_eq!("[true]", format!("{:?}", Foo));
+        assert_eq!(
+"[
+    true
+]",
+                   format!("{:#?}", Foo));
+    }
+
+    #[test]
+    fn test_multiple() {
+        struct Foo;
+
+        impl fmt::Debug for Foo {
+            fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+                fmt.debug_list()
+                    .entry(&true)
+                    .entry(&format_args!("{}/{}", 10i32, 20i32))
+                    .finish()
+            }
+        }
+
+        assert_eq!("[true, 10/20]", format!("{:?}", Foo));
+        assert_eq!(
+"[
+    true,
+    10/20
+]",
+                   format!("{:#?}", Foo));
+    }
+
+    #[test]
+    fn test_nested() {
+        struct Foo;
+
+        impl fmt::Debug for Foo {
+            fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+                fmt.debug_list()
+                    .entry(&true)
+                    .entry(&format_args!("{}/{}", 10i32, 20i32))
+                    .finish()
+            }
+        }
+
+        struct Bar;
+
+        impl fmt::Debug for Bar {
+            fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+                fmt.debug_list()
+                    .entry(&Foo)
+                    .entry(&"world")
+                    .finish()
+            }
+        }
+
+        assert_eq!("[[true, 10/20], \"world\"]",
+                   format!("{:?}", Bar));
+        assert_eq!(
+"[
+    [
+        true,
+        10/20
+    ],
+    \"world\"
+]",
+                   format!("{:#?}", Bar));
+    }
+}
index 16da3237c815c6993fc6bf2f29a8f0d36727784f..23e31df5395268971b0c821f8ffd96a08da76d0d 100644 (file)
@@ -23,7 +23,6 @@
 use std::collections::HashSet;
 use syntax::ast;
 use syntax::ast_util::local_def;
-use syntax::attr;
 use syntax::codemap::Span;
 use syntax::parse::token::{self, special_idents};
 use syntax::visit;
@@ -250,22 +249,6 @@ fn check_impl(&mut self,
                                                         &fcx.inh.param_env.free_substs,
                                                         &trait_ref);
 
-            // There are special rules that apply to drop.
-            if
-                fcx.tcx().lang_items.drop_trait() == Some(trait_ref.def_id) &&
-                !attr::contains_name(&item.attrs, "unsafe_destructor")
-            {
-                match self_ty.sty {
-                    ty::ty_struct(def_id, _) |
-                    ty::ty_enum(def_id, _) => {
-                        check_struct_safe_for_destructor(fcx, item.span, def_id);
-                    }
-                    _ => {
-                        // Coherence already reports an error in this case.
-                    }
-                }
-            }
-
             if fcx.tcx().lang_items.copy_trait() == Some(trait_ref.def_id) {
                 // This is checked in coherence.
                 return
@@ -761,22 +744,3 @@ fn filter_to_trait_obligations<'tcx>(bounds: ty::InstantiatedPredicates<'tcx>)
     }
     result
 }
-
-///////////////////////////////////////////////////////////////////////////
-// Special drop trait checking
-
-fn check_struct_safe_for_destructor<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
-                                              span: Span,
-                                              struct_did: ast::DefId) {
-    let struct_tpt = ty::lookup_item_type(fcx.tcx(), struct_did);
-    if struct_tpt.generics.has_type_params(subst::TypeSpace)
-        || struct_tpt.generics.has_region_params(subst::TypeSpace)
-    {
-        span_err!(fcx.tcx().sess, span, E0141,
-                  "cannot implement a destructor on a structure \
-                   with type parameters");
-        span_note!(fcx.tcx().sess, span,
-                   "use \"#[unsafe_destructor]\" on the implementation \
-                    to force the compiler to allow this");
-    }
-}
index f9e1cb877b60bfd847443b4e451cbfabf49490f7..276959b715dfb3c067c5f9781279547ec91f5d70 100644 (file)
@@ -20,7 +20,7 @@
 use default::Default;
 use fmt::{self, Debug};
 use hash::{Hash, SipHasher};
-use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map};
+use iter::{self, Iterator, ExactSizeIterator, IntoIterator, FromIterator, Extend, Map};
 use marker::Sized;
 use mem::{self, replace};
 use ops::{Deref, FnMut, FnOnce, Index};
@@ -1226,14 +1226,7 @@ impl<K, V, S> Debug for HashMap<K, V, S>
     where K: Eq + Hash + Debug, V: Debug, S: HashState
 {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
-
-        for (i, (k, v)) in self.iter().enumerate() {
-            if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{:?}: {:?}", *k, *v));
-        }
-
-        write!(f, "}}")
+        self.iter().fold(f.debug_map(), |b, (k, v)| b.entry(k, v)).finish()
     }
 }
 
index 0933b4f662a9d744fbec130c491ea1d842e3d944..9a4b55af4d5f42404adb38e99c33be417464fe01 100644 (file)
@@ -18,9 +18,7 @@
 use fmt::Debug;
 use fmt;
 use hash::Hash;
-use iter::{
-    Iterator, IntoIterator, ExactSizeIterator, IteratorExt, FromIterator, Map, Chain, Extend,
-};
+use iter::{Iterator, IntoIterator, ExactSizeIterator, FromIterator, Map, Chain, Extend};
 use ops::{BitOr, BitAnd, BitXor, Sub};
 use option::Option::{Some, None, self};
 
@@ -614,14 +612,7 @@ impl<T, S> fmt::Debug for HashSet<T, S>
           S: HashState
 {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
-
-        for (i, x) in self.iter().enumerate() {
-            if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{:?}", *x));
-        }
-
-        write!(f, "}}")
+        self.iter().fold(f.debug_set(), |b, e| b.entry(e)).finish()
     }
 }
 
index 710f0fe19db8e6d36782a44700db27857982277a..8f65933453854a6d3f4f3ebba141b5e8cb2a1327 100644 (file)
@@ -15,7 +15,7 @@
 use clone::Clone;
 use cmp;
 use hash::{Hash, Hasher};
-use iter::{Iterator, IteratorExt, ExactSizeIterator, count};
+use iter::{Iterator, ExactSizeIterator, count};
 use marker::{Copy, Send, Sync, Sized, self};
 use mem::{min_align_of, size_of};
 use mem;
index b96fe94dd2ed736d0f530701f52460dcdb23b620..d8a95133d94144dc6d062ca552a9c08314177dfa 100644 (file)
@@ -261,7 +261,7 @@ fn dlsym(handle: *mut libc::c_void,
 #[cfg(target_os = "windows")]
 mod dl {
     use ffi::OsStr;
-    use iter::IteratorExt;
+    use iter::Iterator;
     use libc;
     use libc::consts::os::extra::ERROR_CALL_NOT_IMPLEMENTED;
     use ops::FnOnce;
index 8b19d16017280ccce55b6458778101f02c5a81c2..a00f77080252c70292950b2ac17202478674be99 100644 (file)
@@ -15,7 +15,7 @@
 use error::{Error, FromError};
 use fmt;
 use io;
-use iter::IteratorExt;
+use iter::Iterator;
 use libc;
 use mem;
 #[allow(deprecated)]
index 5d62f1341e300f046100ffd2abcd7a112c4ebfa4..be0b3687bad89b0e88ef45056b3bc2e7b63a348c 100644 (file)
@@ -16,7 +16,7 @@
 use unicode::str as core_str;
 use error as std_error;
 use fmt;
-use iter::{self, Iterator, IteratorExt, Extend};
+use iter::{self, Iterator, Extend};
 use marker::Sized;
 use ops::{Drop, FnOnce};
 use option::Option::{self, Some, None};
index 5f5f2fed567328a26fba2a8256d53bbe87e5b6ac..b7cb8f9ed50fdcbec680f17db933b23fca299ae4 100644 (file)
 #![feature(into_cow)]
 #![feature(slice_patterns)]
 #![feature(std_misc)]
+#![feature(debug_builders)]
 #![cfg_attr(test, feature(test, rustc_private, std_misc))]
 
 // Don't link to std. We are std.
index 502f414d50b98f1224e54d20cf3f7e52e0b7661f..b8b7df750033157c219cbe8c4d76be820efe1337 100644 (file)
@@ -15,7 +15,7 @@
 use cmp;
 use fmt;
 use old_io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
-use iter::{IteratorExt, ExactSizeIterator, repeat};
+use iter::{Iterator, ExactSizeIterator, repeat};
 use ops::Drop;
 use option::Option;
 use option::Option::{Some, None};
index 76a448c4aae0e4f96e3212b6ba66e95a1c509ecf..5f20c383bb7586388901f826f1b9be138e6a6d0d 100644 (file)
@@ -400,7 +400,7 @@ mod test {
     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;
+    use prelude::v1::Iterator;
     use old_io;
     use iter::repeat;
     use self::test_crate::Bencher;
index aaa55c5d1d9b9eba876ea1aa10773ffbd799b556..df8ac78f7e581c107d85d9c32f3a895788af72bb 100644 (file)
 use error::Error;
 use fmt;
 use isize;
-use iter::{Iterator, IteratorExt};
+use iter::Iterator;
 use marker::{PhantomFn, Sized};
 use mem::transmute;
 use ops::FnOnce;
index 6237bb97f3e6092f349e5a5dc5ad0e097422a717..739439ebd151ba50b5ff401a75c1fe183829022b 100644 (file)
@@ -19,7 +19,7 @@
 pub use self::Flag::*;
 pub use self::Protocol::*;
 
-use iter::IteratorExt;
+use iter::Iterator;
 use old_io::IoResult;
 use old_io::net::ip::{SocketAddr, IpAddr};
 use option::Option;
index ba3578f742596f5d422c17207e7c707cd690be31..26e1bb6550b7a152887e05d26a246f2dd1cb8b8f 100644 (file)
@@ -21,7 +21,7 @@
 use fmt;
 use old_io::{self, IoResult, IoError};
 use old_io::net;
-use iter::{Iterator, IteratorExt};
+use iter::Iterator;
 use ops::{FnOnce, FnMut};
 use option::Option;
 use option::Option::{None, Some};
index 572cfa1395ddadeec44ce8bf4a6459815fcefbfa..0a2cc517a0631096ed58ddc0b3a2e70fc0971b73 100644 (file)
@@ -12,7 +12,7 @@
 #![allow(deprecated)] // rand
 
 use env;
-use iter::IteratorExt;
+use iter::Iterator;
 use old_io::{fs, IoError, IoErrorKind, IoResult};
 use old_io;
 use ops::Drop;
index 50bda04b5d0745c33ce30b2baab8b886e472923e..c405df2824e818bc4736c3d8b4e264d923f048d3 100644 (file)
@@ -70,7 +70,7 @@
 use ffi::CString;
 use clone::Clone;
 use fmt;
-use iter::IteratorExt;
+use iter::Iterator;
 use option::Option;
 use option::Option::{None, Some};
 use str;
index 67bfe2bd77026f6c0bb725187ceb97fb7735b37d..bbc1756bee6321004625b2bd4c14a0d3ede76859 100644 (file)
@@ -16,7 +16,7 @@
 use hash;
 use old_io::Writer;
 use iter::{AdditiveIterator, Extend};
-use iter::{Iterator, IteratorExt, Map};
+use iter::{Iterator, Map};
 use marker::Sized;
 use option::Option::{self, Some, None};
 use result::Result::{self, Ok, Err};
@@ -444,13 +444,13 @@ mod tests {
     use super::*;
 
     use clone::Clone;
-    use iter::IteratorExt;
     use option::Option::{self, Some, None};
     use old_path::GenericPath;
     use slice::AsSlice;
     use str::{self, Str};
     use string::ToString;
     use vec::Vec;
+    use iter::Iterator;
 
     macro_rules! t {
         (s: $path:expr, $exp:expr) => (
index 869a8127301730fbf0c599653c9355781657f92a..bd67855bf1b8c45fbbe4d4a6932844c4d8f072c1 100644 (file)
@@ -21,7 +21,7 @@
 use hash;
 use old_io::Writer;
 use iter::{AdditiveIterator, Extend};
-use iter::{Iterator, IteratorExt, Map, repeat};
+use iter::{Iterator, Map, repeat};
 use mem;
 use option::Option::{self, Some, None};
 use result::Result::{self, Ok, Err};
@@ -1126,7 +1126,7 @@ mod tests {
     use super::*;
 
     use clone::Clone;
-    use iter::IteratorExt;
+    use iter::Iterator;
     use option::Option::{self, Some, None};
     use old_path::GenericPath;
     use slice::AsSlice;
index 2e8521cc94bd77cfb9079c04bcc62ffc0034fd77..e19c734b8a3acc3646a8712c4ff83558d16389ea 100644 (file)
@@ -43,7 +43,7 @@
 use error::{FromError, Error};
 use ffi::{OsString, OsStr};
 use fmt;
-use iter::{Iterator, IteratorExt};
+use iter::Iterator;
 use libc::{c_void, c_int, c_char};
 use libc;
 use marker::{Copy, Send};
index 6e12ac1a226592b864354231aed50703fd0f8e4f..611dd85a71b364f8d5de1a2dffe8deed7387b319 100644 (file)
@@ -36,7 +36,7 @@
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use iter::ExactSizeIterator;
 #[stable(feature = "rust1", since = "1.0.0")]
-#[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend};
+#[doc(no_inline)] pub use iter::{Iterator, Extend};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)] pub use option::Option::{self, Some, None};
 #[stable(feature = "rust1", since = "1.0.0")]
index cfd4e17c021b1d6f55e8e1b9c00c771010e6483d..fad57323d34baf6e443addf71ea9688067214bbf 100644 (file)
 use cell::RefCell;
 use clone::Clone;
 use old_io::IoResult;
-use iter::{Iterator, IteratorExt};
+use iter::Iterator;
 use mem;
 use rc::Rc;
 use result::Result::{Ok, Err};
index b46d390826c93934cf292746b2e5b92634297835..99a554a835f9fbc6cc7179d3757bae03892646c6 100644 (file)
@@ -122,9 +122,9 @@ fn backtrace(buf: *mut *mut libc::c_void,
 
     try!(writeln!(w, "stack backtrace:"));
     // 100 lines should be enough
-    const SIZE: uint = 100;
+    const SIZE: usize = 100;
     let mut buf: [*mut libc::c_void; SIZE] = unsafe {mem::zeroed()};
-    let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as uint};
+    let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as usize};
 
     // skipping the first one as it is write itself
     let iter = (1..cnt).map(|i| {
index 724156d81d84e7e515b1997b5fd85cc0aa83375f..fab443feebd0bd08f1c5fe8bd7ab963e6d2f80da 100644 (file)
@@ -339,7 +339,7 @@ pub fn args() -> Args {
         let info = objc_msgSend(klass, process_info_sel);
         let args = objc_msgSend(info, arguments_sel);
 
-        let cnt: int = mem::transmute(objc_msgSend(args, count_sel));
+        let cnt: usize = mem::transmute(objc_msgSend(args, count_sel));
         for i in (0..cnt) {
             let tmp = objc_msgSend(args, object_at_sel, i);
             let utf_c_str: *const libc::c_char =
index 4c2777459dd5d1810c789b46e556e336b975504f..9e9bb86446e7c11b1f395ed598c888a89764ea4e 100644 (file)
@@ -127,7 +127,7 @@ pub fn spawn(cfg: &Command,
 
         use env::split_paths;
         use mem;
-        use iter::IteratorExt;
+        use iter::Iterator;
 
         // To have the spawning semantics of unix/windows stay the same, we need to
         // read the *child's* PATH if one is provided. See #15149 for more details.
index c6e6e749860c06d381fcaae6463e452cf681d259..1b03a18072011a2c1f5acf0bbcf306369af6fe28 100644 (file)
@@ -58,7 +58,6 @@
     ("log_syntax", "1.0.0", Active),
     ("trace_macros", "1.0.0", Active),
     ("concat_idents", "1.0.0", Active),
-    ("unsafe_destructor", "1.0.0", Active),
     ("intrinsics", "1.0.0", Active),
     ("lang_items", "1.0.0", Active),
 
     ("start", "1.0.0", Active),
     ("main", "1.0.0", Active),
 
+    // Deprecate after snapshot
+    // SNAP a923278
+    ("unsafe_destructor", "1.0.0", Active),
+
     // A temporary feature gate used to enable parser extensions needed
     // to bootstrap fix for #5723.
     ("issue_5723_bootstrap", "1.0.0", Accepted),
@@ -193,7 +196,6 @@ enum Status {
     ("repr", Normal),
     ("path", Normal),
     ("abi", Normal),
-    ("unsafe_destructor", Normal),
     ("automatically_derived", Normal),
     ("no_mangle", Normal),
     ("no_link", Normal),
@@ -205,7 +207,8 @@ enum Status {
     ("link_args", Normal),
     ("macro_escape", Normal),
 
-
+    ("unsafe_destructor", Gated("unsafe_destructor",
+                                "`#[unsafe_destructor]` does nothing anymore")),
     ("staged_api", Gated("staged_api",
                          "staged_api is for use by rustc only")),
     ("plugin", Gated("plugin",
@@ -571,15 +574,6 @@ fn visit_item(&mut self, i: &ast::Item) {
                     _ => {}
                 }
 
-                if attr::contains_name(&i.attrs,
-                                       "unsafe_destructor") {
-                    self.gate_feature("unsafe_destructor",
-                                      i.span,
-                                      "`#[unsafe_destructor]` allows too \
-                                       many unsafe patterns and may be \
-                                       removed in the future");
-                }
-
                 if attr::contains_name(&i.attrs[..],
                                        "old_orphan_check") {
                     self.gate_feature(
index 6024fef9fb81f043256f4f189995349a6943e8b4..2aebbf3d54b9cd08d6151d071685887cde875098 100644 (file)
 
 // Test that `#[unsafe_destructor]` attribute is gated by `unsafe_destructor`
 // feature gate.
+//
+// (This test can be removed entirely when we remove the
+// `unsafe_destructor` feature itself.)
 
 struct D<'a>(&'a u32);
 
 #[unsafe_destructor]
+//~^ ERROR `#[unsafe_destructor]` does nothing anymore
+//~| HELP: add #![feature(unsafe_destructor)] to the crate attributes to enable
+// (but of couse there is no point in doing so)
 impl<'a> Drop for D<'a> {
-    //~^ ERROR `#[unsafe_destructor]` allows too many unsafe patterns
     fn drop(&mut self) { }
 }
-//~^ HELP: add #![feature(unsafe_destructor)] to the crate attributes to enable
 
 pub fn main() { }
diff --git a/src/test/compile-fail/issue-13853-3.rs b/src/test/compile-fail/issue-13853-3.rs
deleted file mode 100644 (file)
index 7ca158c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2014 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.
-
-#![crate_type = "lib"]
-
-use std::marker::PhantomData;
-
-enum NodeContents<'a> {
-    Children(Vec<Node<'a>>),
-}
-
-impl<'a> Drop for NodeContents<'a> {
-    //~^ ERROR cannot implement a destructor on a structure with type parameters
-    fn drop( &mut self ) {
-    }
-}
-
-struct Node<'a> {
-    contents: NodeContents<'a>,
-    marker: PhantomData<&'a ()>,
-}
-
-impl<'a> Node<'a> {
-    fn noName(contents: NodeContents<'a>) -> Node<'a> {
-        Node { contents: contents, marker: PhantomData }
-    }
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/issue-13853-4.rs b/src/test/compile-fail/issue-13853-4.rs
deleted file mode 100644 (file)
index b0db9e5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2014 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.
-
-struct AutoBuilder<'a> {
-    context: &'a isize
-}
-
-impl<'a> Drop for AutoBuilder<'a> {
-    //~^ ERROR cannot implement a destructor on a structure with type parameters
-    fn drop(&mut self) {
-    }
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/issue-16465.rs b/src/test/compile-fail/issue-16465.rs
deleted file mode 100644 (file)
index 825b40c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2014 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.
-
-// Used to cause an ICE
-
-struct Foo<T>{
-    x : T
-}
-
-type FooInt = Foo<isize>;
-
-impl Drop for FooInt {
-//~^ ERROR cannot implement a destructor on a structure with type parameters
-    fn drop(&mut self){}
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs
deleted file mode 100644 (file)
index 7f37041..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 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.
-
-
-struct Bar<'a> {
-    f: &'a isize,
-}
-
-impl<'a> Drop for Bar<'a> {
-//~^ ERROR E0141
-    fn drop(&mut self) {
-    }
-}
-
-struct Baz {
-    f: &'static isize,
-}
-
-impl Drop for Baz {
-    fn drop(&mut self) {
-    }
-}
-
-fn main() { }
diff --git a/src/test/compile-fail/unsafe-destructor-check-crash.rs b/src/test/compile-fail/unsafe-destructor-check-crash.rs
deleted file mode 100644 (file)
index af67558..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2014 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.
-
-
-
-// Regression test for issue #15557
-
-#![allow(dead_code)]
-struct AReg1<'a>(&'a u32);
-
-impl<'a> Drop for AReg1<'a> {
-//~^ ERROR: cannot implement a destructor on a structure with type parameters
-  fn drop(&mut self) {}
-}
-
-fn main() {}