about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-05-13 18:31:51 -0700
committerbors <bors@rust-lang.org>2014-05-13 18:31:51 -0700
commitb2b383cab5959b1ec331e1d77583fa944b7fd593 (patch)
tree79540b4f5f7e125a260b9ca00f25e796241425f9 /src/libstd
parentcb115ac2d4f57d8b590c8d46d8f9e2958ed9a527 (diff)
parentf09592a5d154177f0c9d739c9fe60742ec4cd951 (diff)
downloadrust-b2b383cab5959b1ec331e1d77583fa944b7fd593.tar.gz
rust-b2b383cab5959b1ec331e1d77583fa944b7fd593.zip
auto merge of #14187 : alexcrichton/rust/rollup, r=alexcrichton
Closes #14184 (std: Move the owned module from core to std)
Closes #14183 (Allow blocks in const expressions)
Closes #14176 (Add tests for from_bits.)
Closes #14175 (Replaced ~T by Box<T> in manual)
Closes #14173 (Implements Default trait for BigInt and BigUint)
Closes #14171 (Fix #8391)
Closes #14159 (Clean up unicode code in libstd)
Closes #14126 (docs: Add a not found page)
Closes #14123 (add a line to the example to clarify semantics)
Closes #14106 (Pretty printer improvements)
Closes #14083 (rustllvm: Add LLVMRustArrayType)
Closes #13957 (io: Implement process wait timeouts)
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/bitflags.rs7
-rw-r--r--src/libstd/io/process.rs190
-rw-r--r--src/libstd/lib.rs8
-rw-r--r--src/libstd/owned.rs101
-rw-r--r--src/libstd/rt/rtio.rs3
-rw-r--r--src/libstd/rt/task.rs3
-rw-r--r--src/libstd/str.rs32
-rw-r--r--src/libstd/task.rs5
-rw-r--r--src/libstd/unicode.rs6
9 files changed, 270 insertions, 85 deletions
diff --git a/src/libstd/bitflags.rs b/src/libstd/bitflags.rs
index 5737bc772df..f834a158588 100644
--- a/src/libstd/bitflags.rs
+++ b/src/libstd/bitflags.rs
@@ -208,6 +208,13 @@ mod tests {
     }
 
     #[test]
