about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-26 20:18:54 -0700
committerbors <bors@rust-lang.org>2013-03-26 20:18:54 -0700
commit5df1aaab9835795bd0ef22d795d57039b703fb21 (patch)
tree1bc265e722323db64eb83673aa1d3b74c8db0472 /src
parent4cb5854d883d275872b16a200a2bfc30c53ccea3 (diff)
parent34c5a09ce3c18874de7150afbf689ce0f94c7c20 (diff)
downloadrust-5df1aaab9835795bd0ef22d795d57039b703fb21.tar.gz
rust-5df1aaab9835795bd0ef22d795d57039b703fb21.zip
auto merge of #5414 : thestinger/rust/option, r=catamorphism
Diffstat (limited to 'src')
-rw-r--r--src/compiletest/compiletest.rc4
-rw-r--r--src/libcore/cell.rs3
-rw-r--r--src/libcore/comm.rs17
-rw-r--r--src/libcore/dlist.rs7
-rw-r--r--src/libcore/option.rs347
-rw-r--r--src/libcore/os.rs15
-rw-r--r--src/libcore/pipes.rs19
-rw-r--r--src/libcore/task/local_data_priv.rs3
-rw-r--r--src/libcore/task/mod.rs7
-rw-r--r--src/libcore/task/spawn.rs15
-rw-r--r--src/libcore/unstable.rs5
-rw-r--r--src/libcore/unstable/weak_task.rs2
-rw-r--r--src/libfuzzer/fuzzer.rc4
-rw-r--r--src/librustc/front/config.rs2
-rw-r--r--src/librustc/metadata/decoder.rs5
-rw-r--r--src/librustc/middle/resolve.rs5
-rw-r--r--src/librustc/middle/trans/monomorphize.rs9
-rw-r--r--src/librustc/middle/trans/type_use.rs3
-rw-r--r--src/librustc/middle/ty.rs10
-rw-r--r--src/librustc/middle/typeck/check/mod.rs3
-rw-r--r--src/librustc/rustc.rc6
-rw-r--r--src/librustdoc/attr_pass.rs8
-rw-r--r--src/librustdoc/doc.rs5
-rw-r--r--src/librustdoc/page_pass.rs3
-rw-r--r--src/libstd/sync.rs11
-rw-r--r--src/libstd/test.rs2
-rw-r--r--src/libsyntax/diagnostic.rs4
-rw-r--r--src/libsyntax/ext/expand.rs4
-rw-r--r--src/libsyntax/fold.rs7
-rw-r--r--src/test/bench/msgsend-ring-mutex-arcs.rs4
-rw-r--r--src/test/bench/msgsend-ring-pipes.rs4
-rw-r--r--src/test/bench/msgsend-ring-rw-arcs.rs4
-rw-r--r--src/test/bench/shootout-k-nucleotide-pipes.rs2
-rw-r--r--src/test/bench/task-perf-linked-failure.rs2
-rw-r--r--src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs2
-rw-r--r--src/test/compile-fail/arc-rw-state-shouldnt-escape.rs2
-rw-r--r--src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs2
-rw-r--r--src/test/compile-fail/issue-2766-a.rs2
-rw-r--r--src/test/compile-fail/issue-3311.rs2
-rw-r--r--src/test/compile-fail/sync-cond-shouldnt-escape.rs4
-rw-r--r--src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs2
-rw-r--r--src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs2
-rw-r--r--src/test/run-pass/issue-2718.rs14
-rw-r--r--src/test/run-pass/stat.rs2
-rw-r--r--src/test/run-pass/task-comm-12.rs2
-rw-r--r--src/test/run-pass/task-comm-9.rs2
-rw-r--r--src/test/run-pass/yield.rs2
-rw-r--r--src/test/run-pass/yield1.rs2
48 files changed, 210 insertions, 383 deletions
diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc
index 0c1f328ad09..738045705a2 100644
--- a/src/compiletest/compiletest.rc
+++ b/src/compiletest/compiletest.rc
@@ -90,9 +90,7 @@ pub fn parse_config(args: ~[~str]) -> config {
              if vec::len(matches.free) > 0u {
                  option::Some(matches.free[0])
              } else { option::None },
-        logfile: option::map(&getopts::opt_maybe_str(matches,
-                                                     ~"logfile"),
-                             |s| Path(*s)),
+        logfile: getopts::opt_maybe_str(matches, ~"logfile").map(|s| Path(*s)),
         runtool: getopts::opt_maybe_str(matches, ~"runtool"),
         rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
         jit: getopts::opt_present(matches, ~"jit"),
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 2c29dbd2e94..72beb4e017d 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -11,7 +11,6 @@
 //! A mutable, nullable memory location
 
 use cast::transmute;
-use option;
 use prelude::*;
 
 /*
@@ -53,7 +52,7 @@ pub impl<T> Cell<T> {
 
         let mut value = None;
         value <-> self.value;
-        return option::unwrap(value);
+        value.unwrap()
     }
 
     /// Returns the value, failing if the cell is full.
diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs
index f749d46bcab..a852b0fb720 100644
--- a/src/libcore/comm.rs
+++ b/src/libcore/comm.rs
@@ -15,8 +15,7 @@ Message passing
 use cast;
 use either::{Either, Left, Right};
 use kinds::Owned;
-use option;
-use option::{Option, Some, None, unwrap};
+use option::{Option, Some, None};
 use uint;
 use unstable;
 use vec;
@@ -126,7 +125,7 @@ fn chan_send<T:Owned>(self: &Chan<T>, x: T) {
     let mut endp = None;
     endp <-> self.endp;
     self.endp = Some(
-        streamp::client::data(unwrap(endp), x))
+        streamp::client::data(endp.unwrap(), x))
 }
 
 impl<T: Owned> GenericSmartChan<T> for Chan<T> {
@@ -139,7 +138,7 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
 fn chan_try_send<T:Owned>(self: &Chan<T>, x: T) -> bool {
     let mut endp = None;
     endp <-> self.endp;
-    match streamp::client::try_data(unwrap(endp), x) {
+    match streamp::client::try_data(endp.unwrap(), x) {
         Some(next) => {
             self.endp = Some(next);
             true
@@ -165,7 +164,7 @@ impl<T: Owned> GenericPort<T> for Port<T> {
 fn port_recv<T:Owned>(self: &Port<T>) -> T {
     let mut endp = None;
     endp <-> self.endp;
-    let streamp::data(x, endp) = recv(unwrap(endp));
+    let streamp::data(x, endp) = recv(endp.unwrap());
     self.endp = Some(endp);
     x
 }
@@ -174,7 +173,7 @@ fn port_recv<T:Owned>(self: &Port<T>) -> T {
 fn port_try_recv<T:Owned>(self: &Port<T>) -> Option<T> {
     let mut endp = None;
     endp <-> self.endp;
-    match try_recv(unwrap(endp)) {
+    match try_recv(endp.unwrap()) {
         Some(streamp::data(x, endp)) => {
             self.endp = Some(endp);
             Some(x)
@@ -312,7 +311,7 @@ fn shared_chan_send<T:Owned>(self: &SharedChan<T>, x: T) {
     do self.with_imm |chan| {
         let mut x = None;
         x <-> xx;
-        chan.send(option::unwrap(x))
+        chan.send(x.unwrap())
     }
 }
 
@@ -326,7 +325,7 @@ fn shared_chan_try_send<T:Owned>(self: &SharedChan<T>, x: T) -> bool {
     do self.with_imm |chan| {
         let mut x = None;
         x <-> xx;
-        chan.try_send(option::unwrap(x))
+        chan.try_send(x.unwrap())
     }
 }
 
@@ -409,7 +408,7 @@ pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> {
 
     if message.is_none() { None }
     else {
-        let oneshot::send(message) = option::unwrap(message);
+        let oneshot::send(message) = message.unwrap();
         Some(message)
     }
 }
diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs
index ff86e8d1ffc..159a79129ee 100644
--- a/src/libcore/dlist.rs
+++ b/src/libcore/dlist.rs
@@ -23,7 +23,6 @@ use iter::BaseIter;
 use kinds::Copy;
 use managed;
 use option::{None, Option, Some};
-use option;
 use vec;
 
 pub type DListLink<T> = Option<@mut DListNode<T>>;
@@ -377,7 +376,7 @@ pub impl<T> DList<T> {
 
     /// Reverse the list's elements in place. O(n).
     fn reverse(@mut self) {
-        do option::while_some(self.hd) |nobe| {
+        do self.hd.while_some |nobe| {
             let next_nobe = nobe.next;
             self.remove(nobe);
             self.make_mine(nobe);
@@ -509,8 +508,8 @@ impl<T> BaseIter<T> for @mut DList<T> {
     */
     fn each(&self, f: &fn(v: &T) -> bool) {
         let mut link = self.peek_n();
-        while option::is_some(&link) {
-            let nobe = option::get(link);
+        while link.is_some() {
+            let nobe = link.get();
             fail_unless!(nobe.linked);
 
             {
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index bb636636953..59c836eba65 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -98,218 +98,6 @@ impl<T: Copy + Add<T,T>> Add<Option<T>, Option<T>> for Option<T> {
     }
 }
 
-#[inline(always)]
-pub fn get<T:Copy>(opt: Option<T>) -> T {
-    /*!
-    Gets the value out of an option
-
-    # Failure
-
-    Fails if the value equals `None`
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged
-    (calling `get` on `None` is akin to dereferencing a null pointer).
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-    */
-
-    match opt {
-      Some(copy x) => return x,
-      None => fail!(~"option::get none")
-    }
-}
-
-#[inline(always)]
-pub fn get_ref<T>(opt: &'r Option<T>) -> &'r T {
-    /*!
-    Gets an immutable reference to the value inside an option.
-
-    # Failure
-
-    Fails if the value equals `None`
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged
-    (calling `get` on `None` is akin to dereferencing a null pointer).
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-     */
-    match *opt {
-        Some(ref x) => x,
-        None => fail!(~"option::get_ref none")
-    }
-}
-
-pub fn get_mut_ref<T>(opt: &'r mut Option<T>) -> &'r mut T {
-    /*!
-    Gets a mutable reference to the value inside an option.
-
-    # Failure
-
-    Fails if the value equals `None`
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged
-    (calling `get` on `None` is akin to dereferencing a null pointer).
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-     */
-    match *opt {
-        Some(ref mut x) => x,
-        None => fail!(~"option::get_mut_ref none")
-    }
-}
-
-#[inline(always)]
-pub fn map<T, U>(opt: &'r Option<T>, f: &fn(x: &'r T) -> U) -> Option<U> {
-    //! Maps a `some` value by reference from one type to another
-
-    match *opt { Some(ref x) => Some(f(x)), None => None }
-}
-
-#[inline(always)]
-pub fn map_consume<T, U>(opt: Option<T>,
-                              f: &fn(v: T) -> U) -> Option<U> {
-    /*!
-     * As `map`, but consumes the option and gives `f` ownership to avoid
-     * copying.
-     */
-    match opt { None => None, Some(v) => Some(f(v)) }
-}
-
-#[inline(always)]
-pub fn chain<T, U>(opt: Option<T>,
-                        f: &fn(t: T) -> Option<U>) -> Option<U> {
-    /*!
-     * Update an optional value by optionally running its content through a
-     * function that returns an option.
-     */
-
-    match opt {
-        Some(t) => f(t),
-        None => None
-    }
-}
-
-#[inline(always)]
-pub fn chain_ref<T, U>(opt: &Option<T>,
-                            f: &fn(x: &T) -> Option<U>) -> Option<U> {
-    /*!
-     * Update an optional value by optionally running its content by reference
-     * through a function that returns an option.
-     */
-
-    match *opt { Some(ref x) => f(x), None => None }
-}
-
-#[inline(always)]
-pub fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
-    /*!
-     * Returns the leftmost Some() value, or None if both are None.
-     */
-    match opta {
-        Some(opta) => Some(opta),
-        _ => optb
-    }
-}
-
-#[inline(always)]
-pub fn while_some<T>(x: Option<T>, blk: &fn(v: T) -> Option<T>) {
-    //! Applies a function zero or more times until the result is none.
-
-    let mut opt = x;
-    while opt.is_some() {
-        opt = blk(unwrap(opt));
-    }
-}
-
-#[inline(always)]
-pub fn is_none<T>(opt: &const Option<T>) -> bool {
-    //! Returns true if the option equals `none`
-
-    match *opt { None => true, Some(_) => false }
-}
-
-#[inline(always)]
-pub fn is_some<T>(opt: &const Option<T>) -> bool {
-    //! Returns true if the option contains some value
-
-    !is_none(opt)
-}
-
-#[inline(always)]
-pub fn get_or_zero<T:Copy + Zero>(opt: Option<T>) -> T {
-    //! Returns the contained value or zero (for this type)
-
-    match opt { Some(copy x) => x, None => Zero::zero() }
-}
-
-#[inline(always)]
-pub fn get_or_default<T:Copy>(opt: Option<T>, def: T) -> T {
-    //! Returns the contained value or a default
-
-    match opt { Some(copy x) => x, None => def }
-}
-
-#[inline(always)]
-pub fn map_default<T, U>(opt: &'r Option<T>, def: U,
-                              f: &fn(&'r T) -> U) -> U {
-    //! Applies a function to the contained value or returns a default
-
-    match *opt { None => def, Some(ref t) => f(t) }
-}
-
-#[inline(always)]
-pub fn unwrap<T>(opt: Option<T>) -> T {
-    /*!
-    Moves a value out of an option type and returns it.
-
-    Useful primarily for getting strings, vectors and unique pointers out
-    of option types without copying them.
-
-    # Failure
-
-    Fails if the value equals `None`.
-
-    # Safety note
-
-    In general, because this function may fail, its use is discouraged.
-    Instead, prefer to use pattern matching and handle the `None`
-    case explicitly.
-     */
-    match opt {
-        Some(x) => x,
-        None => fail!(~"option::unwrap none")
-    }
-}
-
-#[inline(always)]
-pub fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
-    /*!
-    The option dance. Moves a value out of an option type and returns it,
-    replacing the original with `None`.
-
-    # Failure
-
-    Fails if the value equals `None`.
-     */
-    if opt.is_none() { fail!(~"option::swap_unwrap none") }
-    unwrap(util::replace(opt, None))
-}
-
-#[inline(always)]
-pub fn expect<T>(opt: Option<T>, reason: &str) -> T {
-    //! As unwrap, but with a specified failure message.
-    match opt {
-        Some(val) => val,
-        None => fail!(reason.to_owned()),
-    }
-}
-
 impl<T> BaseIter<T> for Option<T> {
     /// Performs an operation on the contained value by reference
     #[inline(always)]
@@ -332,37 +120,64 @@ impl<T> MutableIter<T> for Option<T> {
 
 pub impl<T> Option<T> {
     /// Returns true if the option equals `none`
-    #[inline(always)]
-    fn is_none(&const self) -> bool { is_none(self) }
+    fn is_none(&const self) -> bool {
+        match *self { None => true, Some(_) => false }
+    }
 
     /// Returns true if the option contains some value
     #[inline(always)]
-    fn is_some(&const self) -> bool { is_some(self) }
+    fn is_some(&const self) -> bool { !self.is_none() }
+
+    #[inline(always)]
+    fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> {
+        /*!
+         * Update an optional value by optionally running its content through a
+         * function that returns an option.
+         */
+
+        match self {
+            Some(t) => f(t),
+            None => None
+        }
+    }
+
+    #[inline(always)]
+    fn or(self, optb: Option<T>) -> Option<T> {
+        /*!
+         * Returns the leftmost Some() value, or None if both are None.
+         */
+        match self {
+            Some(opta) => Some(opta),
+            _ => optb
+        }
+    }
 
     /**
      * Update an optional value by optionally running its content by reference
      * through a function that returns an option.
      */
     #[inline(always)]
-    fn chain_ref<U>(&self, f: &fn(x: &T) -> Option<U>) -> Option<U> {
-        chain_ref(self, f)
+    fn chain_ref<U>(&self, f: &fn(x: &'self T) -> Option<U>) -> Option<U> {
+        match *self { Some(ref x) => f(x), None => None }
     }
 
     /// Maps a `some` value from one type to another by reference
     #[inline(always)]
-    fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> { map(self, f) }
+    fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> {
+        match *self { Some(ref x) => Some(f(x)), None => None }
+    }
 
     /// As `map`, but consumes the option and gives `f` ownership to avoid
     /// copying.
     #[inline(always)]
     fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> {
-        map_consume(self, f)
+        match self { None => None, Some(v) => Some(f(v)) }
     }
 
     /// Applies a function to the contained value or returns a default
     #[inline(always)]
     fn map_default<U>(&self, def: U, f: &fn(&'self T) -> U) -> U {
-        map_default(self, def, f)
+        match *self { None => def, Some(ref t) => f(t) }
     }
 
     /// As `map_default`, but consumes the option and gives `f`
@@ -403,7 +218,12 @@ pub impl<T> Option<T> {
     case explicitly.
      */
     #[inline(always)]
-    fn get_ref(&self) -> &'self T { get_ref(self) }
+    fn get_ref(&self) -> &'self T {
+        match *self {
+          Some(ref x) => x,
+          None => fail!(~"option::get_ref none")
+        }
+    }
 
     /**
     Gets a mutable reference to the value inside an option.
@@ -420,17 +240,36 @@ pub impl<T> Option<T> {
     case explicitly.
      */
     #[inline(always)]
-    fn get_mut_ref(&mut self) -> &'self mut T { get_mut_ref(self) }
+    fn get_mut_ref(&mut self) -> &'self mut T {
+        match *self {
+          Some(ref mut x) => x,
+          None => fail!(~"option::get_mut_ref none")
+        }
+    }
 
-    /**
-     * Gets the value out of an option without copying.
-     *
-     * # Failure
-     *
-     * Fails if the value equals `none`
-     */
     #[inline(always)]
-    fn unwrap(self) -> T { unwrap(self) }
+    fn unwrap(self) -> T {
+        /*!
+        Moves a value out of an option type and returns it.
+
+        Useful primarily for getting strings, vectors and unique pointers out
+        of option types without copying them.
+
+        # Failure
+
+        Fails if the value equals `None`.
+
+        # Safety note
+
+        In general, because this function may fail, its use is discouraged.
+        Instead, prefer to use pattern matching and handle the `None`
+        case explicitly.
+         */
+        match self {
+          Some(x) => x,
+          None => fail!(~"option::unwrap none")
+        }
+    }
 
     /**
      * The option dance. Moves a value out of an option type and returns it,
@@ -441,7 +280,10 @@ pub impl<T> Option<T> {
      * Fails if the value equals `None`.
      */
     #[inline(always)]
-    fn swap_unwrap(&mut self) -> T { swap_unwrap(self) }
+    fn swap_unwrap(&mut self) -> T {
+        if self.is_none() { fail!(~"option::swap_unwrap none") }
+        util::replace(self, None).unwrap()
+    }
 
     /**
      * Gets the value out of an option, printing a specified message on
@@ -452,7 +294,12 @@ pub impl<T> Option<T> {
      * Fails if the value equals `none`
      */
     #[inline(always)]
-    fn expect(self, reason: &str) -> T { expect(self, reason) }
+    fn expect(self, reason: &str) -> T {
+        match self {
+          Some(val) => val,
+          None => fail!(reason.to_owned()),
+        }
+    }
 }
 
 pub impl<T:Copy> Option<T> {
@@ -471,21 +318,35 @@ pub impl<T:Copy> Option<T> {
     case explicitly.
     */
     #[inline(always)]
-    fn get(self) -> T { get(self) }
+    fn get(self) -> T {
+        match self {
+          Some(copy x) => return x,
+          None => fail!(~"option::get none")
+        }
+    }
 
+    /// Returns the contained value or a default
     #[inline(always)]
-    fn get_or_default(self, def: T) -> T { get_or_default(self, def) }
+    fn get_or_default(self, def: T) -> T {
+        match self { Some(copy x) => x, None => def }
+    }
 
     /// Applies a function zero or more times until the result is none.
     #[inline(always)]
     fn while_some(self, blk: &fn(v: T) -> Option<T>) {
-        while_some(self, blk)
+        let mut opt = self;
+        while opt.is_some() {
+            opt = blk(opt.unwrap());
+        }
     }
 }
 
 pub impl<T:Copy + Zero> Option<T> {
+    /// Returns the contained value or zero (for this type)
     #[inline(always)]
-    fn get_or_zero(self) -> T { get_or_zero(self) }
+    fn get_or_zero(self) -> T {
+        match self { Some(copy x) => x, None => Zero::zero() }
+    }
 }
 
 #[test]
@@ -493,7 +354,7 @@ fn test_unwrap_ptr() {
     let x = ~0;
     let addr_x = ptr::addr_of(&(*x));
     let opt = Some(x);
-    let y = unwrap(opt);
+    let y = opt.unwrap();
     let addr_y = ptr::addr_of(&(*y));
     fail_unless!(addr_x == addr_y);
 }
@@ -503,7 +364,7 @@ fn test_unwrap_str() {
     let x = ~"test";
     let addr_x = str::as_buf(x, |buf, _len| buf);
     let opt = Some(x);
-    let y = unwrap(opt);
+    let y = opt.unwrap();
     let addr_y = str::as_buf(y, |buf, _len| buf);
     fail_unless!(addr_x == addr_y);
 }
@@ -529,7 +390,7 @@ fn test_unwrap_resource() {
     {
         let x = R(i);
         let opt = Some(x);
-        let _y = unwrap(opt);
+        let _y = opt.unwrap();
     }
     fail_unless!(*i == 1);
 }
@@ -540,7 +401,7 @@ fn test_option_dance() {
     let mut y = Some(5);
     let mut y2 = 0;
     for x.each |_x| {
-        y2 = swap_unwrap(&mut y);
+        y2 = y.swap_unwrap();
     }
     fail_unless!(y2 == 5);
     fail_unless!(y.is_none());
@@ -548,8 +409,8 @@ fn test_option_dance() {
 #[test] #[should_fail] #[ignore(cfg(windows))]
 fn test_option_too_much_dance() {
     let mut y = Some(util::NonCopyable());
-    let _y2 = swap_unwrap(&mut y);
-    let _y3 = swap_unwrap(&mut y);
+    let _y2 = y.swap_unwrap();
+    let _y3 = y.swap_unwrap();
 }
 
 #[test]
diff --git a/src/libcore/os.rs b/src/libcore/os.rs
index 9aa00e8e457..e93888f3eaf 100644
--- a/src/libcore/os.rs
+++ b/src/libcore/os.rs
@@ -517,7 +517,7 @@ pub fn homedir() -> Option<Path> {
 
     #[cfg(windows)]
     fn secondary() -> Option<Path> {
-        do option::chain(getenv(~"USERPROFILE")) |p| {
+        do getenv(~"USERPROFILE").chain |p| {
             if !str::is_empty(p) {
                 Some(Path(p))
             } else {
@@ -555,19 +555,16 @@ pub fn tmpdir() -> Path {
     #[cfg(unix)]
     #[allow(non_implicitly_copyable_typarams)]
     fn lookup() -> Path {
-        option::get_or_default(getenv_nonempty("TMPDIR"),
-                            Path("/tmp"))
+        getenv_nonempty("TMPDIR").get_or_default(Path("/tmp"))
     }
 
     #[cfg(windows)]
     #[allow(non_implicitly_copyable_typarams)]
     fn lookup() -> Path {
-        option::get_or_default(
-                    option::or(getenv_nonempty("TMP"),
-                    option::or(getenv_nonempty("TEMP"),
-                    option::or(getenv_nonempty("USERPROFILE"),
-                               getenv_nonempty("WINDIR")))),
-                    Path("C:\\Windows"))
+        getenv_nonempty("TMP").or(
+            getenv_nonempty("TEMP").or(
+                getenv_nonempty("USERPROFILE").or(
+                   getenv_nonempty("WINDIR")))).get_or_default(Path("C:\\Windows"))
     }
 }
 /// Recursively walk a directory structure
diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index 350a1de629c..ae01a3d57f3 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -87,8 +87,7 @@ use cell::Cell;
 use either::{Either, Left, Right};
 use kinds::Owned;
 use libc;
-use option;
-use option::{None, Option, Some, unwrap};
+use option::{None, Option, Some};
 use unstable::intrinsics;
 use ptr;
 use task;
@@ -465,7 +464,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
         let mut payload = None;
         payload <-> p.payload;
         p.header.state = Empty;
-        return Some(option::unwrap(payload))
+        return Some(payload.unwrap())
       },
       Terminated => return None,
       _ => {}
@@ -523,7 +522,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
                 }
             }
             p.header.state = Empty;
-            return Some(option::unwrap(payload))
+            return Some(payload.unwrap())
           }
           Terminated => {
             // This assert detects when we've accidentally unsafely
@@ -777,7 +776,7 @@ impl<T:Owned,Tbuffer:Owned> ::ops::Drop for SendPacketBuffered<T,Tbuffer> {
         if self.p != None {
             let mut p = None;
             p <-> self.p;
-            sender_terminate(option::unwrap(p))
+            sender_terminate(p.unwrap())
         }
         //unsafe { error!("send_drop: %?",
         //                if self.buffer == none {
@@ -802,7 +801,7 @@ pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
     fn unwrap(&self) -> *Packet<T> {
         let mut p = None;
         p <-> self.p;
-        option::unwrap(p)
+        p.unwrap()
     }
 
     fn header(&self) -> *PacketHeader {
@@ -821,7 +820,7 @@ pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
         //error!("send reuse_buffer");
         let mut tmp = None;
         tmp <-> self.buffer;
-        option::unwrap(tmp)
+        tmp.unwrap()
     }
 }
 
@@ -847,7 +846,7 @@ impl<T:Owned,Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> {
         if self.p != None {
             let mut p = None;
             p <-> self.p;
-            receiver_terminate(option::unwrap(p))
+            receiver_terminate(p.unwrap())
         }
         //unsafe { error!("recv_drop: %?",
         //                if self.buffer == none {
@@ -860,14 +859,14 @@ pub impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
     fn unwrap(&self) -> *Packet<T> {
         let mut p = None;
         p <-> self.p;
-        option::unwrap(p)
+        p.unwrap()
     }
 
     fn reuse_buffer(&self) -> BufferResource<Tbuffer> {
         //error!("recv reuse_buffer");
         let mut tmp = None;
         tmp <-> self.buffer;
-        option::unwrap(tmp)
+        tmp.unwrap()
     }
 }
 
diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs
index 59f4942b3a4..a4fd18ec094 100644
--- a/src/libcore/task/local_data_priv.rs
+++ b/src/libcore/task/local_data_priv.rs
@@ -13,7 +13,6 @@
 use cast;
 use cmp::Eq;
 use libc;
-use option;
 use prelude::*;
 use task::rt;
 use task::local_data::LocalDataKey;
@@ -181,6 +180,6 @@ pub unsafe fn local_modify<T:Durable>(
     // Could be more efficient by doing the lookup work, but this is easy.
     let newdata = modify_fn(local_pop(task, key));
     if newdata.is_some() {
-        local_set(task, key, option::unwrap(newdata));
+        local_set(task, key, newdata.unwrap());
     }
 }
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs
index 349a10bb809..3e980daaa08 100644
--- a/src/libcore/task/mod.rs
+++ b/src/libcore/task/mod.rs
@@ -35,7 +35,6 @@
 
 use cell::Cell;
 use cmp::Eq;
-use option;
 use result::Result;
 use comm::{stream, Chan, GenericChan, GenericPort, Port, SharedChan};
 use prelude::*;
@@ -410,7 +409,7 @@ pub impl TaskBuilder {
         do fr_task_builder.spawn || {
             ch.send(f());
         }
-        match option::unwrap(result).recv() {
+        match result.unwrap().recv() {
             Success => result::Ok(po.recv()),
             Failure => result::Err(())
         }
@@ -839,14 +838,14 @@ fn test_add_wrapper() {
 fn test_future_result() {
     let mut result = None;
     do task().future_result(|+r| { result = Some(r); }).spawn { }
-    fail_unless!(option::unwrap(result).recv() == Success);
+    fail_unless!(result.unwrap().recv() == Success);
 
     result = None;
     do task().future_result(|+r|
         { result = Some(r); }).unlinked().spawn {
         fail!();
     }
-    fail_unless!(option::unwrap(result).recv() == Failure);
+    fail_unless!(result.unwrap().recv() == Failure);
 }
 
 #[test] #[should_fail] #[ignore(cfg(windows))]
diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs
index b97a682c4e5..f353db5ae70 100644
--- a/src/libcore/task/spawn.rs
+++ b/src/libcore/task/spawn.rs
@@ -75,7 +75,6 @@
 use cast;
 use cell::Cell;
 use container::Map;
-use option;
 use comm::{Chan, GenericChan, GenericPort, Port, stream};
 use prelude::*;
 use unstable;
@@ -194,7 +193,7 @@ fn each_ancestor(list:        &mut AncestorList,
         if coalesce_this.is_some() {
             // Needed coalesce. Our next ancestor becomes our old
             // ancestor's next ancestor. ("next = old_next->next;")
-            *list = option::unwrap(coalesce_this);
+            *list = coalesce_this.unwrap();
         } else {
             // No coalesce; restore from tmp. ("next = old_next;")
             *list = tmp_list;
@@ -290,7 +289,7 @@ fn each_ancestor(list:        &mut AncestorList,
         fn with_parent_tg<U>(parent_group: &mut Option<TaskGroupArc>,
                              blk: &fn(TaskGroupInner) -> U) -> U {
             // If this trips, more likely the problem is 'blk' failed inside.
-            let tmp_arc = option::swap_unwrap(&mut *parent_group);
+            let tmp_arc = parent_group.swap_unwrap();
             let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) };
             *parent_group = Some(tmp_arc);
             result
@@ -374,7 +373,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
     let newstate = util::replace(&mut *state, None);
     // If 'None', the group was failing. Can't enlist.
     if newstate.is_some() {
-        let group = option::unwrap(newstate);
+        let group = newstate.unwrap();
         taskset_insert(if is_member { &mut group.members }
                        else         { &mut group.descendants }, me);
         *state = Some(group);
@@ -390,7 +389,7 @@ fn leave_taskgroup(state: TaskGroupInner, me: *rust_task,
     let newstate = util::replace(&mut *state, None);
     // If 'None', already failing and we've already gotten a kill signal.
     if newstate.is_some() {
-        let group = option::unwrap(newstate);
+        let group = newstate.unwrap();
         taskset_remove(if is_member { &mut group.members }
                        else         { &mut group.descendants }, me);
         *state = Some(group);
@@ -414,7 +413,7 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) {
         // That's ok; only one task needs to do the dirty work. (Might also
         // see 'None' if Somebody already failed and we got a kill signal.)
         if newstate.is_some() {
-            let group = option::unwrap(newstate);
+            let group = newstate.unwrap();
             for taskset_each(&group.members) |sibling| {
                 // Skip self - killing ourself won't do much good.
                 if sibling != me {
@@ -519,7 +518,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
         //    None               { ancestor_list(None) }
         let tmp = util::replace(&mut **ancestors, None);
         if tmp.is_some() {
-            let ancestor_arc = option::unwrap(tmp);
+            let ancestor_arc = tmp.unwrap();
             let result = ancestor_arc.clone();
             **ancestors = Some(ancestor_arc);
             AncestorList(Some(result))
@@ -549,7 +548,7 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) {
             let mut notify_chan = if opts.notify_chan.is_none() {
                 None
             } else {
-                Some(option::swap_unwrap(&mut opts.notify_chan))
+                Some(opts.notify_chan.swap_unwrap())
             };
 
             let child_wrapper = make_child_wrapper(new_task, child_tg,
diff --git a/src/libcore/unstable.rs b/src/libcore/unstable.rs
index 6f0c9ba23df..5daccd9f879 100644
--- a/src/libcore/unstable.rs
+++ b/src/libcore/unstable.rs
@@ -12,7 +12,6 @@
 
 use cast;
 use libc;
-use option;
 use comm::{GenericChan, GenericPort};
 use prelude::*;
 use task;
@@ -165,7 +164,7 @@ pub unsafe fn get_shared_mutable_state<T:Owned>(
     unsafe {
         let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
         fail_unless!(ptr.count > 0);
-        let r = cast::transmute(option::get_ref(&ptr.data));
+        let r = cast::transmute(ptr.data.get_ref());
         cast::forget(ptr);
         return r;
     }
@@ -177,7 +176,7 @@ pub unsafe fn get_shared_immutable_state<T:Owned>(
         let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
         fail_unless!(ptr.count > 0);
         // Cast us back into the correct region
-        let r = cast::transmute_region(option::get_ref(&ptr.data));
+        let r = cast::transmute_region(ptr.data.get_ref());
         cast::forget(ptr);
         return r;
     }
diff --git a/src/libcore/unstable/weak_task.rs b/src/libcore/unstable/weak_task.rs
index 7e9742fecbb..1947f294cb3 100644
--- a/src/libcore/unstable/weak_task.rs
+++ b/src/libcore/unstable/weak_task.rs
@@ -22,7 +22,7 @@ use cell::Cell;
 use comm::{GenericSmartChan, stream};
 use comm::{Port, Chan, SharedChan, GenericChan, GenericPort};
 use hashmap::linear::LinearMap;
-use option::{Some, None, swap_unwrap};
+use option::{Some, None};
 use unstable::at_exit::at_exit;
 use unstable::finally::Finally;
 use unstable::global::global_data_clone_create;
diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc
index 3580edb5814..cb9e4a4d7b8 100644
--- a/src/libfuzzer/fuzzer.rc
+++ b/src/libfuzzer/fuzzer.rc
@@ -334,8 +334,8 @@ pub fn check_variants_T<T: Copy>(
 }
 
 pub fn last_part(filename: ~str) -> ~str {
-  let ix = option::get(str::rfind_char(filename, '/'));
-  str::slice(filename, ix + 1u, str::len(filename) - 3u).to_owned()
+    let ix = str::rfind_char(filename, '/').get();
+    str::slice(filename, ix + 1u, str::len(filename) - 3u).to_owned()
 }
 
 pub enum happiness {
diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs
index 39a1fda2c92..2cec6ec5ab1 100644
--- a/src/librustc/front/config.rs
+++ b/src/librustc/front/config.rs
@@ -142,7 +142,7 @@ fn fold_block(
     ast::blk_ {
         view_items: /*bad*/copy b.view_items,
         stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
-        expr: option::map(&b.expr, |x| fld.fold_expr(*x)),
+        expr: b.expr.map(|x| fld.fold_expr(*x)),
         id: b.id,
         rules: b.rules,
     }
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 0e9246eedbc..5f74dcb27ac 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -207,8 +207,7 @@ fn each_reexport(d: ebml::Doc, f: &fn(ebml::Doc) -> bool) {
 
 fn field_mutability(d: ebml::Doc) -> ast::struct_mutability {
     // Use maybe_get_doc in case it's a method
-    option::map_default(
-        &reader::maybe_get_doc(d, tag_struct_mut),
+    reader::maybe_get_doc(d, tag_struct_mut).map_default(
         ast::struct_immutable,
         |d| {
             match reader::doc_as_u8(*d) as char {
@@ -219,7 +218,7 @@ fn field_mutability(d: ebml::Doc) -> ast::struct_mutability {
 }
 
 fn variant_disr_val(d: ebml::Doc) -> Option<int> {
-    do option::chain(reader::maybe_get_doc(d, tag_disr_val)) |val_doc| {
+    do reader::maybe_get_doc(d, tag_disr_val).chain |val_doc| {
         int::parse_bytes(reader::doc_data(val_doc), 10u)
     }
 }
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index f956c8cb10c..bd507f4cf22 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -75,7 +75,6 @@ use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper};
 use syntax::visit::{visit_mod, visit_ty, vt};
 use syntax::opt_vec::OptVec;
 
-use core::option::{Some, get, is_some, is_none};
 use core::str::{connect, each_split_str};
 use core::hashmap::linear::{LinearMap, LinearSet};
 
@@ -2490,7 +2489,7 @@ pub impl Resolver {
 
             debug!("(resolving glob import) writing module resolution \
                     %? into `%s`",
-                   is_none(&mut target_import_resolution.type_target),
+                   target_import_resolution.type_target.is_none(),
                    self.module_to_str(module_));
 
             // Here we merge two import resolutions.
@@ -5163,7 +5162,7 @@ pub impl Resolver {
             if this.main_fns.len() >= 1u {
                 let mut i = 1u;
                 while i < this.main_fns.len() {
-                    let (_, dup_main_span) = option::unwrap(this.main_fns[i]);
+                    let (_, dup_main_span) = this.main_fns[i].unwrap();
                     this.session.span_err(
                         dup_main_span,
                         ~"multiple 'main' functions");
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 659b3f6c7ac..e8c6cf78a18 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -32,7 +32,6 @@ use middle::ty::{FnSig};
 use middle::typeck;
 use util::ppaux::ty_to_str;
 
-use core::option;
 use core::vec;
 use syntax::ast;
 use syntax::ast_map;
@@ -194,8 +193,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
       }
       ast_map::node_variant(ref v, enum_item, _) => {
         let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
-        let this_tv = option::get(vec::find(*tvs, |tv| {
-            tv.id.node == fn_id.node}));
+        let this_tv = vec::find(*tvs, |tv| { tv.id.node == fn_id.node}).get();
         let d = mk_lldecl();
         set_inline_hint(d);
         match (*v).node.kind {
@@ -248,9 +246,8 @@ pub fn monomorphic_fn(ccx: @CrateContext,
         set_inline_hint(d);
         base::trans_tuple_struct(ccx,
                                  /*bad*/copy struct_def.fields,
-                                 option::expect(struct_def.ctor_id,
-                                                ~"ast-mapped tuple struct \
-                                                  didn't have a ctor id"),
+                                 struct_def.ctor_id.expect(~"ast-mapped tuple struct \
+                                                             didn't have a ctor id"),
                                  psubsts,
                                  d);
         d
diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs
index e19afb0d507..cad2a03f7a1 100644
--- a/src/librustc/middle/trans/type_use.rs
+++ b/src/librustc/middle/trans/type_use.rs
@@ -35,7 +35,6 @@ use middle::trans::inline;
 use middle::ty;
 use middle::typeck;
 
-use core::option;
 use core::option::{Some, None, Option};
 use core::uint;
 use core::vec;
@@ -220,7 +219,7 @@ pub fn type_needs_inner(cx: Context,
                 ty::ty_trait(_, _, _) => false,
 
               ty::ty_enum(did, ref substs) => {
-                if option::is_none(&list::find(enums_seen, |id| *id == did)) {
+                if list::find(enums_seen, |id| *id == did).is_none() {
                     let seen = @Cons(did, enums_seen);
                     for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
                         for vec::each(v.args) |aty| {
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index fcbf34dca90..edf76ee7c36 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -30,7 +30,6 @@ use util::common::{indenter};
 use core::cast;
 use core::cmp;
 use core::ops;
-use core::option;
 use core::ptr::to_unsafe_ptr;
 use core::result::Result;
 use core::result;
@@ -3632,11 +3631,10 @@ pub fn impl_traits(cx: ctxt, id: ast::def_id, store: TraitStore) -> ~[t] {
                         _},
                     _)) => {
 
-               do option::map_default(&opt_trait, ~[]) |trait_ref| {
-                       ~[storeify(cx,
-                                  node_id_to_type(cx, trait_ref.ref_id),
-                                  store)]
-                   }
+               do opt_trait.map_default(~[]) |trait_ref| {
+                   ~[storeify(cx, node_id_to_type(cx, trait_ref.ref_id),
+                              store)]
+               }
            }
            _ => ~[]
         }
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index 005b5377b62..17a67838bbe 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -113,7 +113,6 @@ use util::ppaux;
 
 use core::either;
 use core::hashmap::linear::LinearMap;
-use core::option;
 use core::ptr;
 use core::result::{Result, Ok, Err};
 use core::result;
@@ -319,7 +318,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
     debug!("check_fn(arg_tys=%?, ret_ty=%?, self_info.self_ty=%?)",
            arg_tys.map(|a| ppaux::ty_to_str(tcx, *a)),
            ppaux::ty_to_str(tcx, ret_ty),
-           option::map(&self_info, |s| ppaux::ty_to_str(tcx, s.self_ty)));
+           self_info.map(|s| ppaux::ty_to_str(tcx, s.self_ty)));
 
     // ______________________________________________________________________
     // Create the function context.  This is either derived from scratch or,
diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc
index f26a97b48a1..5b4d3be1264 100644
--- a/src/librustc/rustc.rc
+++ b/src/librustc/rustc.rc
@@ -260,10 +260,8 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
     let ofile = getopts::opt_maybe_str(matches, ~"o");
     let ofile = ofile.map(|o| Path(*o));
     let cfg = build_configuration(sess, binary, input);
-    let pretty =
-        option::map(&getopts::opt_default(matches, ~"pretty",
-                                         ~"normal"),
-                    |a| parse_pretty(sess, *a) );
+    let pretty = getopts::opt_default(matches, ~"pretty", "normal").map(
+                    |a| parse_pretty(sess, *a));
     match pretty {
       Some::<pp_mode>(ppm) => {
         pretty_print_input(sess, cfg, input, ppm);
diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs
index 30c8ff6964e..101c11bd58b 100644
--- a/src/librustdoc/attr_pass.rs
+++ b/src/librustdoc/attr_pass.rs
@@ -27,7 +27,6 @@ use fold::Fold;
 use fold;
 use pass::Pass;
 
-use core::option;
 use core::vec;
 use syntax::ast;
 use syntax::ast_map;
@@ -71,8 +70,7 @@ fn fold_crate(
     doc::CrateDoc {
         topmod: doc::ModDoc {
             item: doc::ItemDoc {
-                name: option::get_or_default(copy attrs.name,
-                                             doc.topmod.name()),
+                name: (copy attrs.name).get_or_default(doc.topmod.name()),
                 .. copy doc.topmod.item
             },
             .. copy doc.topmod
@@ -166,10 +164,10 @@ fn fold_enum(
                         ast_map::node_item(@ast::item {
                             node: ast::item_enum(ref enum_definition, _), _
                         }, _) => {
-                            let ast_variant = option::get(
+                            let ast_variant =
                                 vec::find(enum_definition.variants, |v| {
                                     to_str(v.node.name) == variant.name
-                                }));
+                                }).get();
 
                             attr_parser::parse_desc(
                                 copy ast_variant.node.attrs)
diff --git a/src/librustdoc/doc.rs b/src/librustdoc/doc.rs
index 5eecbf58cc6..2d5f60e714b 100644
--- a/src/librustdoc/doc.rs
+++ b/src/librustdoc/doc.rs
@@ -14,7 +14,6 @@ use core::prelude::*;
 
 use doc;
 
-use core::option;
 use core::vec;
 
 pub type AstId = int;
@@ -175,12 +174,12 @@ pub struct IndexEntry {
 
 pub impl Doc {
     fn CrateDoc(&self) -> CrateDoc {
-        option::get(vec::foldl(None, self.pages, |_m, page| {
+        vec::foldl(None, self.pages, |_m, page| {
             match copy *page {
               doc::CratePage(doc) => Some(doc),
               _ => None
             }
-        }))
+        }).get()
     }
 
     fn cratemod(&self) -> ModDoc {
diff --git a/src/librustdoc/page_pass.rs b/src/librustdoc/page_pass.rs
index d5e877de712..49db98e3200 100644
--- a/src/librustdoc/page_pass.rs
+++ b/src/librustdoc/page_pass.rs
@@ -26,7 +26,6 @@ use fold;
 use pass::Pass;
 use util::NominalOp;
 
-use core::option;
 use core::comm::*;
 use syntax::ast;
 
@@ -68,7 +67,7 @@ fn make_doc_from_pages(page_port: &PagePort) -> doc::Doc {
     loop {
         let val = page_port.recv();
         if val.is_some() {
-            pages += ~[option::unwrap(val)];
+            pages += ~[val.unwrap()];
         } else {
             break;
         }
diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs
index 569c67eac93..22ba33ba04e 100644
--- a/src/libstd/sync.rs
+++ b/src/libstd/sync.rs
@@ -15,7 +15,6 @@
  * in std.
  */
 
-use core::option;
 use core::prelude::*;
 use core::unstable::{Exclusive, exclusive};
 use core::ptr;
@@ -119,7 +118,7 @@ pub impl<Q:Owned> Sem<Q> {
         /* for 1000.times { task::yield(); } */
         // Need to wait outside the exclusive.
         if waiter_nobe.is_some() {
-            let _ = comm::recv_one(option::unwrap(waiter_nobe));
+            let _ = comm::recv_one(waiter_nobe.unwrap());
         }
     }
     fn release(&self) {
@@ -235,7 +234,7 @@ pub impl Condvar<'self> {
                             signal_waitqueue(&state.waiters);
                         }
                         // Enqueue ourself to be woken up by a signaller.
-                        let SignalEnd = option::swap_unwrap(&mut SignalEnd);
+                        let SignalEnd = SignalEnd.swap_unwrap();
                         state.blocked[condvar_id].tail.send(SignalEnd);
                     } else {
                         out_of_bounds = Some(vec::len(state.blocked));
@@ -255,7 +254,7 @@ pub impl Condvar<'self> {
             // Unconditionally "block". (Might not actually block if a
             // signaller already sent -- I mean 'unconditionally' in contrast
             // with acquire().)
-            let _ = comm::recv_one(option::swap_unwrap(&mut WaitEnd));
+            let _ = comm::recv_one(WaitEnd.swap_unwrap());
         }
 
         // This is needed for a failing condition variable to reacquire the
@@ -327,7 +326,7 @@ pub impl Condvar<'self> {
             }
         }
         do check_cvar_bounds(out_of_bounds, condvar_id, "cond.signal_on()") {
-            let queue = option::swap_unwrap(&mut queue);
+            let queue = queue.swap_unwrap();
             broadcast_waitqueue(&queue)
         }
     }
@@ -1352,7 +1351,7 @@ mod tests {
         do x.write_downgrade |xwrite| {
             let mut xopt = Some(xwrite);
             do y.write_downgrade |_ywrite| {
-                y.downgrade(option::swap_unwrap(&mut xopt));
+                y.downgrade(xopt.swap_unwrap());
                 error!("oops, y.downgrade(x) should have failed!");
             }
         }
diff --git a/src/libstd/test.rs b/src/libstd/test.rs
index d039e8eef5a..ded4d6fd1b4 100644
--- a/src/libstd/test.rs
+++ b/src/libstd/test.rs
@@ -569,7 +569,7 @@ pub fn run_test(force_ignore: bool,
             task::task().unlinked().future_result(|+r| {
                 result_future = Some(r);
             }).spawn(testfn_cell.take());
-            let task_result = option::unwrap(result_future).recv();
+            let task_result = result_future.unwrap().recv();
             let test_result = calc_result(&desc,
                                           task_result == task::Success);
             monitor_ch.send((desc, test_result));
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index eed36e16754..24360734520 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -15,7 +15,6 @@ use codemap;
 
 use core::io::WriterUtil;
 use core::io;
-use core::option;
 use core::str;
 use core::vec;
 
@@ -294,8 +293,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
 
 fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) {
     for sp.expn_info.each |ei| {
-        let ss = option::map_default(&ei.callee.span, @~"",
-                                     |span| @cm.span_to_str(*span));
+        let ss = ei.callee.span.map_default(@~"", |span| @cm.span_to_str(*span));
         print_diagnostic(*ss, note,
                          fmt!("in expansion of %s!", ei.callee.name));
         let ss = cm.span_to_str(ei.call_site);
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index fb9d96a7831..07ed6b7dfe2 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -22,7 +22,6 @@ use fold::*;
 use parse;
 use parse::{parser, parse_item_from_source_str, new_parser_from_tts};
 
-use core::option;
 use core::vec;
 
 pub fn expand_expr(extsbox: @mut SyntaxEnv,
@@ -294,8 +293,7 @@ pub fn expand_item_mac(+extsbox: @mut SyntaxEnv,
         MRExpr(_) => cx.span_fatal(pth.span,
                                     ~"expr macro in item position: "
                                     + *extname),
-        MRAny(_, item_maker, _) =>
-            option::chain(item_maker(), |i| {fld.fold_item(i)}),
+        MRAny(_, item_maker, _) => item_maker().chain(|i| {fld.fold_item(i)}),
         MRDef(ref mdef) => {
             extsbox.insert(@/*bad*/ copy mdef.name, @SE((*mdef).ext));
             None
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 159b23f4f99..b3974acc674 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -15,7 +15,6 @@ use ast;
 use codemap::{span, spanned};
 use opt_vec::OptVec;
 
-use core::option;
 use core::vec;
 
 pub trait ast_fold {
@@ -298,7 +297,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
 
 fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold)
                 -> @ast::struct_def {
-    let dtor = do option::map(&struct_def.dtor) |dtor| {
+    let dtor = do struct_def.dtor.map |dtor| {
         let dtor_body = fld.fold_block(&dtor.node.body);
         let dtor_id   = fld.new_id(dtor.node.id);
         spanned {
@@ -663,7 +662,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
             })
         }
         struct_variant_kind(struct_def) => {
-            let dtor = do option::map(&struct_def.dtor) |dtor| {
+            let dtor = do struct_def.dtor.map |dtor| {
                 let dtor_body = fld.fold_block(&dtor.node.body);
                 let dtor_id   = fld.new_id(dtor.node.id);
                 spanned {
@@ -679,7 +678,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
                 fields: vec::map(struct_def.fields,
                                  |f| fld.fold_struct_field(*f)),
                 dtor: dtor,
-                ctor_id: option::map(&struct_def.ctor_id, |c| fld.new_id(*c))
+                ctor_id: struct_def.ctor_id.map(|c| fld.new_id(*c))
             })
         }
         enum_variant_kind(ref enum_definition) => {
diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs
index 12060a87850..a1ab7384d62 100644
--- a/src/test/bench/msgsend-ring-mutex-arcs.rs
+++ b/src/test/bench/msgsend-ring-mutex-arcs.rs
@@ -54,8 +54,8 @@ fn thread_ring(i: uint,
     // Send/Receive lots of messages.
     for uint::range(0u, count) |j| {
         //error!("task %?, iter %?", i, j);
-        let mut num_chan2 = option::swap_unwrap(&mut num_chan);
-        let mut num_port2 = option::swap_unwrap(&mut num_port);
+        let mut num_chan2 = num_chan.swap_unwrap();
+        let mut num_port2 = num_port.swap_unwrap();
         send(&num_chan2, i * j);
         num_chan = Some(num_chan2);
         let _n = recv(&num_port2);
diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs
index 56a46d3e006..1fdc826c481 100644
--- a/src/test/bench/msgsend-ring-pipes.rs
+++ b/src/test/bench/msgsend-ring-pipes.rs
@@ -46,8 +46,8 @@ fn thread_ring(i: uint,
         let mut num_port2 = None;
         num_chan2 <-> num_chan;
         num_port2 <-> num_port;
-        num_chan = Some(ring::client::num(option::unwrap(num_chan2), i * j));
-        let port = option::unwrap(num_port2);
+        num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
+        let port = num_port2.unwrap();
         match recv(port) {
           ring::num(_n, p) => {
             //log(error, _n);
diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs
index 57d04abb414..8e819cc4aba 100644
--- a/src/test/bench/msgsend-ring-rw-arcs.rs
+++ b/src/test/bench/msgsend-ring-rw-arcs.rs
@@ -55,8 +55,8 @@ fn thread_ring(i: uint,
     // Send/Receive lots of messages.
     for uint::range(0u, count) |j| {
         //error!("task %?, iter %?", i, j);
-        let mut num_chan2 = option::swap_unwrap(&mut num_chan);
-        let mut num_port2 = option::swap_unwrap(&mut num_port);
+        let mut num_chan2 = num_chan.swap_unwrap();
+        let mut num_port2 = num_port.swap_unwrap();
         send(&num_chan2, i * j);
         num_chan = Some(num_chan2);
         let _n = recv(&num_port2);
diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs
index f4ae799aace..3bc40a46cfb 100644
--- a/src/test/bench/shootout-k-nucleotide-pipes.rs
+++ b/src/test/bench/shootout-k-nucleotide-pipes.rs
@@ -158,7 +158,7 @@ fn main() {
         let sz = *sz;
         let mut stream = None;
         stream <-> streams[ii];
-        let (from_child_, to_parent_) = option::unwrap(stream);
+        let (from_child_, to_parent_) = stream.unwrap();
 
         from_child.push(from_child_);
 
diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs
index de58ae8ab0d..889a2836c0c 100644
--- a/src/test/bench/task-perf-linked-failure.rs
+++ b/src/test/bench/task-perf-linked-failure.rs
@@ -50,7 +50,7 @@ fn spawn_supervised_blocking(myname: &str, +f: ~fn()) {
     let mut res = None;
     task::task().future_result(|+r| res = Some(r)).supervised().spawn(f);
     error!("%s group waiting", myname);
-    let x = option::unwrap(res).recv();
+    let x = res.unwrap().recv();
     fail_unless!(x == task::Success);
 }
 
diff --git a/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs
index 7d74d7039a8..f59eb509156 100644
--- a/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs
+++ b/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs
@@ -17,5 +17,5 @@ fn main() {
     do x.write_cond |_one, cond| {
         y = Some(cond);
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
diff --git a/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
index b9f0fb18c16..22f5a8eac03 100644
--- a/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
+++ b/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
@@ -17,5 +17,5 @@ fn main() {
     do x.write |one| {
         y = Some(one);
     }
-    *option::unwrap(y) = 2;
+    *y.unwrap() = 2;
 }
diff --git a/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs
index 828bd0a4dc6..c8273cb0167 100644
--- a/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs
+++ b/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs
@@ -19,5 +19,5 @@ fn main() {
             y = Some(cond);
         }
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
diff --git a/src/test/compile-fail/issue-2766-a.rs b/src/test/compile-fail/issue-2766-a.rs
index 8ec63ddc634..5e3eb9ef09b 100644
--- a/src/test/compile-fail/issue-2766-a.rs
+++ b/src/test/compile-fail/issue-2766-a.rs
@@ -22,7 +22,7 @@ pub mod stream {
                 //~^ ERROR use of undeclared type name
                 //~^^ ERROR attempt to use a type argument out of scope
                 //~^^^ ERROR use of undeclared type name
-                    option::unwrap(pipes::recv(pipe))
+                    pipes::recv(pipe).unwrap()
                 }
                 recv
             }
diff --git a/src/test/compile-fail/issue-3311.rs b/src/test/compile-fail/issue-3311.rs
index 1b83cefbf33..295b6c989b5 100644
--- a/src/test/compile-fail/issue-3311.rs
+++ b/src/test/compile-fail/issue-3311.rs
@@ -26,6 +26,6 @@ fn bar(s: &str, f: &fn(Option<Foo>)) {
 
 fn main() {
     do bar(~"testing") |opt| {
-        io::println(option::unwrap(opt).get_s()); //~ ERROR illegal borrow:
+        io::println(opt.unwrap().get_s()); //~ ERROR illegal borrow:
     };
 }
diff --git a/src/test/compile-fail/sync-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-cond-shouldnt-escape.rs
index 1fc90f3ba9d..964c2ce946b 100644
--- a/src/test/compile-fail/sync-cond-shouldnt-escape.rs
+++ b/src/test/compile-fail/sync-cond-shouldnt-escape.rs
@@ -17,6 +17,6 @@ fn main() {
     let mut cond = None;
     do m.lock_cond |c| {
         cond = Some(c);
-    }   
-    option::unwrap(cond).signal();
+    }
+    cond.unwrap().signal();
 }
diff --git a/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs
index a02a2758fb9..9cab2d3b056 100644
--- a/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs
+++ b/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs
@@ -17,5 +17,5 @@ fn main() {
     do x.write_cond |cond| {
         y = Some(cond);
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
diff --git a/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs
index 2421209902b..43ad693ccf8 100644
--- a/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs
+++ b/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs
@@ -19,5 +19,5 @@ fn main() {
             y = Some(cond);
         }
     }
-    option::unwrap(y).wait();
+    y.unwrap().wait();
 }
diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs
index cc4f10ca347..3acfa744117 100644
--- a/src/test/run-pass/issue-2718.rs
+++ b/src/test/run-pass/issue-2718.rs
@@ -107,7 +107,7 @@ pub mod pipes {
               full => {
                 let mut payload = None;
                 payload <-> (*p).payload;
-                return Some(option::unwrap(payload))
+                return Some(payload.unwrap())
               }
               terminated => {
                 fail_unless!(old_state == terminated);
@@ -164,7 +164,7 @@ pub mod pipes {
                     let self_p: &mut Option<*packet<T>> =
                         cast::transmute(&self.p);
                     p <-> *self_p;
-                    sender_terminate(option::unwrap(p))
+                    sender_terminate(p.unwrap())
                 }
             }
         }
@@ -174,7 +174,7 @@ pub mod pipes {
         fn unwrap(&mut self) -> *packet<T> {
             let mut p = None;
             p <-> self.p;
-            option::unwrap(p)
+            p.unwrap()
         }
     }
 
@@ -197,7 +197,7 @@ pub mod pipes {
                     let self_p: &mut Option<*packet<T>> =
                         cast::transmute(&self.p);
                     p <-> *self_p;
-                    receiver_terminate(option::unwrap(p))
+                    receiver_terminate(p.unwrap())
                 }
             }
         }
@@ -207,7 +207,7 @@ pub mod pipes {
         fn unwrap(&mut self) -> *packet<T> {
             let mut p = None;
             p <-> self.p;
-            option::unwrap(p)
+            p.unwrap()
         }
     }
 
@@ -275,7 +275,7 @@ pub mod pingpong {
             if packet.is_none() {
                 fail!(~"sender closed the connection")
             }
-            (pingpong::liberate_pong(option::unwrap(packet)), ())
+            (pingpong::liberate_pong(packet.unwrap()), ())
         }
     }
 
@@ -290,7 +290,7 @@ pub mod pingpong {
             if packet.is_none() {
                 fail!(~"sender closed the connection")
             }
-            (pingpong::liberate_ping(option::unwrap(packet)), ())
+            (pingpong::liberate_ping(packet.unwrap()), ())
         }
 
         pub fn do_pong(+c: pong) -> ping {
diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs
index f2e12294b09..6b3a37a9d79 100644
--- a/src/test/run-pass/stat.rs
+++ b/src/test/run-pass/stat.rs
@@ -15,7 +15,7 @@ use core::io::WriterUtil;
 use std::tempfile;
 
 pub fn main() {
-    let dir = option::unwrap(tempfile::mkdtemp(&Path("."), ""));
+    let dir = tempfile::mkdtemp(&Path("."), "").unwrap();
     let path = dir.with_filename("file");
 
     {
diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs
index 9f23ab1c9df..b426212d872 100644
--- a/src/test/run-pass/task-comm-12.rs
+++ b/src/test/run-pass/task-comm-12.rs
@@ -29,7 +29,7 @@ fn test00() {
     }
 
     // Try joining tasks that have already finished.
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 
     debug!("Joined task.");
 }
diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs
index 57e07221c3d..767203a1f63 100644
--- a/src/test/run-pass/task-comm-9.rs
+++ b/src/test/run-pass/task-comm-9.rs
@@ -39,7 +39,7 @@ fn test00() {
         i += 1;
     }
 
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 
     fail_unless!((sum == number_of_messages * (number_of_messages - 1) / 2));
 }
diff --git a/src/test/run-pass/yield.rs b/src/test/run-pass/yield.rs
index 16f43016b8e..75d9979807b 100644
--- a/src/test/run-pass/yield.rs
+++ b/src/test/run-pass/yield.rs
@@ -17,7 +17,7 @@ pub fn main() {
     error!("2");
     task::yield();
     error!("3");
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 }
 
 fn child() {
diff --git a/src/test/run-pass/yield1.rs b/src/test/run-pass/yield1.rs
index ae1271f64e4..51483121f50 100644
--- a/src/test/run-pass/yield1.rs
+++ b/src/test/run-pass/yield1.rs
@@ -14,7 +14,7 @@ pub fn main() {
     task::task().future_result(|+r| { result = Some(r); }).spawn(child);
     error!("1");
     task::yield();
-    option::unwrap(result).recv();
+    result.unwrap().recv();
 }
 
 fn child() { error!("2"); }