+    fn test_from_bits() {
+        assert!(unsafe { Flags::from_bits(0x00000000) } == Flags::empty());
+        assert!(unsafe { Flags::from_bits(0x00000001) } == FlagA);
+        assert!(unsafe { Flags::from_bits(0x00000111) } == FlagABC);
+    }
+
+    #[test]
     fn test_is_empty(){
         assert!(Flags::empty().is_empty());
         assert!(!FlagA.is_empty());
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index 529fd25dc50..349cac723ff 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -10,6 +10,8 @@
 
 //! Bindings for executing child processes
 
+#![allow(experimental)]
+
 use prelude::*;
 
 use fmt;
@@ -50,7 +52,7 @@ use rt::rtio::{RtioProcess, IoFactory, LocalIo};
 /// };
 ///
 /// let contents = child.stdout.get_mut_ref().read_to_end();
-/// assert!(child.wait().success());
+/// assert!(child.wait().unwrap().success());
 /// ```
 pub struct Process {
     handle: Box<RtioProcess:Send>,
@@ -284,7 +286,7 @@ impl Process {
     /// println!("stderr: {}", str::from_utf8_lossy(output.error.as_slice()));
     /// ```
     pub fn output(prog: &str, args: &[~str]) -> IoResult<ProcessOutput> {
-        Process::new(prog, args).map(|mut p| p.wait_with_output())
+        Process::new(prog, args).and_then(|p| p.wait_with_output())
     }
 
     /// Executes a child process and collects its exit status. This will block
@@ -303,7 +305,7 @@ impl Process {
     /// println!("process exited with: {}", status);
     /// ```
     pub fn status(prog: &str, args: &[~str]) -> IoResult<ProcessExit> {
-        Process::new(prog, args).map(|mut p| p.wait())
+        Process::new(prog, args).and_then(|mut p| p.wait())
     }
 
     /// Creates a new process with the specified configuration.
@@ -378,17 +380,72 @@ impl Process {
     /// after it has been called at least once.
     ///
     /// The stdin handle to the child process will be closed before waiting.
-    pub fn wait(&mut self) -> ProcessExit {
+    ///
+    /// # Errors
+    ///
+    /// This function can fail if a timeout was previously specified via
+    /// `set_timeout` and the timeout expires before the child exits.
+    pub fn wait(&mut self) -> IoResult<ProcessExit> {
         drop(self.stdin.take());
         self.handle.wait()
     }
 
+    /// Sets a timeout, in milliseconds, for future calls to wait().
+    ///
+    /// The argument specified is a relative distance into the future, in
+    /// milliseconds, after which any call to wait() will return immediately
+    /// with a timeout error, and all future calls to wait() will not block.
+    ///
+    /// A value of `None` will clear any previous timeout, and a value of `Some`
+    /// will override any previously set timeout.
+    ///
+    /// # Example
+    ///
+    /// ```no_run
+    /// # #![allow(experimental)]
+    /// use std::io::process::{Process, ProcessExit};
+    /// use std::io::IoResult;
+    ///
+    /// fn run_gracefully(prog: &str) -> IoResult<ProcessExit> {
+    ///     let mut p = try!(Process::new("long-running-process", []));
+    ///
+    ///     // give the process 10 seconds to finish completely
+    ///     p.set_timeout(Some(10_000));
+    ///     match p.wait() {
+    ///         Ok(status) => return Ok(status),
+    ///         Err(..) => {}
+    ///     }
+    ///
+    ///     // Attempt to exit gracefully, but don't wait for it too long
+    ///     try!(p.signal_exit());
+    ///     p.set_timeout(Some(1_000));
+    ///     match p.wait() {
+    ///         Ok(status) => return Ok(status),
+    ///         Err(..) => {}
+    ///     }
+    ///
+    ///     // Well, we did our best, forcefully kill the process
+    ///     try!(p.signal_kill());
+    ///     p.set_timeout(None);
+    ///     p.wait()
+    /// }
+    /// ```
+    #[experimental = "the type of the timeout is likely to change"]
+    pub fn set_timeout(&mut self, timeout_ms: Option<u64>) {
+        self.handle.set_timeout(timeout_ms)
+    }
+
     /// Simultaneously wait for the child to exit and collect all remaining
     /// output on the stdout/stderr handles, returning a `ProcessOutput`
     /// instance.
     ///
     /// The stdin handle to the child is closed before waiting.
-    pub fn wait_with_output(&mut self) -> ProcessOutput {
+    ///
+    /// # Errors
+    ///
+    /// This function can fail for any of the same reasons that `wait()` can
+    /// fail.
+    pub fn wait_with_output(mut self) -> IoResult<ProcessOutput> {
         drop(self.stdin.take());
         fn read(stream: Option<io::PipeStream>) -> Receiver<IoResult<Vec<u8>>> {
             let (tx, rx) = channel();
@@ -404,11 +461,13 @@ impl Process {
         let stdout = read(self.stdout.take());
         let stderr = read(self.stderr.take());
 
-        let status = self.wait();
+        let status = try!(self.wait());
 
-        ProcessOutput { status: status,
-                        output: stdout.recv().ok().unwrap_or(Vec::new()),
-                        error:  stderr.recv().ok().unwrap_or(Vec::new()) }
+        Ok(ProcessOutput {
+            status: status,
+            output: stdout.recv().ok().unwrap_or(Vec::new()),
+            error:  stderr.recv().ok().unwrap_or(Vec::new()),
+        })
     }
 }
 
@@ -421,7 +480,8 @@ impl Drop for Process {
         drop(self.stderr.take());
         drop(mem::replace(&mut self.extra_io, Vec::new()));
 
-        self.wait();
+        self.set_timeout(None);
+        let _ = self.wait().unwrap();
     }
 }
 
@@ -441,7 +501,7 @@ mod tests {
         let p = Process::configure(args);
         assert!(p.is_ok());
         let mut p = p.unwrap();
-        assert!(p.wait().success());
+        assert!(p.wait().unwrap().success());
     })
 
     #[cfg(not(target_os="android"))]
@@ -465,7 +525,7 @@ mod tests {
         let p = Process::configure(args);
         assert!(p.is_ok());
         let mut p = p.unwrap();
-        assert!(p.wait().matches_exit_status(1));
+        assert!(p.wait().unwrap().matches_exit_status(1));
         drop(p.wait().clone());
     })
 
@@ -479,7 +539,7 @@ mod tests {
         let p = Process::configure(args);
         assert!(p.is_ok());
         let mut p = p.unwrap();
-        match p.wait() {
+        match p.wait().unwrap() {
             process::ExitSignal(1) => {},
             result => fail!("not terminated by signal 1 (instead, {})", result),
         }
@@ -495,7 +555,7 @@ mod tests {
         let mut p = p.unwrap();
         assert!(p.stdout.is_some());
         let ret = read_all(p.stdout.get_mut_ref() as &mut Reader);
-        assert!(p.wait().success());
+        assert!(p.wait().unwrap().success());
         return ret;
     }
 
@@ -536,7 +596,7 @@ mod tests {
         p.stdin.get_mut_ref().write("foobar".as_bytes()).unwrap();
         drop(p.stdin.take());
         let out = read_all(p.stdout.get_mut_ref() as &mut Reader);
-        assert!(p.wait().success());
+        assert!(p.wait().unwrap().success());
         assert_eq!(out, "foobar\n".to_owned());
     })
 
@@ -548,7 +608,7 @@ mod tests {
             .. ProcessConfig::new()
         };
         let mut p = Process::configure(args).unwrap();
-        assert!(p.wait().success());
+        assert!(p.wait().unwrap().success());
     })
 
     #[cfg(windows)]
@@ -572,7 +632,7 @@ mod tests {
             .. ProcessConfig::new()
         };
         let mut p = Process::configure(args).unwrap();
-        assert!(p.wait().success());
+        assert!(p.wait().unwrap().success());
     })
 
     #[cfg(unix, not(target_os="android"))]
@@ -635,21 +695,21 @@ mod tests {
     #[cfg(not(target_os="android"))]
     iotest!(fn test_finish_once() {
         let mut prog = Process::new("false", []).unwrap();
-        assert!(prog.wait().matches_exit_status(1));
+        assert!(prog.wait().unwrap().matches_exit_status(1));
     })
 
     #[cfg(not(target_os="android"))]
     iotest!(fn test_finish_twice() {
         let mut prog = Process::new("false", []).unwrap();
-        assert!(prog.wait().matches_exit_status(1));
-        assert!(prog.wait().matches_exit_status(1));
+        assert!(prog.wait().unwrap().matches_exit_status(1));
+        assert!(prog.wait().unwrap().matches_exit_status(1));
     })
 
     #[cfg(not(target_os="android"))]
     iotest!(fn test_wait_with_output_once() {
 
-        let mut prog = Process::new("echo", ["hello".to_owned()]).unwrap();
-        let ProcessOutput {status, output, error} = prog.wait_with_output();
+        let prog = Process::new("echo", ["hello".to_owned()]).unwrap();
+        let ProcessOutput {status, output, error} = prog.wait_with_output().unwrap();
         let output_str = str::from_utf8(output.as_slice()).unwrap();
 
         assert!(status.success());
@@ -660,30 +720,6 @@ mod tests {
         }
     })
 
-    #[cfg(not(target_os="android"))]
-    iotest!(fn test_wait_with_output_twice() {
-        let mut prog = Process::new("echo", ["hello".to_owned()]).unwrap();
-        let ProcessOutput {status, output, error} = prog.wait_with_output();
-
-        let output_str = str::from_utf8(output.as_slice()).unwrap();
-
-        assert!(status.success());
-        assert_eq!(output_str.trim().to_owned(), "hello".to_owned());
-        // FIXME #7224
-        if !running_on_valgrind() {
-            assert_eq!(error, Vec::new());
-        }
-
-        let ProcessOutput {status, output, error} = prog.wait_with_output();
-
-        assert!(status.success());
-        assert_eq!(output, Vec::new());
-        // FIXME #7224
-        if !running_on_valgrind() {
-            assert_eq!(error, Vec::new());
-        }
-    })
-
     #[cfg(unix,not(target_os="android"))]
     pub fn run_pwd(dir: Option<&Path>) -> Process {
         Process::configure(ProcessConfig {
@@ -714,9 +750,10 @@ mod tests {
 
     iotest!(fn test_keep_current_working_dir() {
         use os;
-        let mut prog = run_pwd(None);
+        let prog = run_pwd(None);
 
-        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
+        let output = str::from_utf8(prog.wait_with_output().unwrap()
+                                        .output.as_slice()).unwrap().to_owned();
         let parent_dir = os::getcwd();
         let child_dir = Path::new(output.trim());
 
@@ -732,9 +769,10 @@ mod tests {
         // test changing to the parent of os::getcwd() because we know
         // the path exists (and os::getcwd() is not expected to be root)
         let parent_dir = os::getcwd().dir_path();
-        let mut prog = run_pwd(Some(&parent_dir));
+        let prog = run_pwd(Some(&parent_dir));
 
-        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
+        let output = str::from_utf8(prog.wait_with_output().unwrap()
+                                        .output.as_slice()).unwrap().to_owned();
         let child_dir = Path::new(output.trim());
 
         let parent_stat = parent_dir.stat().unwrap();
@@ -777,8 +815,9 @@ mod tests {
         use os;
         if running_on_valgrind() { return; }
 
-        let mut prog = run_env(None);
-        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
+        let prog = run_env(None);
+        let output = str::from_utf8(prog.wait_with_output().unwrap()
+                                        .output.as_slice()).unwrap().to_owned();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
@@ -791,8 +830,10 @@ mod tests {
         use os;
         if running_on_valgrind() { return; }
 
-        let mut prog = run_env(None);
-        let output = str::from_utf8(prog.wait_with_output().output.as_slice()).unwrap().to_owned();
+        let prog = run_env(None);
+        let output = str::from_utf8(prog.wait_with_output()
+                                        .unwrap().output.as_slice())
+                                   .unwrap().to_owned();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
@@ -807,8 +848,8 @@ mod tests {
     iotest!(fn test_add_to_env() {
         let new_env = box [("RUN_TEST_NEW_ENV".to_owned(), "123".to_owned())];
 
-        let mut prog = run_env(Some(new_env));
-        let result = prog.wait_with_output();
+        let prog = run_env(Some(new_env));
+        let result = prog.wait_with_output().unwrap();
         let output = str::from_utf8_lossy(result.output.as_slice()).into_owned();
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"),
@@ -830,14 +871,14 @@ mod tests {
     iotest!(fn test_kill() {
         let mut p = sleeper();
         Process::kill(p.id(), PleaseExitSignal).unwrap();
-        assert!(!p.wait().success());
+        assert!(!p.wait().unwrap().success());
     })
 
     iotest!(fn test_exists() {
         let mut p = sleeper();
         assert!(Process::kill(p.id(), 0).is_ok());
         p.signal_kill().unwrap();
-        assert!(!p.wait().success());
+        assert!(!p.wait().unwrap().success());
     })
 
     iotest!(fn test_zero() {
@@ -845,11 +886,42 @@ mod tests {
         p.signal_kill().unwrap();
         for _ in range(0, 20) {
             if p.signal(0).is_err() {
-                assert!(!p.wait().success());
+                assert!(!p.wait().unwrap().success());
                 return
             }
             timer::sleep(100);
         }
         fail!("never saw the child go away");
     })
+
+    iotest!(fn wait_timeout() {
+        let mut p = sleeper();
+        p.set_timeout(Some(10));
+        assert_eq!(p.wait().err().unwrap().kind, TimedOut);
+        assert_eq!(p.wait().err().unwrap().kind, TimedOut);
+        p.signal_kill().unwrap();
+        p.set_timeout(None);
+        assert!(p.wait().is_ok());
+    })
+
+    iotest!(fn wait_timeout2() {
+        let (tx, rx) = channel();
+        let tx2 = tx.clone();
+        spawn(proc() {
+            let mut p = sleeper();
+            p.set_timeout(Some(10));
+            assert_eq!(p.wait().err().unwrap().kind, TimedOut);
+            p.signal_kill().unwrap();
+            tx.send(());
+        });
+        spawn(proc() {
+            let mut p = sleeper();
+            p.set_timeout(Some(10));
+            assert_eq!(p.wait().err().unwrap().kind, TimedOut);
+            p.signal_kill().unwrap();
+            tx2.send(());
+        });
+        rx.recv();
+        rx.recv();
+    })
 }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 34ed7933c39..a37f9a516fd 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -133,14 +133,16 @@ extern crate core;
 #[cfg(test)] pub use ops = realstd::ops;
 #[cfg(test)] pub use cmp = realstd::cmp;
 #[cfg(test)] pub use ty = realstd::ty;
-#[cfg(test)] pub use owned = realstd::owned;
+#[cfg(not(stage0), test)] pub use owned = realstd::owned;
 
 #[cfg(not(test))] pub use cmp = core::cmp;
 #[cfg(not(test))] pub use kinds = core::kinds;
 #[cfg(not(test))] pub use ops = core::ops;
-#[cfg(not(test))] pub use owned = core::owned;
 #[cfg(not(test))] pub use ty = core::ty;
 
+#[cfg(stage0, test)] pub use owned = realstd::owned;
+#[cfg(stage0, not(test))] pub use owned = core::owned;
+
 pub use core::any;
 pub use core::bool;
 pub use core::cell;
@@ -207,6 +209,8 @@ pub mod ascii;
 
 pub mod rc;
 pub mod gc;
+#[cfg(not(stage0), not(test))]
+pub mod owned;
 
 /* Common traits */
 
diff --git a/src/libstd/owned.rs b/src/libstd/owned.rs
new file mode 100644
index 00000000000..3af12c5154c
--- /dev/null
+++ b/src/libstd/owned.rs
@@ -0,0 +1,101 @@
+// Copyright 2012 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.
+
+//! Operations on unique pointer types
+
+use any::{Any, AnyRefExt};
+use clone::Clone;
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
+use default::Default;
+use intrinsics;
+use mem;
+use raw::TraitObject;
+use result::{Ok, Err, Result};
+
+/// A value that represents the global exchange heap. This is the default
+/// place that the `box` keyword allocates into when no place is supplied.
+///
+/// The following two examples are equivalent:
+///
+///     let foo = box(HEAP) Bar::new(...);
+///     let foo = box Bar::new(...);
+#[lang="exchange_heap"]
+pub static HEAP: () = ();
+
+/// A type that represents a uniquely-owned value.
+#[lang="owned_box"]
+pub struct Box<T>(*T);
+
+impl<T: Default> Default for Box<T> {
+    fn default() -> Box<T> { box Default::default() }
+}
+
+impl<T: Clone> Clone for Box<T> {
+    /// Return a copy of the owned box.
+    #[inline]
+    fn clone(&self) -> Box<T> { box {(**self).clone()} }
+
+    /// Perform copy-assignment from `source` by reusing the existing allocation.
+    #[inline]
+    fn clone_from(&mut self, source: &Box<T>) {
+        (**self).clone_from(&(**source));
+    }
+}
+
+// box pointers
+impl<T:Eq> Eq for Box<T> {
+    #[inline]
+    fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
+    #[inline]
+    fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) }
+}
+impl<T:Ord> Ord for Box<T> {
+    #[inline]
+    fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
+    #[inline]
+    fn le(&self, other: &Box<T>) -> bool { *(*self) <= *(*other) }
+    #[inline]
+    fn ge(&self, other: &Box<T>) -> bool { *(*self) >= *(*other) }
+    #[inline]
+    fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) }
+}
+impl<T: TotalOrd> TotalOrd for Box<T> {
+    #[inline]
+    fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(*other) }
+}
+impl<T: TotalEq> TotalEq for Box<T> {}
+
+/// Extension methods for an owning `Any` trait object
+pub trait AnyOwnExt {
+    /// Returns the boxed value if it is of type `T`, or
+    /// `Err(Self)` if it isn't.
+    fn move<T: 'static>(self) -> Result<Box<T>, Self>;
+}
+
+impl AnyOwnExt for Box<Any> {
+    #[inline]
+    fn move<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
+        if self.is::<T>() {
+            unsafe {
+                // Get the raw representation of the trait object
+                let to: TraitObject =
+                    *mem::transmute::<&Box<Any>, &TraitObject>(&self);
+
+                // Prevent destructor on self being run
+                intrinsics::forget(self);
+
+                // Extract the data pointer
+                Ok(mem::transmute(to.data))
+            }
+        } else {
+            Err(self)
+        }
+    }
+}
diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs
index d23d327d558..90f97e59caa 100644
--- a/src/libstd/rt/rtio.rs
+++ b/src/libstd/rt/rtio.rs
@@ -275,7 +275,8 @@ pub trait RtioFileStream {
 pub trait RtioProcess {
     fn id(&self) -> libc::pid_t;
     fn kill(&mut self, signal: int) -> IoResult<()>;
-    fn wait(&mut self) -> ProcessExit;
+    fn wait(&mut self) -> IoResult<ProcessExit>;
+    fn set_timeout(&mut self, timeout: Option<u64>);
 }
 
 pub trait RtioPipe {
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index cd0445056b2..31a20145306 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -13,7 +13,6 @@
 //! local storage, and logging. Even a 'freestanding' Rust would likely want
 //! to implement this.
 
-use any::AnyOwnExt;
 use cleanup;
 use clone::Clone;
 use comm::Sender;
@@ -24,7 +23,7 @@ use local_data;
 use mem;
 use ops::Drop;
 use option::{Option, Some, None};
-use owned::Box;
+use owned::{AnyOwnExt, Box};
 use prelude::drop;
 use result::{Result, Ok, Err};
 use rt::Runtime;
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 24cf9681ca8..fa4cf8e4427 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -228,25 +228,25 @@ fn canonical_sort(comb: &mut [(char, u8)]) {
 }
 
 #[deriving(Clone)]
-enum NormalizationForm {
-    NFD,
-    NFKD
+enum DecompositionType {
+    Canonical,
+    Compatible
 }
 
-/// External iterator for a string's normalization's characters.
+/// External iterator for a string's decomposition's characters.
 /// Use with the `std::iter` module.
 #[deriving(Clone)]
-pub struct Normalizations<'a> {
-    kind: NormalizationForm,
+pub struct Decompositions<'a> {
+    kind: DecompositionType,
     iter: Chars<'a>,
     buffer: Vec<(char, u8)>,
     sorted: bool
 }
 
-impl<'a> Iterator<char> for Normalizations<'a> {
+impl<'a> Iterator<char> for Decompositions<'a> {
     #[inline]
     fn next(&mut self) -> Option<char> {
-        use unicode::decompose::canonical_combining_class;
+        use unicode::normalization::canonical_combining_class;
 
         match self.buffer.as_slice().head() {
             Some(&(c, 0)) => {
@@ -262,8 +262,8 @@ impl<'a> Iterator<char> for Normalizations<'a> {
         }
 
         let decomposer = match self.kind {
-            NFD => char::decompose_canonical,
-            NFKD => char::decompose_compatible
+            Canonical => char::decompose_canonical,
+            Compatible => char::decompose_compatible
         };
 
         if !self.sorted {
@@ -887,24 +887,24 @@ pub trait StrAllocating: Str {
     /// An Iterator over the string in Unicode Normalization Form D
     /// (canonical decomposition).
     #[inline]
-    fn nfd_chars<'a>(&'a self) -> Normalizations<'a> {
-        Normalizations {
+    fn nfd_chars<'a>(&'a self) -> Decompositions<'a> {
+        Decompositions {
             iter: self.as_slice().chars(),
             buffer: Vec::new(),
             sorted: false,
-            kind: NFD
+            kind: Canonical
         }
     }
 
     /// An Iterator over the string in Unicode Normalization Form KD
     /// (compatibility decomposition).
     #[inline]
-    fn nfkd_chars<'a>(&'a self) -> Normalizations<'a> {
-        Normalizations {
+    fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> {
+        Decompositions {
             iter: self.as_slice().chars(),
             buffer: Vec::new(),
             sorted: false,
-            kind: NFKD
+            kind: Compatible
         }
     }
 }
diff --git a/src/libstd/task.rs b/src/libstd/task.rs
index 2f7b31ae31d..7fb61c29112 100644
--- a/src/libstd/task.rs
+++ b/src/libstd/task.rs
@@ -47,10 +47,11 @@ use rt::local::Local;
 use rt::task::Task;
 use str::{Str, SendStr, IntoMaybeOwned};
 
-#[cfg(test)] use any::{AnyOwnExt, AnyRefExt};
+#[cfg(test)] use any::AnyRefExt;
+#[cfg(test)] use owned::AnyOwnExt;
+#[cfg(test)] use realstd::result::ResultUnwrap;
 #[cfg(test)] use result;
 #[cfg(test)] use str::StrAllocating;
-#[cfg(test)] use realstd::result::ResultUnwrap;
 
 /// Indicates the manner in which a task exited.
 ///
diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs
index be6e5d040a7..03c960e96ff 100644
--- a/src/libstd/unicode.rs
+++ b/src/libstd/unicode.rs
@@ -1,4 +1,4 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// The following code was generated by "src/etc/unicode.py"
+// NOTE: The following code was generated by "src/etc/unicode.py", do not edit directly
 
 #![allow(missing_doc, non_uppercase_statics)]
 
-pub mod decompose {
+pub mod normalization {
     use option::{Some, None};
     use slice::ImmutableVector;