From 6e38e334de13d878da91991c4c5e9014a06f93cb Mon Sep 17 00:00:00 2001
From: Brian Anderson <banderson@mozilla.com>
Date: Tue, 11 Dec 2012 12:20:27 -0800
Subject: [PATCH 01/23] Relate the module hierarchy to directory paths in the
 parser

Introduces a temporary 'path2' attribute that will replace 'path' after
a snapshot
---
 src/libsyntax/parse/parser.rs                 | 33 ++++++++++++++++---
 src/test/run-pass/mod_dir_path.rs             | 21 ++++++++++++
 src/test/run-pass/mod_dir_path2.rs            | 22 +++++++++++++
 src/test/run-pass/mod_dir_path3.rs            | 21 ++++++++++++
 src/test/run-pass/mod_dir_path_multi.rs       | 27 +++++++++++++++
 src/test/run-pass/mod_dir_recursive.rs        | 24 ++++++++++++++
 src/test/run-pass/mod_dir_simple.rs           | 20 +++++++++++
 .../mod_dir_simple/load_another_mod.rs        | 11 +++++++
 src/test/run-pass/mod_dir_simple/test.rs      | 11 +++++++
 9 files changed, 186 insertions(+), 4 deletions(-)
 create mode 100644 src/test/run-pass/mod_dir_path.rs
 create mode 100644 src/test/run-pass/mod_dir_path2.rs
 create mode 100644 src/test/run-pass/mod_dir_path3.rs
 create mode 100644 src/test/run-pass/mod_dir_path_multi.rs
 create mode 100644 src/test/run-pass/mod_dir_recursive.rs
 create mode 100644 src/test/run-pass/mod_dir_simple.rs
 create mode 100644 src/test/run-pass/mod_dir_simple/load_another_mod.rs
 create mode 100644 src/test/run-pass/mod_dir_simple/test.rs

diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 79fe50ecd148f..709d1537d4178 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -203,6 +203,7 @@ fn Parser(sess: parse_sess, cfg: ast::crate_cfg,
         strict_keywords: token::strict_keyword_table(),
         reserved_keywords: token::reserved_keyword_table(),
         obsolete_set: std::map::HashMap(),
+        mod_path_stack: ~[],
     }
 }
 
@@ -226,6 +227,8 @@ struct Parser {
     /// The set of seen errors about obsolete syntax. Used to suppress
     /// extra detail when the same error is seen twice
     obsolete_set: HashMap<ObsoleteSyntax, ()>,
+    /// Used to determine the path to externally loaded source files
+    mut mod_path_stack: ~[~str],
 
     drop {} /* do not copy the parser; its state is tied to outside state */
 }
@@ -3041,10 +3044,12 @@ impl Parser {
             let (m, attrs) = self.eval_src_mod(id, outer_attrs, id_span);
             (id, m, Some(move attrs))
         } else {
+            self.push_mod_path(id, outer_attrs);
             self.expect(token::LBRACE);
             let inner_attrs = self.parse_inner_attrs_and_next();
             let m = self.parse_mod_items(token::RBRACE, inner_attrs.next);
             self.expect(token::RBRACE);
+            self.pop_mod_path();
             (id, item_mod(m), Some(inner_attrs.inner))
         };
 
@@ -3081,20 +3086,40 @@ impl Parser {
         }
     }
 
+    fn push_mod_path(id: ident, attrs: ~[ast::attribute]) {
+        let default_path = self.sess.interner.get(id);
+        let file_path = match ::attr::first_attr_value_str_by_name(
+            attrs, ~"path2") {
+
+            Some(ref d) => (*d),
+            None => copy *default_path
+        };
+        self.mod_path_stack.push(file_path)
+    }
+
+    fn pop_mod_path() {
+        self.mod_path_stack.pop();
+    }
+
     fn eval_src_mod(id: ast::ident,
                     outer_attrs: ~[ast::attribute],
                     id_sp: span) -> (ast::item_, ~[ast::attribute]) {
+
         let prefix = Path(self.sess.cm.span_to_filename(copy self.span));
         let prefix = prefix.dir_path();
+        let mod_path = Path(".").push_many(self.mod_path_stack);
         let default_path = self.sess.interner.get(id) + ~".rs";
         let file_path = match ::attr::first_attr_value_str_by_name(
-            outer_attrs, ~"path") {
+            outer_attrs, ~"path2") {
 
-            Some(ref d) => (*d),
-            None => default_path
+            Some(ref d) => mod_path.push(*d),
+            None => match ::attr::first_attr_value_str_by_name(
+                outer_attrs, ~"path") {
+                Some(ref d) => Path(*d),
+                None => mod_path.push(default_path)
+            }
         };
 
-        let file_path = Path(file_path);
         self.eval_src_mod_from_path(prefix, file_path,
                                     outer_attrs, id_sp)
     }
diff --git a/src/test/run-pass/mod_dir_path.rs b/src/test/run-pass/mod_dir_path.rs
new file mode 100644
index 0000000000000..14ad18cd09100
--- /dev/null
+++ b/src/test/run-pass/mod_dir_path.rs
@@ -0,0 +1,21 @@
+// 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.
+
+// xfail-pretty
+// xfail-fast
+
+mod mod_dir_simple {
+    #[path2 = "test.rs"]
+    pub mod syrup;
+}
+
+fn main() {
+    assert mod_dir_simple::syrup::foo() == 10;
+}
diff --git a/src/test/run-pass/mod_dir_path2.rs b/src/test/run-pass/mod_dir_path2.rs
new file mode 100644
index 0000000000000..98ed84ec7075f
--- /dev/null
+++ b/src/test/run-pass/mod_dir_path2.rs
@@ -0,0 +1,22 @@
+// 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.
+
+// xfail-pretty
+// xfail-fast
+
+#[path2 = "mod_dir_simple"]
+mod pancakes {
+    #[path2 = "test.rs"]
+    pub mod syrup;
+}
+
+fn main() {
+    assert pancakes::syrup::foo() == 10;
+}
diff --git a/src/test/run-pass/mod_dir_path3.rs b/src/test/run-pass/mod_dir_path3.rs
new file mode 100644
index 0000000000000..cc11dbe1fbd36
--- /dev/null
+++ b/src/test/run-pass/mod_dir_path3.rs
@@ -0,0 +1,21 @@
+// 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.
+
+// xfail-pretty
+// xfail-fast
+
+#[path2 = "mod_dir_simple"]
+mod pancakes {
+    pub mod test;
+}
+
+fn main() {
+    assert pancakes::test::foo() == 10;
+}
diff --git a/src/test/run-pass/mod_dir_path_multi.rs b/src/test/run-pass/mod_dir_path_multi.rs
new file mode 100644
index 0000000000000..ef6b3be6e45b0
--- /dev/null
+++ b/src/test/run-pass/mod_dir_path_multi.rs
@@ -0,0 +1,27 @@
+// 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.
+
+// xfail-pretty
+// xfail-fast
+
+#[path2 = "mod_dir_simple"]
+mod biscuits {
+    pub mod test;
+}
+
+#[path2 = "mod_dir_simple"]
+mod gravy {
+    pub mod test;
+}
+
+fn main() {
+    assert biscuits::test::foo() == 10;
+    assert gravy::test::foo() == 10;
+}
diff --git a/src/test/run-pass/mod_dir_recursive.rs b/src/test/run-pass/mod_dir_recursive.rs
new file mode 100644
index 0000000000000..b95852f3a31a3
--- /dev/null
+++ b/src/test/run-pass/mod_dir_recursive.rs
@@ -0,0 +1,24 @@
+// 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.
+
+// xfail-pretty
+// xfail-fast
+
+// Testing that the parser for each file tracks its modules
+// and paths independently. The load_another_mod module should
+// not try to reuse the 'mod_dir_simple' path.
+
+mod mod_dir_simple {
+    pub mod load_another_mod;
+}
+
+fn main() {
+    assert mod_dir_simple::load_another_mod::test::foo() == 10;
+}
diff --git a/src/test/run-pass/mod_dir_simple.rs b/src/test/run-pass/mod_dir_simple.rs
new file mode 100644
index 0000000000000..7f07982a65b5a
--- /dev/null
+++ b/src/test/run-pass/mod_dir_simple.rs
@@ -0,0 +1,20 @@
+// 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.
+
+// xfail-pretty
+// xfail-fast
+
+mod mod_dir_simple {
+    pub mod test;
+}
+
+fn main() {
+    assert mod_dir_simple::test::foo() == 10;
+}
diff --git a/src/test/run-pass/mod_dir_simple/load_another_mod.rs b/src/test/run-pass/mod_dir_simple/load_another_mod.rs
new file mode 100644
index 0000000000000..335da61cd4ebb
--- /dev/null
+++ b/src/test/run-pass/mod_dir_simple/load_another_mod.rs
@@ -0,0 +1,11 @@
+// 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.
+
+mod test;
diff --git a/src/test/run-pass/mod_dir_simple/test.rs b/src/test/run-pass/mod_dir_simple/test.rs
new file mode 100644
index 0000000000000..a3c1628725a07
--- /dev/null
+++ b/src/test/run-pass/mod_dir_simple/test.rs
@@ -0,0 +1,11 @@
+// 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.
+
+pub fn foo() -> int { 10 }

From 7d556e18b05dbac67d2c5d17c332b5d44afcb192 Mon Sep 17 00:00:00 2001
From: Brian Anderson <banderson@mozilla.com>
Date: Tue, 11 Dec 2012 15:40:49 -0800
Subject: [PATCH 02/23] Fix deriving for single-variant enums

---
 src/libsyntax/ext/deriving.rs                 | 44 ++++++++++---------
 .../run-pass/deriving-enum-single-variant.rs  |  8 ++++
 2 files changed, 32 insertions(+), 20 deletions(-)
 create mode 100644 src/test/run-pass/deriving-enum-single-variant.rs

diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index f37f1e268ce40..d41e7e3153636 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -698,26 +698,30 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
         };
         other_arms.push(move matching_arm);
 
-        // Create the nonmatching pattern.
-        let nonmatching_pat = @{
-            id: cx.next_id(),
-            node: pat_wild,
-            span: span
-        };
-
-        // Create the nonmatching pattern body.
-        let nonmatching_expr = build::mk_bool(cx, span, !is_eq);
-        let nonmatching_body_block = build::mk_simple_block(cx,
-                                                            span,
-                                                            nonmatching_expr);
-
-        // Create the nonmatching arm.
-        let nonmatching_arm = {
-            pats: ~[ nonmatching_pat ],
-            guard: None,
-            body: move nonmatching_body_block
-        };
-        other_arms.push(move nonmatching_arm);
+        // Maybe generate a non-matching case. If there is only one
+        // variant then there will always be a match.
+        if enum_definition.variants.len() > 1 {
+            // Create the nonmatching pattern.
+            let nonmatching_pat = @{
+                id: cx.next_id(),
+                node: pat_wild,
+                span: span
+            };
+
+            // Create the nonmatching pattern body.
+            let nonmatching_expr = build::mk_bool(cx, span, !is_eq);
+            let nonmatching_body_block = build::mk_simple_block(cx,
+                                                                span,
+                                                                nonmatching_expr);
+
+            // Create the nonmatching arm.
+            let nonmatching_arm = {
+                pats: ~[ nonmatching_pat ],
+                guard: None,
+                body: move nonmatching_body_block
+            };
+            other_arms.push(move nonmatching_arm);
+        }
 
         // Create the self pattern.
         let self_pat = create_enum_variant_pattern(cx,
diff --git a/src/test/run-pass/deriving-enum-single-variant.rs b/src/test/run-pass/deriving-enum-single-variant.rs
new file mode 100644
index 0000000000000..40055a61380e7
--- /dev/null
+++ b/src/test/run-pass/deriving-enum-single-variant.rs
@@ -0,0 +1,8 @@
+type task_id = int;
+
+#[deriving_eq]
+pub enum Task {
+    TaskHandle(task_id)
+}
+
+fn main() { }

From 3ee1adb7ece94da682109707cca6cd08aacb131a Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Tue, 11 Dec 2012 13:47:53 -0800
Subject: [PATCH 03/23] libstd: teach workcache to check freshness.

---
 src/libstd/workcache.rs | 77 +++++++++++++++++++++++++++++++----------
 1 file changed, 59 insertions(+), 18 deletions(-)

diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs
index 2fd085fdb3343..1defca9b20592 100644
--- a/src/libstd/workcache.rs
+++ b/src/libstd/workcache.rs
@@ -118,17 +118,18 @@ struct Database {
 
 impl Database {
     pure fn prepare(_fn_name: &str,
-                    _declared_inputs: &const WorkMap) ->
-        Option<(WorkMap, WorkMap, WorkMap, ~str)> {
+                    _declared_inputs: &const WorkMap,
+                    _declared_outputs: &const WorkMap) ->
+        Option<(WorkMap, WorkMap, ~str)> {
         // XXX: load
         None
     }
     pure fn cache(_fn_name: &str,
-             _declared_inputs: &WorkMap,
-             _declared_outputs: &WorkMap,
-             _discovered_inputs: &WorkMap,
-             _discovered_outputs: &WorkMap,
-             _result: &str) {
+                  _declared_inputs: &WorkMap,
+                  _declared_outputs: &WorkMap,
+                  _discovered_inputs: &WorkMap,
+                  _discovered_outputs: &WorkMap,
+                  _result: &str) {
         // XXX: store
     }
 }
@@ -138,11 +139,19 @@ struct Logger {
     a: ()
 }
 
+impl Logger {
+    pure fn info(i: &str) {
+        unsafe {
+            io::println(~"workcache: " + i.to_owned());
+        }
+    }
+}
+
 struct Context {
     db: @Database,
     logger: @Logger,
     cfg: @json::Object,
-    freshness: LinearMap<~str,~fn(&str,&str)->bool>
+    freshness: LinearMap<~str,@pure fn(&str,&str)->bool>
 }
 
 struct Prep {
@@ -213,25 +222,57 @@ impl Prep {
                                      val.to_owned());
     }
 
+    pure fn is_fresh(cat: &str, kind: &str,
+                     name: &str, val: &str) -> bool {
+        let k = kind.to_owned();
+        let f = (self.ctxt.freshness.get(&k))(name, val);
+        if f {
+            self.ctxt.logger.info(fmt!("%s %s:%s is fresh",
+                                       cat, kind, name));
+        } else {
+            self.ctxt.logger.info(fmt!("%s %s:%s is not fresh",
+                                       cat, kind, name))
+        }
+        return f;
+    }
+
+    pure fn all_fresh(cat: &str, map: WorkMap) -> bool {
+        for map.each |k,v| {
+            if ! self.is_fresh(cat, k.kind, k.name, *v) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     fn exec<T:Send
               Serializable<json::Serializer>
               Deserializable<json::Deserializer>>(
                   @mut self, blk: ~fn(&Exec) -> T) -> Work<T> {
+
         let cached = self.ctxt.db.prepare(self.fn_name,
-                                          &self.declared_inputs);
+                                          &self.declared_inputs,
+                                          &self.declared_outputs);
 
         match move cached {
             None => (),
-            Some((move _decl_out,
-                  move _disc_in,
-                  move _disc_out,
+            Some((move disc_in,
+                  move disc_out,
                   move res)) => {
-                // XXX: check deps for freshness, only return if fresh.
-                let v : T = do io::with_str_reader(res) |rdr| {
-                    let j = result::unwrap(json::from_reader(rdr));
-                    deserialize(&json::Deserializer(move j))
-                };
-                return Work::new(self, move Left(move v));
+
+                if self.all_fresh("declared input",
+                                  self.declared_inputs) &&
+                    self.all_fresh("declared output",
+                                   self.declared_outputs) &&
+                    self.all_fresh("discovered input", disc_in) &&
+                    self.all_fresh("discovered output", disc_out) {
+
+                    let v : T = do io::with_str_reader(res) |rdr| {
+                        let j = result::unwrap(json::from_reader(rdr));
+                        deserialize(&json::Deserializer(move j))
+                    };
+                    return Work::new(self, move Left(move v));
+                }
             }
         }
 

From a55ea48d2bd3b56ce6e8667e8bebc72371f17dd8 Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Tue, 11 Dec 2012 15:19:43 -0800
Subject: [PATCH 04/23] libstd: refactor future, remove with(), remove ~
 indirection.

Conflicts:

	src/libstd/future.rs
---
 src/librustdoc/markdown_writer.rs         |   2 +-
 src/libstd/future.rs                      | 122 ++++++----------------
 src/test/bench/msgsend-ring-mutex-arcs.rs |   2 +-
 src/test/bench/msgsend-ring-pipes.rs      |   2 +-
 src/test/bench/msgsend-ring-rw-arcs.rs    |   2 +-
 5 files changed, 36 insertions(+), 94 deletions(-)

diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs
index e5e22c2d7fa7f..ae4fa5f42c2c8 100644
--- a/src/librustdoc/markdown_writer.rs
+++ b/src/librustdoc/markdown_writer.rs
@@ -283,7 +283,7 @@ pub fn future_writer_factory(
         do task::spawn |move writer_ch| {
             let (writer, future) = future_writer();
             writer_ch.send(move writer);
-            let s = future::get(&future);
+            let s = future.get();
             comm::send(markdown_ch, (page, s));
         }
         writer_po.recv()
diff --git a/src/libstd/future.rs b/src/libstd/future.rs
index e0aed60e80300..960098c1db626 100644
--- a/src/libstd/future.rs
+++ b/src/libstd/future.rs
@@ -8,11 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// NB: transitionary, de-mode-ing.
-// tjc: allowing deprecated modes due to function issue.
-// can re-forbid them after snapshot
-#[forbid(deprecated_pattern)];
-
 /*!
  * A type representing values that may be computed concurrently and
  * operations for working with them.
@@ -44,27 +39,42 @@ impl<A> Future<A> : Drop {
 priv enum FutureState<A> {
     Pending(fn~() -> A),
     Evaluating,
-    Forced(~A)
+    Forced(A)
 }
 
 /// Methods on the `future` type
 impl<A:Copy> Future<A> {
     fn get() -> A {
         //! Get the value of the future
-
-        get(&self)
+        *(self.get_ref())
     }
 }
 
 impl<A> Future<A> {
-    fn get_ref(&self) -> &self/A {
-        get_ref(self)
-    }
-
-    fn with<B>(blk: fn(&A) -> B) -> B {
-        //! Work with the value without copying it
 
-        with(&self, blk)
+    pure fn get_ref(&self) -> &self/A {
+        /*!
+        * Executes the future's closure and then returns a borrowed
+        * pointer to the result.  The borrowed pointer lasts as long as
+        * the future.
+        */
+        unsafe {
+            match self.state {
+                Forced(ref mut v) => { return cast::transmute(v); }
+                Evaluating => fail ~"Recursive forcing of future!",
+                Pending(_) => {}
+            }
+
+            let mut state = Evaluating;
+            self.state <-> state;
+            match move state {
+                Forced(_) | Evaluating => fail ~"Logic error.",
+                Pending(move f) => {
+                    self.state = Forced(move f());
+                    self.get_ref()
+                }
+            }
+        }
     }
 }
 
@@ -76,7 +86,7 @@ pub fn from_value<A>(val: A) -> Future<A> {
      * not block.
      */
 
-    Future {state: Forced(~(move val))}
+    Future {state: Forced(move val)}
 }
 
 pub fn from_port<A:Send>(port: PortOne<A>) ->
@@ -130,62 +140,12 @@ pub fn spawn<A:Send>(blk: fn~() -> A) -> Future<A> {
     return from_port(move port);
 }
 
-pub fn get_ref<A>(future: &r/Future<A>) -> &r/A {
-    /*!
-     * Executes the future's closure and then returns a borrowed
-     * pointer to the result.  The borrowed pointer lasts as long as
-     * the future.
-     */
-
-    // The unsafety here is to hide the aliases from borrowck, which
-    // would otherwise be concerned that someone might reassign
-    // `future.state` and cause the value of the future to be freed.
-    // But *we* know that once `future.state` is `Forced()` it will
-    // never become "unforced"---so we can safely return a pointer
-    // into the interior of the Forced() variant which will last as
-    // long as the future itself.
-
-    match future.state {
-      Forced(ref v) => { // v here has type &A, but with a shorter lifetime.
-        return unsafe{ copy_lifetime(future, &**v) }; // ...extend it.
-      }
-      Evaluating => {
-        fail ~"Recursive forcing of future!";
-      }
-      Pending(_) => {}
-    }
-
-    let mut state = Evaluating;
-    state <-> future.state;
-    match move state {
-      Forced(_) | Evaluating => {
-        fail ~"Logic error.";
-      }
-      Pending(move f) => {
-        future.state = Forced(~f());
-        return get_ref(future);
-      }
-    }
-}
-
-pub fn get<A:Copy>(future: &Future<A>) -> A {
-    //! Get the value of the future
-
-    *get_ref(future)
-}
-
-pub fn with<A,B>(future: &Future<A>, blk: fn(&A) -> B) -> B {
-    //! Work with the value without copying it
-
-    blk(get_ref(future))
-}
-
 #[allow(non_implicitly_copyable_typarams)]
 pub mod test {
     #[test]
     pub fn test_from_value() {
         let f = from_value(~"snail");
-        assert get(&f) == ~"snail";
+        assert f.get() == ~"snail";
     }
 
     #[test]
@@ -193,13 +153,13 @@ pub mod test {
         let (ch, po) = oneshot::init();
         send_one(move ch, ~"whale");
         let f = from_port(move po);
-        assert get(&f) == ~"whale";
+        assert f.get() == ~"whale";
     }
 
     #[test]
     pub fn test_from_fn() {
         let f = from_fn(|| ~"brail");
-        assert get(&f) == ~"brail";
+        assert f.get() == ~"brail";
     }
 
     #[test]
@@ -208,34 +168,16 @@ pub mod test {
         assert f.get() == ~"fail";
     }
 
-    #[test]
-    pub fn test_with() {
-        let f = from_value(~"nail");
-        assert with(&f, |v| copy *v) == ~"nail";
-    }
-
     #[test]
     pub fn test_get_ref_method() {
         let f = from_value(22);
         assert *f.get_ref() == 22;
     }
 
-    #[test]
-    pub fn test_get_ref_fn() {
-        let f = from_value(22);
-        assert *get_ref(&f) == 22;
-    }
-
-    #[test]
-    pub fn test_interface_with() {
-        let f = from_value(~"kale");
-        assert f.with(|v| copy *v) == ~"kale";
-    }
-
     #[test]
     pub fn test_spawn() {
         let f = spawn(|| ~"bale");
-        assert get(&f) == ~"bale";
+        assert f.get() == ~"bale";
     }
 
     #[test]
@@ -243,7 +185,7 @@ pub mod test {
     #[ignore(cfg(target_os = "win32"))]
     pub fn test_futurefail() {
         let f = spawn(|| fail);
-        let _x: ~str = get(&f);
+        let _x: ~str = f.get();
     }
 
     #[test]
@@ -251,7 +193,7 @@ pub mod test {
         let expected = ~"schlorf";
         let f = do spawn |copy expected| { copy expected };
         do task::spawn |move f, move expected| {
-            let actual = get(&f);
+            let actual = f.get();
             assert actual == expected;
         }
     }
diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs
index 3bd00c647311a..5e1ac20f5eb9f 100644
--- a/src/test/bench/msgsend-ring-mutex-arcs.rs
+++ b/src/test/bench/msgsend-ring-mutex-arcs.rs
@@ -107,7 +107,7 @@ fn main() {
     thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port);
 
     // synchronize
-    for futures.each |f| { future::get(f) };
+    for futures.each |f| { f.get() };
 
     let stop = time::precise_time_s();
 
diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs
index 8ad7ee033ed14..e9281a0c41736 100644
--- a/src/test/bench/msgsend-ring-pipes.rs
+++ b/src/test/bench/msgsend-ring-pipes.rs
@@ -101,7 +101,7 @@ fn main() {
     thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port);
 
     // synchronize
-    for futures.each |f| { future::get(f) };
+    for futures.each |f| { f.get() };
 
     let stop = time::precise_time_s();
 
diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs
index 0432364c791b1..ff88eea598dfb 100644
--- a/src/test/bench/msgsend-ring-rw-arcs.rs
+++ b/src/test/bench/msgsend-ring-rw-arcs.rs
@@ -108,7 +108,7 @@ fn main() {
     thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port);
 
     // synchronize
-    for futures.each |f| { future::get(f) };
+    for futures.each |f| { f.get() };
 
     let stop = time::precise_time_s();
 

From 76dc7818eae05dab94429a61c95a400a2b85c2fe Mon Sep 17 00:00:00 2001
From: Huon Wilson <dbau.pp+github@gmail.com>
Date: Mon, 10 Dec 2012 03:29:33 +0100
Subject: [PATCH 05/23] libstd: Implement read_managed_str for the JSON
 deserialiser.

The FIXME is an underlying issue (a core::at_str library) that this
doesn't address.
---
 src/libstd/json.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/libstd/json.rs b/src/libstd/json.rs
index eb96e074a8258..70bffb215878e 100644
--- a/src/libstd/json.rs
+++ b/src/libstd/json.rs
@@ -782,8 +782,11 @@ pub impl Deserializer: serialization::Deserializer {
     }
 
     fn read_managed_str(&self) -> @str {
-        // FIXME(#3604): There's no way to convert from a ~str to a @str.
-        fail ~"read_managed_str()";
+        debug!("read_managed_str");
+        match *self.pop() {
+            String(ref s) => s.to_managed(),
+            _ => fail ~"not a string"
+        }
     }
 
     fn read_owned<T>(&self, f: fn() -> T) -> T {

From 35209cb9ec1ed743dfbee9854d6a53500e6bf0ff Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Tue, 11 Dec 2012 16:04:35 -0800
Subject: [PATCH 06/23] fix long line, r=tidypolice.

---
 src/libsyntax/ext/deriving.rs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index d41e7e3153636..434c00e7487eb 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -710,9 +710,10 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
 
             // Create the nonmatching pattern body.
             let nonmatching_expr = build::mk_bool(cx, span, !is_eq);
-            let nonmatching_body_block = build::mk_simple_block(cx,
-                                                                span,
-                                                                nonmatching_expr);
+            let nonmatching_body_block =
+                build::mk_simple_block(cx,
+                                       span,
+                                       nonmatching_expr);
 
             // Create the nonmatching arm.
             let nonmatching_arm = {

From 6439f2d54645915ce57f4c229811719e8e498151 Mon Sep 17 00:00:00 2001
From: Tim Chevalier <chevalier@alum.wellesley.edu>
Date: Tue, 11 Dec 2012 13:10:30 -0800
Subject: [PATCH 07/23] Avoid extra error for type mismatches in patterns

When a type error has already occurred, don't call ty::subst,
which may ICE due to the mismatch in the number of type params
involved.

I'm deeming this too small to review.

Closes #3680
---
 src/librustc/middle/typeck/check/alt.rs | 11 ++++++++++-
 src/test/compile-fail/issue-3680.rs     |  3 +--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/librustc/middle/typeck/check/alt.rs b/src/librustc/middle/typeck/check/alt.rs
index 19f3fad071089..ec39c659cf59c 100644
--- a/src/librustc/middle/typeck/check/alt.rs
+++ b/src/librustc/middle/typeck/check/alt.rs
@@ -95,7 +95,16 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
                 let vinfo =
                     ty::enum_variant_with_id(
                         tcx, v_def_ids.enm, v_def_ids.var);
-                vinfo.args.map(|t| { ty::subst(tcx, expected_substs, *t) })
+                let var_tpt = ty::lookup_item_type(tcx, v_def_ids.var);
+                vinfo.args.map(|t| {
+                    if var_tpt.bounds.len() == expected_substs.tps.len() {
+                        ty::subst(tcx, expected_substs, *t)
+                    }
+                    else {
+                        *t // In this case, an error was already signaled
+                           // anyway
+                    }
+                })
             };
 
             kind_name = "variant";
diff --git a/src/test/compile-fail/issue-3680.rs b/src/test/compile-fail/issue-3680.rs
index 1f212889100a2..9044c6b6d79b5 100644
--- a/src/test/compile-fail/issue-3680.rs
+++ b/src/test/compile-fail/issue-3680.rs
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test
-fn f() {
+fn main() {
     match None {
             Err(_) => () //~ ERROR expected `core::result
     }

From a7159be24a9c81517a46e09c7ff62cadc72759b6 Mon Sep 17 00:00:00 2001
From: Brian Anderson <banderson@mozilla.com>
Date: Tue, 11 Dec 2012 16:41:43 -0800
Subject: [PATCH 08/23] Remove old deriving

---
 src/librustc/middle/trans/base.rs             |  46 --
 src/librustc/middle/trans/callee.rs           |   2 -
 src/librustc/middle/trans/deriving.rs         | 473 ------------------
 src/librustc/middle/ty.rs                     |  31 --
 src/librustc/middle/typeck/coherence.rs       | 113 +----
 src/librustc/middle/typeck/deriving.rs        | 322 ------------
 src/librustc/middle/typeck/mod.rs             |   2 -
 src/librustc/rustc.rc                         |   2 -
 .../compile-fail/enum-deriving-incomplete.rs  |  35 --
 src/test/run-pass/deriving-generic-bounded.rs |  44 --
 src/test/run-pass/deriving-one-method.rs      |  35 --
 src/test/run-pass/deriving-override.rs        |  36 --
 .../run-pass/deriving-param-pass-through.rs   |  41 --
 src/test/run-pass/deriving-returning-nil.rs   |  51 --
 src/test/run-pass/deriving-simple.rs          |  43 --
 src/test/run-pass/enum-deriving-simple.rs     |  43 --
 16 files changed, 17 insertions(+), 1302 deletions(-)
 delete mode 100644 src/librustc/middle/trans/deriving.rs
 delete mode 100644 src/librustc/middle/typeck/deriving.rs
 delete mode 100644 src/test/compile-fail/enum-deriving-incomplete.rs
 delete mode 100644 src/test/run-pass/deriving-generic-bounded.rs
 delete mode 100644 src/test/run-pass/deriving-one-method.rs
 delete mode 100644 src/test/run-pass/deriving-override.rs
 delete mode 100644 src/test/run-pass/deriving-param-pass-through.rs
 delete mode 100644 src/test/run-pass/deriving-returning-nil.rs
 delete mode 100644 src/test/run-pass/deriving-simple.rs
 delete mode 100644 src/test/run-pass/enum-deriving-simple.rs

diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 3922ba55b9d40..cf6207dee588a 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -52,7 +52,6 @@ use util::ppaux;
 use util::ppaux::{ty_to_str, ty_to_short_str};
 use syntax::diagnostic::expect;
 use util::common::indenter;
-use ty::DerivedMethodInfo;
 
 use build::*;
 use shape::*;
@@ -1878,10 +1877,6 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
         }
       }
       ast::item_impl(tps, _, _, ms) => {
-        // This call will do nothing if there are no derivable methods.
-        deriving::trans_deriving_impl(ccx, *path, item.ident, tps,
-                                      item.id);
-
         meth::trans_impl(ccx, *path, item.ident, ms, tps, None,
                          item.id);
       }
@@ -2112,20 +2107,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
     match ccx.item_vals.find(id) {
       Some(v) => v,
       None => {
-        // First, check whether we need to automatically generate a method
-        // via the deriving mechanism.
-        match ccx.tcx.automatically_derived_methods.find(local_def(id)) {
-            None => {}  // Continue.
-            Some(ref derived_method_info) => {
-                // XXX: Mark as internal if necessary.
-                let llfn = register_deriving_method(
-                    ccx, id, derived_method_info);
-                ccx.item_vals.insert(id, llfn);
-                return llfn;
-            }
-        }
 
-        // Failing that, look for an item.
         let mut exprt = false;
         let val = match ccx.tcx.items.get(id) {
           ast_map::node_item(i, pth) => {
@@ -2273,34 +2255,6 @@ fn register_method(ccx: @crate_ctxt, id: ast::node_id, pth: @ast_map::path,
     llfn
 }
 
-fn register_deriving_method(ccx: @crate_ctxt,
-                            id: ast::node_id,
-                            derived_method_info: &DerivedMethodInfo) ->
-                            ValueRef {
-    // Find the path of the item.
-    let path, span;
-    match ccx.tcx.items.get(derived_method_info.containing_impl.node) {
-        ast_map::node_item(item, found_path) => {
-            path = found_path;
-            span = item.span;
-        }
-        _ => {
-            ccx.tcx.sess.bug(~"derived method info containing impl didn't \
-                               refer to an item");
-        }
-    }
-
-    let path = vec::append(*path, ~[
-        ast_map::path_mod(
-            ccx.sess.parse_sess.interner.intern(@fmt!("__derived%d__", id))),
-        ast_map::path_name(derived_method_info.method_info.ident)
-    ]);
-    let mty = ty::lookup_item_type(ccx.tcx, local_def(id)).ty;
-    let llfn = register_fn_full(ccx, span, path, id, mty);
-    // XXX: Inline hint.
-    llfn
-}
-
 // The constant translation pass.
 fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
     let _icx = ccx.insn_ctxt("trans_constant");
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index 13064a3eab25e..50bf0cf39c889 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -223,8 +223,6 @@ fn trans_fn_ref_with_vtables(
     let must_monomorphise;
     if type_params.len() > 0 || opt_impl_did.is_some() {
         must_monomorphise = true;
-    } else if ccx.tcx.automatically_derived_methods.contains_key(def_id) {
-        must_monomorphise = false;
     } else if def_id.crate == ast::local_crate {
         let map_node = session::expect(
             ccx.sess,
diff --git a/src/librustc/middle/trans/deriving.rs b/src/librustc/middle/trans/deriving.rs
deleted file mode 100644
index 1259ab6ccf741..0000000000000
--- a/src/librustc/middle/trans/deriving.rs
+++ /dev/null
@@ -1,473 +0,0 @@
-// 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.
-
-// Translation of automatically-derived trait implementations. This handles
-// enums and structs only; other types cannot be automatically derived.
-
-use lib::llvm::llvm::{LLVMCountParams, LLVMGetParam};
-use middle::trans::base::{GEP_enum, finish_fn, get_insn_ctxt, get_item_val};
-use middle::trans::base::{new_fn_ctxt, sub_block, top_scope_block};
-use middle::trans::base;
-use middle::trans::build::{AddCase, Br, CondBr, GEPi, Load, PointerCast};
-use middle::trans::build::{Store, Switch, Unreachable, ValueRef};
-use middle::trans::callee;
-use middle::trans::callee::{ArgVals, Callee, DontAutorefArg, Method};
-use middle::trans::callee::{MethodData};
-use middle::trans::common;
-use middle::trans::common::{C_bool, C_int, T_ptr, block, crate_ctxt};
-use middle::trans::common::{fn_ctxt};
-use middle::trans::expr::SaveIn;
-use middle::trans::type_of::type_of;
-use middle::ty::{DerivedFieldInfo, re_static};
-use middle::typeck::check::method;
-use middle::typeck::method_static;
-use syntax::ast;
-use syntax::ast::{def_id, ident, node_id, ty_param};
-use syntax::ast_map::path;
-use syntax::ast_util;
-use syntax::ast_util::local_def;
-
-use core::dvec::DVec;
-use core::dvec;
-use core::libc::c_uint;
-
-/// The kind of deriving method this is.
-enum DerivingKind {
-    BoolKind,   // fn f(&self, other: &other) -> bool
-    UnitKind,   // fn f(&self) -> ()
-}
-
-impl DerivingKind {
-    static fn of_item(ccx: @crate_ctxt, method_did: ast::def_id)
-                   -> DerivingKind {
-        let item_type = ty::lookup_item_type(ccx.tcx, method_did).ty;
-        match ty::get(item_type).sty {
-            ty::ty_fn(ref f) => {
-                match ty::get(f.sig.output).sty {
-                    ty::ty_bool => BoolKind,
-                    ty::ty_nil => UnitKind,
-                    _ => {
-                        // FIXME (#3957): Report this earlier.
-                        ccx.tcx.sess.fatal(~"attempt to automatically derive \
-                                             derive an implementation of a \
-                                             function returning something \
-                                             other than bool or ()");
-                    }
-                }
-            }
-            _ => {
-                ccx.tcx.sess.bug(~"DerivingKind::of_item(): method def ID \
-                                   didn't have a function type");
-            }
-        }
-    }
-}
-
-/// The main "translation" pass for the automatically-derived methods in
-/// an impl. Generates code for monomorphic methods only. Other methods will
-/// be generated when they are invoked with specific type parameters; see
-/// `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
-pub fn trans_deriving_impl(ccx: @crate_ctxt,
-                           _path: path,
-                           _name: ident,
-                           tps: ~[ty_param],
-                           id: node_id) {
-    let _icx = ccx.insn_ctxt("deriving::trans_deriving_impl");
-    if tps.len() > 0 { return; }
-
-    let impl_def_id = local_def(id);
-    let self_ty = ty::lookup_item_type(ccx.tcx, impl_def_id);
-
-    match ccx.tcx.automatically_derived_methods_for_impl.find(impl_def_id) {
-        Some(copy method_dids) => {
-            for method_dids.each |method_did| {
-                let kind = DerivingKind::of_item(ccx, *method_did);
-                let llfn = get_item_val(ccx, method_did.node);
-
-                // Transform the self type as appropriate.
-                let derived_method_info =
-                    ccx.tcx.automatically_derived_methods.get(*method_did);
-                let transformed_self_ty =
-                    method::transform_self_type_for_method(
-                        ccx.tcx,
-                        Some(re_static),
-                        self_ty.ty,
-                        derived_method_info.method_info.self_type);
-
-                match ty::get(self_ty.ty).sty {
-                    ty::ty_struct(*) => {
-                        trans_deriving_struct_method(ccx,
-                                                     llfn,
-                                                     impl_def_id,
-                                                     self_ty.ty,
-                                                     transformed_self_ty,
-                                                     kind);
-                    }
-                    ty::ty_enum(*) => {
-                        trans_deriving_enum_method(ccx,
-                                                   llfn,
-                                                   impl_def_id,
-                                                   self_ty.ty,
-                                                   transformed_self_ty,
-                                                   kind);
-                    }
-                    _ => {
-                        ccx.tcx.sess.bug(~"translation of non-struct \
-                                           deriving method");
-                    }
-                }
-            }
-        }
-        None => {}  // Nothing to do.
-    }
-}
-
-fn get_extra_params(llfn: ValueRef, kind: DerivingKind) -> ~[ValueRef] {
-    let n_params = LLVMCountParams(llfn) as uint;
-
-    let initial_extra_param;
-    match kind {
-        BoolKind => initial_extra_param = 3,
-        UnitKind => initial_extra_param = 2,
-    }
-
-    let extra_params = DVec();
-    for uint::range(initial_extra_param, n_params) |i| {
-        extra_params.push(LLVMGetParam(llfn, i as c_uint));
-    }
-
-    return dvec::unwrap(move extra_params);
-}
-
-fn trans_deriving_struct_method(ccx: @crate_ctxt,
-                                llfn: ValueRef,
-                                impl_did: def_id,
-                                self_ty: ty::t,
-                                transformed_self_ty: ty::t,
-                                kind: DerivingKind) {
-    let _icx = ccx.insn_ctxt("trans_deriving_struct_method");
-    let fcx = new_fn_ctxt(ccx, ~[], llfn, None);
-    let top_bcx = top_scope_block(fcx, None);
-    let lltop = top_bcx.llbb;
-    let mut bcx = top_bcx;
-
-    let llextraparams = get_extra_params(llfn, kind);
-
-    let lltransformedselfty = type_of(ccx, transformed_self_ty);
-    let lltransformedselfval =
-        PointerCast(bcx, fcx.llenv, T_ptr(lltransformedselfty));
-    let llselfval = Load(bcx, lltransformedselfval);
-
-    // If there is an "other" value, then get it. The "other" value is the
-    // value we're comparing against in the case of Eq and Ord.
-    let llotherval_opt;
-    match kind {
-        BoolKind => llotherval_opt = Some(LLVMGetParam(llfn, 2)),
-        UnitKind => llotherval_opt = None
-    }
-
-    let struct_field_tys;
-    match ty::get(self_ty).sty {
-        ty::ty_struct(struct_id, ref struct_substs) => {
-            struct_field_tys = ty::struct_fields(
-                ccx.tcx, struct_id, struct_substs);
-        }
-        _ => {
-            ccx.tcx.sess.bug(~"passed non-struct to \
-                               trans_deriving_struct_method");
-        }
-    }
-
-    // Iterate over every element of the struct.
-    for ccx.tcx.deriving_struct_methods.get(impl_did).eachi
-            |i, derived_method_info| {
-        let llselfval = GEPi(bcx, llselfval, [0, 0, i]);
-        let llselfallocaty = common::val_ty(llselfval);
-        let llselfalloca = base::alloca(bcx, llselfallocaty);
-        Store(bcx, llselfval, llselfalloca);
-
-        let llotherval_opt = llotherval_opt.map(
-            |llotherval| GEPi(bcx, *llotherval, [0, 0, i]));
-
-        let self_ty = struct_field_tys[i].mt.ty;
-        bcx = call_substructure_method(bcx,
-                                       derived_method_info,
-                                       self_ty,
-                                       llselfalloca,
-                                       llotherval_opt,
-                                       llextraparams);
-
-        // If this derived method is of boolean kind, return immediately if
-        // the call to the substructure method returned false.
-        match kind {
-            BoolKind => {
-                let next_block = sub_block(top_bcx, ~"next");
-                let llcond = Load(bcx, fcx.llretptr);
-                CondBr(bcx, llcond, next_block.llbb, fcx.llreturn);
-                bcx = next_block;
-            }
-            UnitKind => {}  // Unconditionally continue.
-        }
-    }
-
-    // Store true if necessary.
-    match kind {
-        BoolKind => Store(bcx, C_bool(true), fcx.llretptr),
-        UnitKind => {}
-    }
-
-    Br(bcx, fcx.llreturn);
-
-    finish_fn(fcx, lltop);
-}
-
-// This could have been combined with trans_deriving_struct_method, but it
-// would probably be too big and hard to understand.
-fn trans_deriving_enum_method(ccx: @crate_ctxt,
-                              llfn: ValueRef,
-                              impl_did: def_id,
-                              self_ty: ty::t,
-                              transformed_self_ty: ty::t,
-                              kind: DerivingKind) {
-    let _icx = ccx.insn_ctxt("trans_deriving_enum_method");
-    let fcx = new_fn_ctxt(ccx, ~[], llfn, None);
-    let top_bcx = top_scope_block(fcx, None);
-    let lltop = top_bcx.llbb;
-    let mut bcx = top_bcx;
-
-    let llextraparams = get_extra_params(llfn, kind);
-
-    let lltransformedselfty = type_of(ccx, transformed_self_ty);
-    let lltransformedselfval =
-        PointerCast(bcx, fcx.llenv, T_ptr(lltransformedselfty));
-    let llselfval = Load(bcx, lltransformedselfval);
-
-    let llotherval_opt;
-    match kind {
-        UnitKind => llotherval_opt = None,
-        BoolKind => llotherval_opt = Some(LLVMGetParam(llfn, 2))
-    }
-
-    let enum_id, enum_substs, enum_variant_infos;
-    match ty::get(self_ty).sty {
-        ty::ty_enum(found_enum_id, ref found_enum_substs) => {
-            enum_id = found_enum_id;
-            enum_substs = copy *found_enum_substs;
-            enum_variant_infos = ty::substd_enum_variants(
-                ccx.tcx, enum_id, &enum_substs);
-        }
-        _ => {
-            ccx.tcx.sess.bug(~"passed non-enum to \
-                               trans_deriving_enum_method");
-        }
-    }
-
-    // Create the "no match" basic block, if necessary. This is a basic block
-    // that does nothing more than return false.
-    let nomatch_bcx_opt;
-    match kind {
-        BoolKind => {
-            let nomatch_bcx = sub_block(top_bcx, ~"no_match");
-            Store(nomatch_bcx, C_bool(false), fcx.llretptr);
-            Br(nomatch_bcx, fcx.llreturn);
-            nomatch_bcx_opt = Some(nomatch_bcx);
-        }
-        UnitKind => nomatch_bcx_opt = None
-    }
-
-    // Create the "unreachable" basic block.
-    let unreachable_bcx = sub_block(top_bcx, ~"unreachable");
-    Unreachable(unreachable_bcx);
-
-    // Get the deriving enum method info.
-    let deriving_enum_methods = ccx.tcx.deriving_enum_methods.get(impl_did);
-    let n_variants = deriving_enum_methods.len();
-
-    if n_variants != 1 {
-        // Grab the two discriminants.
-        let llselfdiscrim = Load(bcx, GEPi(bcx, llselfval, [0, 0]));
-        let llotherdiscrim_opt = llotherval_opt.map(
-            |llotherval| Load(bcx, GEPi(bcx, *llotherval, [0, 0])));
-
-        // Skip over the discriminants and compute the address of the payload.
-        let llselfpayload = GEPi(bcx, llselfval, [0, 1]);
-        let llotherpayload_opt = llotherval_opt.map(
-            |llotherval| GEPi(bcx, *llotherval, [0, 1]));
-
-        // Create basic blocks for the outer switch.
-        let outer_bcxs = vec::from_fn(
-            deriving_enum_methods.len(),
-            |i| sub_block(top_bcx, fmt!("outer_%u", i)));
-
-        // For each basic block in the outer switch...
-        for outer_bcxs.eachi |self_variant_index, bcx| {
-            // Create the matching basic block for the inner switch.
-            let top_match_bcx = sub_block(top_bcx, fmt!("maybe_match_%u",
-                                                        self_variant_index));
-            let mut match_bcx = top_match_bcx;
-
-            // Compare each variant.
-            for deriving_enum_methods[self_variant_index].eachi
-                    |i, derived_method_info| {
-                let variant_def_id =
-                        enum_variant_infos[self_variant_index].id;
-                let llselfval = GEP_enum(match_bcx, llselfpayload, enum_id,
-                                         variant_def_id, enum_substs.tps, i);
-                let llselfallocaty = common::val_ty(llselfval);
-                let llselfalloca = base::alloca(match_bcx, llselfallocaty);
-                Store(match_bcx, llselfval, llselfalloca);
-
-                let llotherval_opt = llotherpayload_opt.map(|llotherpayload|
-                    GEP_enum(match_bcx, *llotherpayload, enum_id,
-                             variant_def_id, enum_substs.tps, i));
-
-                let self_ty = enum_variant_infos[self_variant_index].args[i];
-                match_bcx = call_substructure_method(match_bcx,
-                                                     derived_method_info,
-                                                     self_ty,
-                                                     llselfalloca,
-                                                     llotherval_opt,
-                                                     llextraparams);
-
-                // If this is a boolean-kind deriving method, then return
-                // immediately if the call to the substructure returned false.
-                match kind {
-                    BoolKind => {
-                        let next_bcx = sub_block(top_bcx,
-                                                 fmt!("next_%u_%u",
-                                                      self_variant_index,
-                                                      i));
-                        let llcond = Load(match_bcx, fcx.llretptr);
-                        CondBr(match_bcx,
-                               llcond,
-                               next_bcx.llbb,
-                               fcx.llreturn);
-                        match_bcx = next_bcx;
-                    }
-                    UnitKind => {}
-                }
-            }
-
-            // Store true in the return pointer if this is a boolean-kind
-            // deriving method.
-            match kind {
-                BoolKind => Store(match_bcx, C_bool(true), fcx.llretptr),
-                UnitKind => {}
-            }
-
-            // Finish up the matching block.
-            Br(match_bcx, fcx.llreturn);
-
-            // If this is a boolean-kind derived method, build the inner
-            // switch. Otherwise, just jump to the matching case.
-            match llotherdiscrim_opt {
-                None => Br(*bcx, top_match_bcx.llbb),
-                Some(copy llotherdiscrim) => {
-                    let llswitch = Switch(*bcx,
-                                          llotherdiscrim,
-                                          unreachable_bcx.llbb,
-                                          n_variants);
-                    for uint::range(0, n_variants) |other_variant_index| {
-                        let discriminant =
-                            enum_variant_infos[other_variant_index].disr_val;
-                        if self_variant_index == other_variant_index {
-                            // This is the potentially-matching case.
-                            AddCase(llswitch,
-                                    C_int(ccx, discriminant),
-                                    top_match_bcx.llbb);
-                        } else {
-                            // This is always a non-matching case.
-                            AddCase(llswitch,
-                                    C_int(ccx, discriminant),
-                                    nomatch_bcx_opt.get().llbb);
-                        }
-                    }
-                }
-            }
-        }
-
-        // Now build the outer switch.
-        let llswitch = Switch(top_bcx, llselfdiscrim, unreachable_bcx.llbb,
-                              n_variants);
-        for outer_bcxs.eachi |self_variant_index, outer_bcx| {
-            let discriminant =
-                enum_variant_infos[self_variant_index].disr_val;
-            AddCase(llswitch, C_int(ccx, discriminant), outer_bcx.llbb);
-        }
-    } else {
-        ccx.tcx.sess.unimpl(~"degenerate enum deriving");
-    }
-
-    // Finish up the function.
-    finish_fn(fcx, lltop);
-}
-
-fn call_substructure_method(bcx: block,
-                            derived_field_info: &DerivedFieldInfo,
-                            self_ty: ty::t,
-                            llselfval: ValueRef,
-                            llotherval_opt: Option<ValueRef>,
-                            llextraparams: &[ValueRef]) -> block {
-    let fcx = bcx.fcx;
-    let ccx = fcx.ccx;
-
-    let target_method_def_id;
-    match derived_field_info.method_origin {
-        method_static(did) => target_method_def_id = did,
-        _ => fail ~"derived method didn't resolve to a static method"
-    }
-
-    let fn_expr_tpbt = ty::lookup_item_type(ccx.tcx, target_method_def_id);
-    debug!("(calling substructure method) substructure method has %u \
-            parameter(s), vtable result is %?",
-           fn_expr_tpbt.bounds.len(),
-           derived_field_info.vtable_result);
-
-    // Get the substructure method we need to call. This may involve
-    // code generation in the case of generics, default methods, or cross-
-    // crate inlining.
-    let fn_data = callee::trans_fn_ref_with_vtables(bcx,
-                                                    target_method_def_id,
-                                                    0,     // ref id
-                                                    *derived_field_info.
-                                                 type_parameter_substitutions,
-                                                    derived_field_info.
-                                                        vtable_result);
-    let llfn = fn_data.llfn;
-
-    // Create the callee.
-    let cb: &fn(block) -> Callee = |bloc| {
-        Callee {
-            bcx: bloc,
-            data: Method(MethodData {
-                llfn: llfn,
-                llself: llselfval,
-                self_ty: self_ty,
-                self_mode: ast::by_copy
-            })
-        }
-    };
-
-    // Build up the argument list.
-    let llargvals = DVec();
-    for llotherval_opt.each |llotherval| { llargvals.push(*llotherval); }
-    for llextraparams.each |llextraparam| { llargvals.push(*llextraparam); }
-
-    // And perform the call.
-    callee::trans_call_inner(bcx,
-                             None,
-                             fn_expr_tpbt.ty,
-                             ty::mk_bool(ccx.tcx),
-                             cb,
-                             ArgVals(dvec::unwrap(move llargvals)),
-                             SaveIn(fcx.llretptr),
-                             DontAutorefArg)
-}
-
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index d244021763782..1ef91bfda880e 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -213,8 +213,6 @@ export opt_region_variance;
 export determine_inherited_purity;
 export provided_trait_methods;
 export trait_supertraits;
-export DerivedMethodInfo;
-export DerivedFieldInfo;
 export AutoAdjustment;
 export AutoRef;
 export AutoRefKind, AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn;
@@ -383,17 +381,6 @@ struct InstantiatedTraitRef {
     tpt: ty_param_substs_and_ty
 }
 
-struct DerivedMethodInfo {
-    method_info: @middle::resolve::MethodInfo,
-    containing_impl: ast::def_id
-}
-
-struct DerivedFieldInfo {
-    method_origin: typeck::method_origin,
-    type_parameter_substitutions: @~[ty::t],
-    vtable_result: Option<typeck::vtable_res>
-}
-
 type ctxt =
     @{diag: syntax::diagnostic::span_handler,
       interner: HashMap<intern_key, t_box>,
@@ -443,20 +430,6 @@ type ctxt =
       provided_methods: ProvidedMethodsMap,
       provided_method_sources: HashMap<ast::def_id, ProvidedMethodSource>,
       supertraits: HashMap<ast::def_id, @~[InstantiatedTraitRef]>,
-      deriving_struct_methods: HashMap<ast::def_id, @~[DerivedFieldInfo]>,
-
-      // The outer vector here describes each enum variant, while the inner
-      // nested vector describes each enum variant argument.
-      deriving_enum_methods: HashMap<ast::def_id, @~[@~[DerivedFieldInfo]]>,
-
-      // A mapping from the def ID of a method that was automatically derived
-      // to information about it.
-      automatically_derived_methods: HashMap<ast::def_id, DerivedMethodInfo>,
-
-      // A mapping from the def ID of an impl to the IDs of the derived
-      // methods within it.
-      automatically_derived_methods_for_impl:
-            HashMap<ast::def_id, @~[ast::def_id]>,
 
       // A mapping from the def ID of an enum or struct type to the def ID
       // of the method that implements its destructor. If the type is not
@@ -1003,10 +976,6 @@ fn mk_ctxt(s: session::Session,
       provided_methods: HashMap(),
       provided_method_sources: HashMap(),
       supertraits: HashMap(),
-      deriving_struct_methods: HashMap(),
-      deriving_enum_methods: HashMap(),
-      automatically_derived_methods: HashMap(),
-      automatically_derived_methods_for_impl: HashMap(),
       destructor_for_type: HashMap(),
       destructors: HashMap(),
       value_modes: HashMap()}
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index c2119471def53..3e5986f5236e6 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -19,7 +19,7 @@ use metadata::csearch::{get_impls_for_mod};
 use metadata::cstore::{CStore, iter_crate_data};
 use metadata::decoder::{dl_def, dl_field, dl_impl};
 use middle::resolve::{Impl, MethodInfo};
-use middle::ty::{DerivedMethodInfo, ProvidedMethodSource,
+use middle::ty::{ProvidedMethodSource,
                  ProvidedMethodInfo, get};
 use middle::ty::{lookup_item_type, subst, t, ty_bot, ty_box, ty_struct};
 use middle::ty::{ty_bool, ty_enum, ty_int, ty_nil, ty_ptr, ty_rptr, ty_uint};
@@ -598,105 +598,31 @@ impl CoherenceChecker {
         return trait_id;
     }
 
-    /// Returns true if the method has been marked with the #[derivable]
-    /// attribute and false otherwise.
-    fn method_is_derivable(method_def_id: ast::def_id) -> bool {
-        if method_def_id.crate == local_crate {
-            match self.crate_context.tcx.items.find(method_def_id.node) {
-                Some(ast_map::node_trait_method(trait_method, _, _)) => {
-                    match *trait_method {
-                        ast::required(ref ty_method) => {
-                            attr::attrs_contains_name((*ty_method).attrs,
-                                                      ~"derivable")
-                        }
-                        ast::provided(method) => {
-                            attr::attrs_contains_name(method.attrs,
-                                                      ~"derivable")
-                        }
-                    }
-                }
-                _ => {
-                    self.crate_context.tcx.sess.bug(~"method_is_derivable(): \
-                                                      def ID passed in \
-                                                      wasn't a trait method")
-                }
-            }
-        } else {
-            false   // XXX: Unimplemented.
-        }
-    }
+    // This check doesn't really have anything to do with coherence. It's
+    // here for historical reasons
+    fn please_check_that_trait_methods_are_implemented(
+        all_methods: &mut ~[@MethodInfo],
+        trait_did: def_id,
+        trait_ref_span: span) {
 
-    fn add_automatically_derived_methods_from_trait(
-            all_methods: &mut ~[@MethodInfo],
-            trait_did: def_id,
-            self_ty: ty::t,
-            impl_did: def_id,
-            trait_ref_span: span) {
         let tcx = self.crate_context.tcx;
 
-        // Make a set of all the method names that this implementation and
-        // trait provided so that we don't try to automatically derive
-        // implementations for them.
         let mut provided_names = send_map::linear::LinearMap();
+        // Implemented methods
         for uint::range(0, all_methods.len()) |i| {
             provided_names.insert(all_methods[i].ident, ());
         }
+        // Default methods
         for ty::provided_trait_methods(tcx, trait_did).each |ident| {
             provided_names.insert(*ident, ());
         }
 
-        let new_method_dids = dvec::DVec();
         for (*ty::trait_methods(tcx, trait_did)).each |method| {
-            // Check to see whether we need to derive this method. We need to
-            // derive a method only if and only if neither the trait nor the
-            // implementation we're considering provided a body.
             if provided_names.contains_key(&method.ident) { loop; }
 
-            if !self.method_is_derivable(method.def_id) {
-                tcx.sess.span_err(trait_ref_span,
-                                  fmt!("missing method `%s`",
-                                       tcx.sess.str_of(method.ident)));
-                loop;
-            }
-
-            // Generate a def ID for each node.
-            let new_def_id = local_def(tcx.sess.next_node_id());
-            let method_info = @{
-                did: new_def_id,
-                n_tps: method.tps.len(),
-                ident: method.ident,
-                self_type: method.self_ty
-            };
-            all_methods.push(method_info);
-
-            // Note that this method was automatically derived so that trans
-            // can handle it differently.
-            let derived_method_info = DerivedMethodInfo {
-                method_info: method_info,
-                containing_impl: impl_did
-            };
-
-            tcx.automatically_derived_methods.insert(new_def_id,
-                                                     derived_method_info);
-
-            new_method_dids.push(new_def_id);
-
-            // Additionally, generate the type for the derived method and add
-            // it to the type cache.
-            //
-            // XXX: Handle generics correctly.
-            let substs = { self_r: None, self_ty: Some(self_ty), tps: ~[] };
-            tcx.tcache.insert(new_def_id, {
-                bounds: @~[],
-                region_param: None,
-                ty: ty::subst(tcx, &substs, ty::mk_fn(tcx, method.fty))
-            });
-        }
-
-        let new_method_dids = @dvec::unwrap(move new_method_dids);
-        if new_method_dids.len() > 0 {
-            tcx.automatically_derived_methods_for_impl.insert(
-                impl_did, new_method_dids);
+            tcx.sess.span_err(trait_ref_span,
+                              fmt!("missing method `%s`",
+                                   tcx.sess.str_of(method.ident)));
         }
     }
 
@@ -720,19 +646,14 @@ impl CoherenceChecker {
                     methods.push(method_to_MethodInfo(*ast_method));
                 }
 
-                // Now search for methods that need to be automatically
-                // derived.
-                let tcx = self.crate_context.tcx;
-                let self_ty = ty::lookup_item_type(tcx, local_def(item.id));
+                // Check that we have implementations of every trait method
                 for trait_refs.each |trait_ref| {
                     let trait_did =
                         self.trait_ref_to_trait_def_id(*trait_ref);
-                    self.add_automatically_derived_methods_from_trait(
-                            &mut methods,
-                            trait_did,
-                            self_ty.ty,
-                            local_def(item.id),
-                            trait_ref.path.span);
+                    self.please_check_that_trait_methods_are_implemented(
+                        &mut methods,
+                        trait_did,
+                        trait_ref.path.span);
                 }
 
                 // For each trait that the impl implements, see which
diff --git a/src/librustc/middle/typeck/deriving.rs b/src/librustc/middle/typeck/deriving.rs
deleted file mode 100644
index bdd286dd484bd..0000000000000
--- a/src/librustc/middle/typeck/deriving.rs
+++ /dev/null
@@ -1,322 +0,0 @@
-// 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.
-
-// Deriving phase
-//
-// The purpose of the deriving phase of typechecking is to ensure that, for
-// each automatically derived implementation of an automatically-derivable
-// trait (for example, Eq), all the subcomponents of the type in question
-// also implement the trait. This phase runs after coherence.
-
-use syntax::ast::crate;
-use syntax::ast::{def_id, ident};
-use syntax::ast::item_impl;
-use syntax::ast::node_id;
-use syntax::ast::self_ty_;
-use syntax::ast::trait_ref;
-use syntax::ast_util::{def_id_of_def, dummy_sp};
-use syntax::codemap::span;
-use syntax::print::pprust;
-use syntax::visit::{default_simple_visitor, mk_simple_visitor, visit_crate};
-use middle::resolve::{Impl, MethodInfo};
-use middle::ty;
-use middle::ty::{DerivedFieldInfo, ReVar, re_infer, re_static, substs};
-use middle::ty::{ty_struct, ty_enum, ty_param_bounds_and_ty};
-use /*middle::typeck::*/check::method;
-use /*middle::typeck::*/check::vtable;
-use /*middle::typeck::*/infer::infer_ctxt;
-use /*middle::typeck::*/vtable::{LocationInfo, VtableContext};
-use util::ppaux;
-
-struct MethodMatch {
-    method_def_id: def_id,
-    type_parameter_substitutions: @~[ty::t],
-    vtable_result: Option<vtable_res>
-}
-
-struct DerivingChecker {
-    crate_context: @crate_ctxt
-}
-
-fn DerivingChecker_new(crate_context: @crate_ctxt) -> DerivingChecker {
-    DerivingChecker {
-        crate_context: crate_context,
-    }
-}
-
-struct TyParamSubstsAndVtableResult {
-    type_parameter_substitutions: @~[ty::t],
-    vtable_result: Option<vtable_res>
-}
-
-impl DerivingChecker {
-    /// Matches one substructure type against an implementation.
-    fn match_impl_method(impl_info: @Impl,
-                         substructure_type: ty::t,
-                         method_info: @MethodInfo,
-                         span: span) ->
-                         Option<TyParamSubstsAndVtableResult> {
-        let tcx = self.crate_context.tcx;
-
-        let impl_self_tpbt = ty::lookup_item_type(tcx, impl_info.did);
-
-        let inference_context = infer::new_infer_ctxt(self.crate_context.tcx);
-        let region = inference_context.next_region_var_nb(span);
-        let transformed_type = method::transform_self_type_for_method(
-            tcx, Some(region), impl_self_tpbt.ty, method_info.self_type);
-
-        let substs = {
-            self_r: None,
-            self_ty: None,
-            tps: inference_context.next_ty_vars(impl_self_tpbt.bounds.len())
-        };
-        let transformed_type = ty::subst(
-            self.crate_context.tcx, &substs, transformed_type);
-
-        // Automatically reference the substructure type.
-        let region = inference_context.next_region_var_nb(span);
-        let substructure_type = ty::mk_rptr(
-            self.crate_context.tcx,
-            region,
-            { ty: substructure_type, mutbl: ast::m_imm });
-
-        debug!("(matching impl method) substructure type %s, transformed \
-                type %s, subst tps %u",
-               ppaux::ty_to_str(self.crate_context.tcx, substructure_type),
-               ppaux::ty_to_str(self.crate_context.tcx, transformed_type),
-               substs.tps.len());
-
-        if !infer::mk_subty(inference_context,
-                            true,
-                            ast_util::dummy_sp(),
-                            substructure_type,
-                            transformed_type).is_ok() {
-            return None;
-        }
-
-        // Get the vtables.
-        let vtable_result;
-        if substs.tps.len() == 0 {
-            vtable_result = None;
-        } else {
-            let vcx = VtableContext {
-                ccx: self.crate_context,
-                infcx: inference_context
-            };
-            let location_info = LocationInfo {
-                span: span,
-                id: impl_info.did.node
-            };
-            vtable_result = Some(vtable::lookup_vtables(&vcx,
-                                                        &location_info,
-                                                        impl_self_tpbt.bounds,
-                                                        &substs,
-                                                        false,
-                                                        false));
-        }
-
-        // Extract the type parameter substitutions.
-        let type_parameter_substitutions = @substs.tps.map(|ty_var|
-            inference_context.resolve_type_vars_if_possible(*ty_var));
-
-        Some(TyParamSubstsAndVtableResult {
-            type_parameter_substitutions: type_parameter_substitutions,
-            vtable_result: vtable_result
-        })
-    }
-
-    fn check_deriving_for_substructure_type(substructure_type: ty::t,
-                                            trait_ref: @trait_ref,
-                                            impl_span: span) ->
-                                            Option<MethodMatch> {
-        let tcx = self.crate_context.tcx;
-        let sess = tcx.sess;
-        let coherence_info = self.crate_context.coherence_info;
-        let trait_id = def_id_of_def(tcx.def_map.get(trait_ref.ref_id));
-        match coherence_info.extension_methods.find(trait_id) {
-            None => {
-                sess.span_bug(impl_span, ~"no extension method info found \
-                                           for this trait");
-            }
-            Some(impls) => {
-                // Try to unify each of these impls with the substructure
-                // type.
-                //
-                // NB: Using range to avoid a recursive-use-of-dvec error.
-                for uint::range(0, impls.len()) |i| {
-                    let impl_info = impls[i];
-                    for uint::range(0, impl_info.methods.len()) |j| {
-                        let method_info = impl_info.methods[j];
-                        match self.match_impl_method(impl_info,
-                                                     substructure_type,
-                                                     method_info,
-                                                     trait_ref.path.span) {
-                            Some(move result) => {
-                                return Some(MethodMatch {
-                                    method_def_id: method_info.did,
-                                    type_parameter_substitutions:
-                                        result.type_parameter_substitutions,
-                                    vtable_result: result.vtable_result
-                                });
-                            }
-                            None => {}  // Continue.
-                        }
-                    }
-                }
-            }
-        }
-        return None;
-    }
-
-    fn check_deriving_for_struct(struct_def_id: def_id,
-                                 struct_substs: &substs,
-                                 trait_ref: @trait_ref,
-                                 impl_id: node_id,
-                                 impl_span: span) {
-        let tcx = self.crate_context.tcx;
-        let field_info = dvec::DVec();
-        for ty::lookup_struct_fields(tcx, struct_def_id).each |field| {
-            let field_type = ty::lookup_field_type(
-                tcx, struct_def_id, field.id, struct_substs);
-            match self.check_deriving_for_substructure_type(field_type,
-                                                            trait_ref,
-                                                            impl_span) {
-                Some(method_match) => {
-                    field_info.push(DerivedFieldInfo {
-                        method_origin:
-                            method_static(method_match.method_def_id),
-                        type_parameter_substitutions:
-                            method_match.type_parameter_substitutions,
-                        vtable_result:
-                            method_match.vtable_result
-                    });
-                }
-                None => {
-                    let trait_str = pprust::path_to_str(
-                        trait_ref.path, tcx.sess.parse_sess.interner);
-                    tcx.sess.span_err(impl_span,
-                                      fmt!("cannot automatically derive an \
-                                            implementation for `%s`: field \
-                                            `%s` does not implement the \
-                                            trait `%s`",
-                                           trait_str,
-                                           tcx.sess.str_of(field.ident),
-                                           trait_str));
-                }
-            }
-        }
-
-        let field_info = @dvec::unwrap(move field_info);
-        tcx.deriving_struct_methods.insert(local_def(impl_id), field_info);
-    }
-
-    fn check_deriving_for_enum(enum_def_id: def_id,
-                               enum_substs: &substs,
-                               trait_ref: @trait_ref,
-                               impl_id: node_id,
-                               impl_span: span) {
-        let tcx = self.crate_context.tcx;
-        let enum_methods = dvec::DVec();
-        let variants = ty::substd_enum_variants(
-            tcx, enum_def_id, enum_substs);
-        for variants.each |enum_variant_info| {
-            let variant_methods = dvec::DVec();
-            for enum_variant_info.args.eachi |i, variant_arg_type| {
-                match self.check_deriving_for_substructure_type(
-                        *variant_arg_type, trait_ref, impl_span) {
-                    Some(method_match) => {
-                        variant_methods.push(DerivedFieldInfo {
-                            method_origin:
-                                method_static(method_match.method_def_id),
-                            type_parameter_substitutions:
-                                method_match.type_parameter_substitutions,
-                            vtable_result:
-                                method_match.vtable_result
-                        });
-                    }
-                    None => {
-                        let trait_str = pprust::path_to_str(
-                            trait_ref.path, tcx.sess.parse_sess.interner);
-                        tcx.sess.span_err(impl_span,
-                                          fmt!("cannot automatically derive \
-                                                an implementation for `%s`: \
-                                                argument %u of variant `%s` \
-                                                does not implement the trait \
-                                                `%s`",
-                                               trait_str,
-                                               i + 1,
-                                               tcx.sess.str_of(
-                                                    enum_variant_info.name),
-                                               trait_str));
-                    }
-                }
-            }
-            enum_methods.push(@dvec::unwrap(move variant_methods));
-        }
-
-        let enum_methods = @dvec::unwrap(move enum_methods);
-        tcx.deriving_enum_methods.insert(local_def(impl_id), enum_methods);
-    }
-
-    fn check_deriving(crate: @crate) {
-        let tcx = self.crate_context.tcx;
-        visit_crate(*crate, (), mk_simple_visitor(@{
-            visit_item: |item| {
-                match item.node {
-                    item_impl(_, Some(trait_ref), _, _) => {
-                        // Determine whether there were any automatically-
-                        // derived methods in this implementation.
-                        let impl_did = local_def(item.id);
-                        if tcx.automatically_derived_methods_for_impl.
-                                contains_key(impl_did) {
-                            // XXX: This does not handle generic impls.
-                            let superty = ty::lookup_item_type(
-                                tcx, local_def(item.id)).ty;
-                            match ty::get(superty).sty {
-                                ty_enum(def_id, ref substs) => {
-                                    self.check_deriving_for_enum(
-                                        def_id,
-                                        substs,
-                                        trait_ref,
-                                        item.id,
-                                        item.span);
-                                }
-                                ty_struct(def_id, ref substs) => {
-                                    self.check_deriving_for_struct(
-                                        def_id,
-                                        substs,
-                                        trait_ref,
-                                        item.id,
-                                        item.span);
-                                }
-                                _ => {
-                                    tcx.sess.span_err(item.span,
-                                                      ~"only enums and \
-                                                        structs may have \
-                                                        implementations \
-                                                        automatically \
-                                                        derived for them");
-                                }
-                            }
-                        }
-                    }
-                    _ => {}
-                }
-            },
-            ..*default_simple_visitor()
-        }));
-    }
-}
-
-pub fn check_deriving(crate_context: @crate_ctxt, crate: @crate) {
-    let deriving_checker = @DerivingChecker_new(crate_context);
-    deriving_checker.check_deriving(crate);
-}
-
diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs
index 6af374353ab74..e128f6a03fb59 100644
--- a/src/librustc/middle/typeck/mod.rs
+++ b/src/librustc/middle/typeck/mod.rs
@@ -103,7 +103,6 @@ mod infer;
 mod collect;
 #[legacy_exports]
 mod coherence;
-mod deriving;
 
 #[auto_serialize]
 #[auto_deserialize]
@@ -391,7 +390,6 @@ fn check_crate(tcx: ty::ctxt,
                            });
     collect::collect_item_types(ccx, crate);
     coherence::check_coherence(ccx, crate);
-    deriving::check_deriving(ccx, crate);
 
     check::check_item_types(ccx, crate);
     check_for_main_fn(ccx);
diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc
index 543bff8a234ce..584f165b75daf 100644
--- a/src/librustc/rustc.rc
+++ b/src/librustc/rustc.rc
@@ -123,8 +123,6 @@ mod middle {
         mod reachable;
         #[path = "middle/trans/machine.rs"]
         mod machine;
-        #[path = "middle/trans/deriving.rs"]
-        mod deriving;
     }
     #[legacy_exports]
     #[path = "middle/ty.rs"]
diff --git a/src/test/compile-fail/enum-deriving-incomplete.rs b/src/test/compile-fail/enum-deriving-incomplete.rs
deleted file mode 100644
index 131a0ed653bfc..0000000000000
--- a/src/test/compile-fail/enum-deriving-incomplete.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.
-
-trait MyEq {
-    #[derivable]
-    pure fn eq(&self, other: &self) -> bool;
-}
-
-struct A {
-    x: int
-}
-
-enum B {
-    C(A),
-    D(A),
-    E(A)
-}
-
-impl B : MyEq;
-//~^ ERROR cannot automatically derive
-//~^^ ERROR cannot automatically derive
-//~^^^ ERROR cannot automatically derive
-
-fn main() {
-    let c = C(A { x: 15 });
-    assert c.eq(&c);
-}
-
diff --git a/src/test/run-pass/deriving-generic-bounded.rs b/src/test/run-pass/deriving-generic-bounded.rs
deleted file mode 100644
index 38c4fd1fc073e..0000000000000
--- a/src/test/run-pass/deriving-generic-bounded.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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.
-
-trait MyEq {
-    #[derivable]
-    pure fn eq(&self, other: &self) -> bool;
-}
-
-impl int : MyEq {
-    pure fn eq(&self, other: &int) -> bool {
-        *self == *other
-    }
-}
-
-impl<T:MyEq> @T : MyEq {
-    pure fn eq(&self, other: &@T) -> bool {
-        unsafe {
-            io::println("@T");
-        }
-        (**self).eq(&**other)
-    }
-}
-
-struct A {
-    x: @int,
-    y: @int
-}
-
-impl A : MyEq;
-
-fn main() {
-    let a = A { x: @3, y: @5 };
-    let b = A { x: @10, y: @20 };
-    assert a.eq(&a);
-    assert !a.eq(&b);
-}
-
diff --git a/src/test/run-pass/deriving-one-method.rs b/src/test/run-pass/deriving-one-method.rs
deleted file mode 100644
index 9ec29088c101f..0000000000000
--- a/src/test/run-pass/deriving-one-method.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.
-
-trait MyEq {
-    #[derivable]
-    pure fn eq(&self, other: &self) -> bool;
-    pure fn ne(&self, other: &self) -> bool;
-}
-
-struct A {
-    x: int
-}
-
-impl int : MyEq {
-    pure fn eq(&self, other: &int) -> bool { *self == *other }
-    pure fn ne(&self, other: &int) -> bool { *self != *other }
-}
-
-impl A : MyEq {
-    pure fn ne(&self, other: &A) -> bool { !self.eq(other) }
-}
-
-fn main() {
-    let a = A { x: 1 };
-    assert a.eq(&a);
-    assert !a.ne(&a);
-}
-
diff --git a/src/test/run-pass/deriving-override.rs b/src/test/run-pass/deriving-override.rs
deleted file mode 100644
index 04a7d2aa6e97c..0000000000000
--- a/src/test/run-pass/deriving-override.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.
-
-trait MyEq {
-    #[derivable]
-    pure fn eq(&self, other: &self) -> bool;
-    #[derivable]
-    pure fn ne(&self, other: &self) -> bool;
-}
-
-struct A {
-    x: int
-}
-
-impl int : MyEq {
-    pure fn eq(&self, other: &int) -> bool { *self == *other }
-    pure fn ne(&self, other: &int) -> bool { *self != *other }
-}
-
-impl A : MyEq {
-    pure fn ne(&self, other: &A) -> bool { !self.eq(other) }
-}
-
-fn main() {
-    let a = A { x: 1 };
-    assert a.eq(&a);
-    assert !a.ne(&a);
-}
-
diff --git a/src/test/run-pass/deriving-param-pass-through.rs b/src/test/run-pass/deriving-param-pass-through.rs
deleted file mode 100644
index f3be94ee9a7ac..0000000000000
--- a/src/test/run-pass/deriving-param-pass-through.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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.
-
-trait Trait {
-    #[derivable]
-    fn f(&self, x: int, y: &str);
-}
-
-impl int : Trait {
-    fn f(&self, x: int, y: &str) {
-        assert x == 42;
-        assert y == "hello";
-    }
-}
-
-impl float : Trait {
-    fn f(&self, x: int, y: &str) {
-        assert x == 42;
-        assert y == "hello";
-    }
-}
-
-struct Foo {
-    x: int,
-    y: float
-}
-
-impl Foo : Trait;
-
-fn main() {
-    let a: Foo = Foo { x: 1, y: 2.0 };
-    a.f(42, "hello");
-}
-
diff --git a/src/test/run-pass/deriving-returning-nil.rs b/src/test/run-pass/deriving-returning-nil.rs
deleted file mode 100644
index 50ce0529b5323..0000000000000
--- a/src/test/run-pass/deriving-returning-nil.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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.
-
-trait Show {
-    #[derivable]
-    fn show(&self);
-}
-
-impl int : Show {
-    fn show(&self) {
-        io::println(self.to_str());
-    }
-}
-
-struct Foo {
-    x: int,
-    y: int,
-    z: int,
-}
-
-impl Foo : Show;
-
-enum Bar {
-    Baz(int, int),
-    Boo(Foo),
-}
-
-impl Bar : Show;
-
-fn main() {
-    let foo = Foo { x: 1, y: 2, z: 3 };
-    foo.show();
-
-    io::println("---");
-
-    let baz = Baz(4, 5);
-    baz.show();
-
-    io::println("---");
-
-    let boo = Boo(Foo { x: 6, y: 7, z: 8 });
-    boo.show();
-}
-
diff --git a/src/test/run-pass/deriving-simple.rs b/src/test/run-pass/deriving-simple.rs
deleted file mode 100644
index 1ed17e56351a3..0000000000000
--- a/src/test/run-pass/deriving-simple.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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.
-
-trait MyEq {
-    #[derivable]
-    pure fn eq(&self, other: &self) -> bool;
-}
-
-struct A {
-    x: int
-}
-
-struct B {
-    x: A,
-    y: A,
-    z: A
-}
-
-impl A : MyEq {
-    pure fn eq(&self, other: &A) -> bool {
-        unsafe { io::println(fmt!("eq %d %d", self.x, other.x)); }
-        self.x == other.x
-    }
-}
-
-impl B : MyEq;
-
-fn main() {
-    let b = B { x: A { x: 1 }, y: A { x: 2 }, z: A { x: 3 } };
-    let c = B { x: A { x: 1 }, y: A { x: 3 }, z: A { x: 4 } };
-    assert b.eq(&b);
-    assert c.eq(&c);
-    assert !b.eq(&c);
-    assert !c.eq(&b);
-}
-
diff --git a/src/test/run-pass/enum-deriving-simple.rs b/src/test/run-pass/enum-deriving-simple.rs
deleted file mode 100644
index 2fdd79d4dcf3c..0000000000000
--- a/src/test/run-pass/enum-deriving-simple.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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.
-
-trait MyEq {
-    #[derivable]
-    pure fn eq(&self, other: &self) -> bool;
-}
-
-struct A {
-    x: int
-}
-
-enum B {
-    C(A),
-    D(A),
-    E(A)
-}
-
-impl A : MyEq {
-    pure fn eq(&self, other: &A) -> bool {
-        unsafe { io::println("in eq"); }
-        self.x == other.x
-    }
-}
-
-impl B : MyEq;
-
-fn main() {
-    let c = C(A { x: 15 });
-    let d = D(A { x: 30 });
-    let e = C(A { x: 30 });
-    assert c.eq(&c);
-    assert !c.eq(&d);
-    assert !c.eq(&e);
-}
-

From d42bdf1997ebaeb8a893947df563ff07d039cf08 Mon Sep 17 00:00:00 2001
From: Tim Chevalier <chevalier@alum.wellesley.edu>
Date: Tue, 11 Dec 2012 19:15:12 -0800
Subject: [PATCH 09/23] Auto-deref when checking field and method privacy

This disallows using pointers to sneak around priv qualifiers.

Deeming this too small for review as well. Closes #3763
---
 src/librustc/middle/privacy.rs      |  9 +++++++--
 src/test/compile-fail/issue-3763.rs | 15 ++++++++++-----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs
index 1bde3f82f7262..78c423b791d57 100644
--- a/src/librustc/middle/privacy.rs
+++ b/src/librustc/middle/privacy.rs
@@ -199,7 +199,10 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
         visit_expr: |expr, method_map: &method_map, visitor| {
             match expr.node {
                 expr_field(base, ident, _) => {
-                    match ty::get(ty::expr_ty(tcx, base)).sty {
+                    // With type_autoderef, make sure we don't
+                    // allow pointers to violate privacy
+                    match ty::get(ty::type_autoderef(tcx, ty::expr_ty(tcx,
+                                                          base))).sty {
                         ty_struct(id, _)
                         if id.crate != local_crate ||
                            !privileged_items.contains(&(id.node)) => {
@@ -220,7 +223,9 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
                     }
                 }
                 expr_method_call(base, _, _, _, _) => {
-                    match ty::get(ty::expr_ty(tcx, base)).sty {
+                    // Ditto
+                    match ty::get(ty::type_autoderef(tcx, ty::expr_ty(tcx,
+                                                          base))).sty {
                         ty_struct(id, _)
                         if id.crate != local_crate ||
                            !privileged_items.contains(&(id.node)) => {
diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs
index 8ee5dab41ed8e..ea4b70c3c2908 100644
--- a/src/test/compile-fail/issue-3763.rs
+++ b/src/test/compile-fail/issue-3763.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// xfail-test
 mod my_mod {
     pub struct MyStruct {
         priv priv_field: int
@@ -16,12 +15,18 @@ mod my_mod {
     pub fn MyStruct () -> MyStruct {
         MyStruct {priv_field: 4}
     }
+    impl MyStruct {
+        priv fn happyfun() {}
+    }
 }
 
 fn main() {
     let my_struct = my_mod::MyStruct();
-    let _woohoo = (&my_struct).priv_field; // compiles but shouldn't
-    let _woohoo = (~my_struct).priv_field; // ditto
-    let _woohoo = (@my_struct).priv_field; // ditto
-   // let nope = my_struct.priv_field;       // compile error as expected
+    let _woohoo = (&my_struct).priv_field; //~ ERROR field `priv_field` is private
+    let _woohoo = (~my_struct).priv_field; //~ ERROR field `priv_field` is private
+    let _woohoo = (@my_struct).priv_field; //~ ERROR field `priv_field` is private
+    (&my_struct).happyfun();               //~ ERROR method `happyfun` is private
+    (~my_struct).happyfun();               //~ ERROR method `happyfun` is private
+    (@my_struct).happyfun();               //~ ERROR method `happyfun` is private
+    let nope = my_struct.priv_field;       //~ ERROR field `priv_field` is private
 }

From b0a01f25638857edaf73d46d634a196781e3019a Mon Sep 17 00:00:00 2001
From: Tim Chevalier <chevalier@alum.wellesley.edu>
Date: Tue, 11 Dec 2012 12:43:33 -0800
Subject: [PATCH 10/23] re-fix typo

---
 src/libsyntax/attr.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 81b6357c6aecd..aadea886407cd 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -182,7 +182,7 @@ fn find_attrs_by_name(attrs: ~[ast::attribute], name: ~str) ->
     return vec::filter_map(attrs, filter);
 }
 
-/// Searcha list of meta items and return only those with a specific name
+/// Search a list of meta items and return only those with a specific name
 fn find_meta_items_by_name(metas: ~[@ast::meta_item], name: ~str) ->
    ~[@ast::meta_item] {
     let filter = fn@(m: &@ast::meta_item) -> Option<@ast::meta_item> {

From 38bd694df14a1b83ff8edaf5246785579fb812c0 Mon Sep 17 00:00:00 2001
From: Tim Chevalier <chevalier@alum.wellesley.edu>
Date: Tue, 11 Dec 2012 12:26:41 -0800
Subject: [PATCH 11/23] Reverse the order of the results of pipes::stream

As per #3637.
---
 src/libcore/pipes.rs                          | 12 +++----
 src/libcore/private.rs                        |  2 +-
 src/libcore/task/mod.rs                       | 10 +++---
 src/libcore/task/spawn.rs                     |  4 +--
 src/librustdoc/markdown_writer.rs             | 10 +++---
 src/libstd/arc.rs                             | 12 +++----
 src/libstd/comm.rs                            |  4 +--
 src/libstd/sync.rs                            | 36 +++++++++----------
 src/libstd/task_pool.rs                       |  2 +-
 src/test/bench/msgsend-pipes-shared.rs        |  4 +--
 src/test/bench/msgsend-pipes.rs               |  8 ++---
 src/test/bench/shootout-k-nucleotide-pipes.rs |  4 +--
 src/test/bench/shootout-pfib.rs               |  2 +-
 .../bench/task-perf-jargon-metal-smoke.rs     |  2 +-
 .../compile-fail/bind-by-move-no-guards.rs    |  2 +-
 src/test/run-pass/issue-3168.rs               |  6 ++--
 src/test/run-pass/issue-3176.rs               |  8 ++---
 src/test/run-pass/task-comm-0.rs              |  2 +-
 src/test/run-pass/task-comm-10.rs             |  4 +--
 src/test/run-pass/task-comm-11.rs             |  4 +--
 src/test/run-pass/task-comm-13.rs             |  2 +-
 src/test/run-pass/task-comm-14.rs             |  2 +-
 src/test/run-pass/task-comm-15.rs             |  2 +-
 src/test/run-pass/task-comm-16.rs             | 12 +++----
 src/test/run-pass/task-comm-4.rs              |  2 +-
 src/test/run-pass/task-comm-5.rs              |  2 +-
 src/test/run-pass/trivial-message.rs          |  2 +-
 27 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index c298213fb7c1c..f01bf89019190 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -978,10 +978,10 @@ pub enum Port<T:Send> {
 These allow sending or receiving an unlimited number of messages.
 
 */
-pub fn stream<T:Send>() -> (Chan<T>, Port<T>) {
+pub fn stream<T:Send>() -> (Port<T>, Chan<T>) {
     let (c, s) = streamp::init();
 
-    (Chan_({ mut endp: Some(move c) }), Port_({ mut endp: Some(move s) }))
+    (Port_({ mut endp: Some(move s) }), Chan_({ mut endp: Some(move c) }))
 }
 
 impl<T: Send> Chan<T>: GenericChan<T> {
@@ -1070,7 +1070,7 @@ impl<T: Send> PortSet<T> {
     }
 
     fn chan() -> Chan<T> {
-        let (ch, po) = stream();
+        let (po, ch) = stream();
         self.add(move po);
         move ch
     }
@@ -1240,8 +1240,8 @@ pub mod rt {
 pub mod test {
     #[test]
     pub fn test_select2() {
-        let (c1, p1) = pipes::stream();
-        let (c2, p2) = pipes::stream();
+        let (p1, c1) = pipes::stream();
+        let (p2, c2) = pipes::stream();
 
         c1.send(~"abc");
 
@@ -1264,7 +1264,7 @@ pub mod test {
 
     #[test]
     fn test_peek_terminated() {
-        let (chan, port): (Chan<int>, Port<int>) = stream();
+        let (port, chan): (Port<int>, Chan<int>) = stream();
 
         {
             // Destroy the channel
diff --git a/src/libcore/private.rs b/src/libcore/private.rs
index 2b6156b14c4bd..bc85dcbbbf807 100644
--- a/src/libcore/private.rs
+++ b/src/libcore/private.rs
@@ -576,7 +576,7 @@ pub mod tests {
 
         for uint::range(0, num_tasks) |_i| {
             let total = total.clone();
-            let (chan, port) = pipes::stream();
+            let (port, chan) = pipes::stream();
             futures.push(move port);
 
             do task::spawn |move total, move chan| {
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs
index 188b7c334672d..98da3f50318d1 100644
--- a/src/libcore/task/mod.rs
+++ b/src/libcore/task/mod.rs
@@ -340,7 +340,7 @@ impl TaskBuilder {
         }
 
         // Construct the future and give it to the caller.
-        let (notify_pipe_ch, notify_pipe_po) = stream::<TaskResult>();
+        let (notify_pipe_po, notify_pipe_ch) = stream::<TaskResult>();
 
         blk(move notify_pipe_po);
 
@@ -1211,7 +1211,7 @@ fn test_unkillable() {
 #[ignore(cfg(windows))]
 #[should_fail]
 fn test_unkillable_nested() {
-    let (ch, po) = pipes::stream();
+    let (po, ch) = pipes::stream();
 
     // We want to do this after failing
     do spawn_unlinked |move ch| {
@@ -1277,7 +1277,7 @@ fn test_child_doesnt_ref_parent() {
 
 #[test]
 fn test_sched_thread_per_core() {
-    let (chan, port) = pipes::stream();
+    let (port, chan) = pipes::stream();
 
     do spawn_sched(ThreadPerCore) |move chan| {
         let cores = rt::rust_num_threads();
@@ -1291,7 +1291,7 @@ fn test_sched_thread_per_core() {
 
 #[test]
 fn test_spawn_thread_on_demand() {
-    let (chan, port) = pipes::stream();
+    let (port, chan) = pipes::stream();
 
     do spawn_sched(ManualThreads(2)) |move chan| {
         let max_threads = rt::rust_sched_threads();
@@ -1299,7 +1299,7 @@ fn test_spawn_thread_on_demand() {
         let running_threads = rt::rust_sched_current_nonlazy_threads();
         assert(running_threads as int == 1);
 
-        let (chan2, port2) = pipes::stream();
+        let (port2, chan2) = pipes::stream();
 
         do spawn() |move chan2| {
             chan2.send(());
diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs
index 05f775d08d431..61e358e1e30e4 100644
--- a/src/libcore/task/spawn.rs
+++ b/src/libcore/task/spawn.rs
@@ -670,7 +670,7 @@ fn test_spawn_raw_unsupervise() {
 #[test]
 #[ignore(cfg(windows))]
 fn test_spawn_raw_notify_success() {
-    let (notify_ch, notify_po) = pipes::stream();
+    let (notify_po, notify_ch) = pipes::stream();
 
     let opts = {
         notify_chan: Some(move notify_ch),
@@ -685,7 +685,7 @@ fn test_spawn_raw_notify_success() {
 #[ignore(cfg(windows))]
 fn test_spawn_raw_notify_failure() {
     // New bindings for these
-    let (notify_ch, notify_po) = pipes::stream();
+    let (notify_po, notify_ch) = pipes::stream();
 
     let opts = {
         linked: false,
diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs
index ae4fa5f42c2c8..0f03e7f4594e1 100644
--- a/src/librustdoc/markdown_writer.rs
+++ b/src/librustdoc/markdown_writer.rs
@@ -111,12 +111,12 @@ fn pandoc_writer(
         os::close(pipe_err.out);
         os::close(pipe_in.out);
 
-        let (stdout_ch, stdout_po) = pipes::stream();
+        let (stdout_po, stdout_ch) = pipes::stream();
         do task::spawn_sched(task::SingleThreaded) |move stdout_ch| {
             stdout_ch.send(readclose(pipe_out.in));
         }
 
-        let (stderr_ch, stderr_po) = pipes::stream();
+        let (stderr_po, stderr_ch) = pipes::stream();
         do task::spawn_sched(task::SingleThreaded) |move stderr_ch| {
             stderr_ch.send(readclose(pipe_err.in));
         }
@@ -149,7 +149,7 @@ fn readclose(fd: libc::c_int) -> ~str {
 }
 
 fn generic_writer(+process: fn~(+markdown: ~str)) -> Writer {
-    let (setup_ch, setup_po) = pipes::stream();
+    let (setup_po, setup_ch) = pipes::stream();
     do task::spawn |move process, move setup_ch| {
         let po: comm::Port<WriteInstr> = comm::Port();
         let ch = comm::Chan(&po);
@@ -279,7 +279,7 @@ pub fn future_writer_factory(
     let markdown_po = comm::Port();
     let markdown_ch = comm::Chan(&markdown_po);
     let writer_factory = fn~(+page: doc::Page) -> Writer {
-        let (writer_ch, writer_po) = pipes::stream();
+        let (writer_po, writer_ch) = pipes::stream();
         do task::spawn |move writer_ch| {
             let (writer, future) = future_writer();
             writer_ch.send(move writer);
@@ -293,7 +293,7 @@ pub fn future_writer_factory(
 }
 
 fn future_writer() -> (Writer, future::Future<~str>) {
-    let (chan, port) = pipes::stream();
+    let (port, chan) = pipes::stream();
     let writer = fn~(move chan, +instr: WriteInstr) {
         chan.send(copy instr);
     };
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs
index 05acbeab9e58d..eacb310ee0284 100644
--- a/src/libstd/arc.rs
+++ b/src/libstd/arc.rs
@@ -471,7 +471,7 @@ mod tests {
         let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
         let arc_v = arc::ARC(v);
 
-        let (c, p) = pipes::stream();
+        let (p, c) = pipes::stream();
 
         do task::spawn() |move c| {
             let p = pipes::PortSet();
@@ -517,7 +517,7 @@ mod tests {
     fn test_arc_condvar_poison() {
         let arc = ~MutexARC(1);
         let arc2 = ~arc.clone();
-        let (c,p) = pipes::stream();
+        let (p, c) = pipes::stream();
 
         do task::spawn_unlinked |move arc2, move p| {
             let _ = p.recv();
@@ -551,7 +551,7 @@ mod tests {
     fn test_mutex_arc_unwrap_poison() {
         let arc = MutexARC(1);
         let arc2 = ~(&arc).clone();
-        let (c,p) = pipes::stream();
+        let (p, c) = pipes::stream();
         do task::spawn |move c, move arc2| {
             do arc2.access |one| {
                 c.send(());
@@ -649,7 +649,7 @@ mod tests {
     fn test_rw_arc() {
         let arc = ~RWARC(0);
         let arc2 = ~arc.clone();
-        let (c,p) = pipes::stream();
+        let (p,c) = pipes::stream();
 
         do task::spawn |move arc2, move c| {
             do arc2.write |num| {
@@ -695,7 +695,7 @@ mod tests {
         // Reader tasks
         let mut reader_convos = ~[];
         for 10.times {
-            let ((rc1,rp1),(rc2,rp2)) = (pipes::stream(),pipes::stream());
+            let ((rp1,rc1),(rp2,rc2)) = (pipes::stream(),pipes::stream());
             reader_convos.push((move rc1, move rp2));
             let arcn = ~arc.clone();
             do task::spawn |move rp1, move rc2, move arcn| {
@@ -709,7 +709,7 @@ mod tests {
 
         // Writer task
         let arc2 = ~arc.clone();
-        let ((wc1,wp1),(wc2,wp2)) = (pipes::stream(),pipes::stream());
+        let ((wp1,wc1),(wp2,wc2)) = (pipes::stream(),pipes::stream());
         do task::spawn |move arc2, move wc2, move wp1| {
             wp1.recv();
             do arc2.write_cond |state, cond| {
diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs
index d8c5b6e5944ee..49c5df2a28e44 100644
--- a/src/libstd/comm.rs
+++ b/src/libstd/comm.rs
@@ -64,8 +64,8 @@ impl<T: Send, U: Send> DuplexStream<T, U> : Selectable {
 pub fn DuplexStream<T: Send, U: Send>()
     -> (DuplexStream<T, U>, DuplexStream<U, T>)
 {
-    let (c2, p1) = pipes::stream();
-    let (c1, p2) = pipes::stream();
+    let (p1, c2) = pipes::stream();
+    let (p2, c1) = pipes::stream();
     (DuplexStream {
         chan: move c1,
         port: move p1
diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs
index a373a201ffee0..7506f1ea7bdab 100644
--- a/src/libstd/sync.rs
+++ b/src/libstd/sync.rs
@@ -34,7 +34,7 @@ struct Waitqueue { head: pipes::Port<SignalEnd>,
                    tail: pipes::Chan<SignalEnd> }
 
 fn new_waitqueue() -> Waitqueue {
-    let (block_tail, block_head) = pipes::stream();
+    let (block_head, block_tail) = pipes::stream();
     Waitqueue { head: move block_head, tail: move block_tail }
 }
 
@@ -733,7 +733,7 @@ mod tests {
     #[test]
     fn test_sem_as_cvar() {
         /* Child waits and parent signals */
-        let (c,p) = pipes::stream();
+        let (p,c) = pipes::stream();
         let s = ~semaphore(0);
         let s2 = ~s.clone();
         do task::spawn |move s2, move c| {
@@ -745,7 +745,7 @@ mod tests {
         let _ = p.recv();
 
         /* Parent waits and child signals */
-        let (c,p) = pipes::stream();
+        let (p,c) = pipes::stream();
         let s = ~semaphore(0);
         let s2 = ~s.clone();
         do task::spawn |move s2, move p| {
@@ -762,8 +762,8 @@ mod tests {
         // time, and shake hands.
         let s = ~semaphore(2);
         let s2 = ~s.clone();
-        let (c1,p1) = pipes::stream();
-        let (c2,p2) = pipes::stream();
+        let (p1,c1) = pipes::stream();
+        let (p2,c2) = pipes::stream();
         do task::spawn |move s2, move c1, move p2| {
             do s2.access {
                 let _ = p2.recv();
@@ -782,7 +782,7 @@ mod tests {
         do task::spawn_sched(task::ManualThreads(1)) {
             let s = ~semaphore(1);
             let s2 = ~s.clone();
-            let (c,p) = pipes::stream();
+            let (p,c) = pipes::stream();
             let child_data = ~mut Some((move s2, move c));
             do s.access {
                 let (s2,c) = option::swap_unwrap(child_data);
@@ -804,7 +804,7 @@ mod tests {
     fn test_mutex_lock() {
         // Unsafely achieve shared state, and do the textbook
         // "load tmp = move ptr; inc tmp; store ptr <- tmp" dance.
-        let (c,p) = pipes::stream();
+        let (p,c) = pipes::stream();
         let m = ~Mutex();
         let m2 = ~m.clone();
         let mut sharedstate = ~0;
@@ -847,7 +847,7 @@ mod tests {
             cond.wait();
         }
         // Parent wakes up child
-        let (chan,port) = pipes::stream();
+        let (port,chan) = pipes::stream();
         let m3 = ~m.clone();
         do task::spawn |move chan, move m3| {
             do m3.lock_cond |cond| {
@@ -870,7 +870,7 @@ mod tests {
 
         for num_waiters.times {
             let mi = ~m.clone();
-            let (chan, port) = pipes::stream();
+            let (port, chan) = pipes::stream();
             ports.push(move port);
             do task::spawn |move chan, move mi| {
                 do mi.lock_cond |cond| {
@@ -932,7 +932,7 @@ mod tests {
         let m2 = ~m.clone();
 
         let result: result::Result<(),()> = do task::try |move m2| {
-            let (c,p) = pipes::stream();
+            let (p,c) = pipes::stream();
             do task::spawn |move p| { // linked
                 let _ = p.recv(); // wait for sibling to get in the mutex
                 task::yield();
@@ -954,12 +954,12 @@ mod tests {
     fn test_mutex_killed_broadcast() {
         let m = ~Mutex();
         let m2 = ~m.clone();
-        let (c,p) = pipes::stream();
+        let (p,c) = pipes::stream();
 
         let result: result::Result<(),()> = do task::try |move c, move m2| {
             let mut sibling_convos = ~[];
             for 2.times {
-                let (c,p) = pipes::stream();
+                let (p,c) = pipes::stream();
                 let c = ~mut Some(move c);
                 sibling_convos.push(move p);
                 let mi = ~m2.clone();
@@ -1022,7 +1022,7 @@ mod tests {
         let result = do task::try {
             let m = ~mutex_with_condvars(2);
             let m2 = ~m.clone();
-            let (c,p) = pipes::stream();
+            let (p,c) = pipes::stream();
             do task::spawn |move m2, move c| {
                 do m2.lock_cond |cond| {
                     c.send(());
@@ -1082,7 +1082,7 @@ mod tests {
                              mode2: RWlockMode) {
         // Test mutual exclusion between readers and writers. Just like the
         // mutex mutual exclusion test, a ways above.
-        let (c,p) = pipes::stream();
+        let (p,c) = pipes::stream();
         let x2 = ~x.clone();
         let mut sharedstate = ~0;
         let ptr = ptr::addr_of(&(*sharedstate));
@@ -1127,8 +1127,8 @@ mod tests {
                              mode2: RWlockMode, make_mode2_go_first: bool) {
         // Much like sem_multi_resource.
         let x2 = ~x.clone();
-        let (c1,p1) = pipes::stream();
-        let (c2,p2) = pipes::stream();
+        let (p1,c1) = pipes::stream();
+        let (p2,c2) = pipes::stream();
         do task::spawn |move c1, move x2, move p2| {
             if !make_mode2_go_first {
                 let _ = p2.recv(); // parent sends to us once it locks, or ...
@@ -1193,7 +1193,7 @@ mod tests {
             cond.wait();
         }
         // Parent wakes up child
-        let (chan,port) = pipes::stream();
+        let (port,chan) = pipes::stream();
         let x3 = ~x.clone();
         do task::spawn |move x3, move chan| {
             do x3.write_cond |cond| {
@@ -1229,7 +1229,7 @@ mod tests {
 
         for num_waiters.times {
             let xi = ~x.clone();
-            let (chan, port) = pipes::stream();
+            let (port, chan) = pipes::stream();
             ports.push(move port);
             do task::spawn |move chan, move xi| {
                 do lock_cond(xi, dg1) |cond| {
diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs
index 938a3ffec0c20..a87576789af55 100644
--- a/src/libstd/task_pool.rs
+++ b/src/libstd/task_pool.rs
@@ -42,7 +42,7 @@ pub impl<T> TaskPool<T> {
         assert n_tasks >= 1;
 
         let channels = do vec::from_fn(n_tasks) |i| {
-            let (chan, port) = pipes::stream::<Msg<T>>();
+            let (port, chan) = pipes::stream::<Msg<T>>();
             let init_fn = init_fn_factory();
 
             let task_body: ~fn() = |move port, move init_fn| {
diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs
index 05898393540f0..5b6c5210dbffb 100644
--- a/src/test/bench/msgsend-pipes-shared.rs
+++ b/src/test/bench/msgsend-pipes-shared.rs
@@ -55,8 +55,8 @@ fn server(requests: Port<request>, responses: pipes::Chan<uint>) {
 }
 
 fn run(args: &[~str]) {
-    let (to_parent, from_child) = pipes::stream();
-    let (to_child, from_parent) = pipes::stream();
+    let (from_child, to_parent) = pipes::stream();
+    let (from_parent, to_child) = pipes::stream();
 
     let to_child = SharedChan(move to_child);
 
diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs
index 0901d9ab8dbae..269d02ae45f33 100644
--- a/src/test/bench/msgsend-pipes.rs
+++ b/src/test/bench/msgsend-pipes.rs
@@ -33,7 +33,7 @@ enum request {
 }
 
 fn server(requests: PortSet<request>, responses: pipes::Chan<uint>) {
-    let mut count = 0u;
+    let mut count = 0;
     let mut done = false;
     while !done {
         match requests.try_recv() {
@@ -51,8 +51,8 @@ fn server(requests: PortSet<request>, responses: pipes::Chan<uint>) {
 }
 
 fn run(args: &[~str]) {
-    let (to_parent, from_child) = pipes::stream();
-    let (to_child, from_parent_) = pipes::stream();
+    let (from_child, to_parent) = pipes::stream();
+    let (from_parent_, to_child) = pipes::stream();
     let from_parent = PortSet();
     from_parent.add(move from_parent_);
 
@@ -62,7 +62,7 @@ fn run(args: &[~str]) {
     let start = std::time::precise_time_s();
     let mut worker_results = ~[];
     for uint::range(0, workers) |_i| {
-        let (to_child, from_parent_) = pipes::stream();
+        let (from_parent_, to_child) = pipes::stream();
         from_parent.add(move from_parent_);
         do task::task().future_result(|+r| {
             worker_results.push(move r);
diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs
index 040ecc56df39b..83f9e77edc570 100644
--- a/src/test/bench/shootout-k-nucleotide-pipes.rs
+++ b/src/test/bench/shootout-k-nucleotide-pipes.rs
@@ -157,11 +157,11 @@ fn main() {
         let sz = *sz;
         let mut stream = None;
         stream <-> streams[ii];
-        let (to_parent_, from_child_) = option::unwrap(move stream);
+        let (from_child_, to_parent_) = option::unwrap(move stream);
 
         from_child.push(move from_child_);
 
-        let (to_child, from_parent) = pipes::stream();
+        let (from_parent, to_child) = pipes::stream();
 
         do task::spawn_with(move from_parent) |move to_parent_, from_parent| {
             make_sequence_processor(sz, from_parent, to_parent_);
diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs
index 55a6211dcc83e..c5429086c4314 100644
--- a/src/test/bench/shootout-pfib.rs
+++ b/src/test/bench/shootout-pfib.rs
@@ -50,7 +50,7 @@ fn fib(n: int) -> int {
         }
     }
 
-    let (ch, p) = pipes::stream();
+    let (p, ch) = pipes::stream();
     let _t = task::spawn(|move ch| pfib(ch, n) );
     p.recv()
 }
diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs
index 9e9a1ffbe5f51..3d886e561a7ec 100644
--- a/src/test/bench/task-perf-jargon-metal-smoke.rs
+++ b/src/test/bench/task-perf-jargon-metal-smoke.rs
@@ -43,7 +43,7 @@ fn main() {
         copy args
     };
 
-    let (c,p) = pipes::stream();
+    let (p,c) = pipes::stream();
     child_generation(uint::from_str(args[1]).get(), move c);
     if p.try_recv().is_none() {
         fail ~"it happened when we slumbered";
diff --git a/src/test/compile-fail/bind-by-move-no-guards.rs b/src/test/compile-fail/bind-by-move-no-guards.rs
index 3c9af823cb93e..a5cc7ea10d79f 100644
--- a/src/test/compile-fail/bind-by-move-no-guards.rs
+++ b/src/test/compile-fail/bind-by-move-no-guards.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let (c,p) = pipes::stream();
+    let (p,c) = pipes::stream();
     let x = Some(p);
     c.send(false);
     match move x {
diff --git a/src/test/run-pass/issue-3168.rs b/src/test/run-pass/issue-3168.rs
index ac1c655319132..5caf5e05ab6ca 100644
--- a/src/test/run-pass/issue-3168.rs
+++ b/src/test/run-pass/issue-3168.rs
@@ -11,15 +11,15 @@
 // xfail-fast
 
 fn main() {
-    let (c,p) = pipes::stream();
+    let (p,c) = pipes::stream();
     do task::try |move c| {
-        let (c2,p2) = pipes::stream();
+        let (p2,c2) = pipes::stream();
         do task::spawn |move p2| {
             p2.recv();
             error!("sibling fails");
             fail;
         }   
-        let (c3,p3) = pipes::stream();
+        let (p3,c3) = pipes::stream();
         c.send(move c3);
         c2.send(());
         error!("child blocks");
diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs
index b94230ec865a1..817d4b9a375e8 100644
--- a/src/test/run-pass/issue-3176.rs
+++ b/src/test/run-pass/issue-3176.rs
@@ -13,19 +13,19 @@
 use pipes::{Select2, Selectable};
 
 fn main() {
-    let (c,p) = pipes::stream();
+    let (p,c) = pipes::stream();
     do task::try |move c| {
-        let (c2,p2) = pipes::stream();
+        let (p2,c2) = pipes::stream();
         do task::spawn |move p2| {
             p2.recv();
             error!("sibling fails");
             fail;
         }   
-        let (c3,p3) = pipes::stream();
+        let (p3,c3) = pipes::stream();
         c.send(move c3);
         c2.send(());
         error!("child blocks");
-        let (c, p) = pipes::stream();
+        let (p, c) = pipes::stream();
         (move p, move p3).select();
         c.send(());
     };  
diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs
index 535c05fb8bd15..a473d63181946 100644
--- a/src/test/run-pass/task-comm-0.rs
+++ b/src/test/run-pass/task-comm-0.rs
@@ -28,7 +28,7 @@ fn test05_start(ch : Chan<int>) {
 }
 
 fn test05() {
-    let (ch, po) = pipes::stream();
+    let (po, ch) = pipes::stream();
     task::spawn(|move ch| test05_start(ch) );
     let mut value = po.recv();
     log(error, value);
diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs
index f41f272e0cf5f..5188ec7b71b6c 100644
--- a/src/test/run-pass/task-comm-10.rs
+++ b/src/test/run-pass/task-comm-10.rs
@@ -14,7 +14,7 @@
 extern mod std;
 
 fn start(c: pipes::Chan<pipes::Chan<~str>>) {
-    let (ch, p) = pipes::stream();
+    let (p, ch) = pipes::stream();
     c.send(move ch);
 
     let mut a;
@@ -28,7 +28,7 @@ fn start(c: pipes::Chan<pipes::Chan<~str>>) {
 }
 
 fn main() {
-    let (ch, p) = pipes::stream();
+    let (p, ch) = pipes::stream();
     let child = task::spawn(|move ch| start(ch) );
 
     let c = p.recv();
diff --git a/src/test/run-pass/task-comm-11.rs b/src/test/run-pass/task-comm-11.rs
index 8df0d7df786ba..8d0a8a425b03d 100644
--- a/src/test/run-pass/task-comm-11.rs
+++ b/src/test/run-pass/task-comm-11.rs
@@ -14,12 +14,12 @@
 extern mod std;
 
 fn start(c: pipes::Chan<pipes::Chan<int>>) {
-    let (ch, p) = pipes::stream();
+    let (p, ch) = pipes::stream();
     c.send(move ch);
 }
 
 fn main() {
-    let (ch, p) = pipes::stream();
+    let (p, ch) = pipes::stream();
     let child = task::spawn(|move ch| start(ch) );
     let c = p.recv();
 }
diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs
index 94a68aefa713c..89097776b90b6 100644
--- a/src/test/run-pass/task-comm-13.rs
+++ b/src/test/run-pass/task-comm-13.rs
@@ -21,7 +21,7 @@ fn start(c: pipes::Chan<int>, start: int, number_of_messages: int) {
 
 fn main() {
     debug!("Check that we don't deadlock.");
-    let (ch, p) = pipes::stream();
+    let (p, ch) = pipes::stream();
     task::try(|move ch| start(ch, 0, 10) );
     debug!("Joined task");
 }
diff --git a/src/test/run-pass/task-comm-14.rs b/src/test/run-pass/task-comm-14.rs
index dd1a3c940f166..62415ca438d19 100644
--- a/src/test/run-pass/task-comm-14.rs
+++ b/src/test/run-pass/task-comm-14.rs
@@ -18,7 +18,7 @@ fn main() {
     let mut i = 10;
     while (i > 0) {
         log(debug, i);
-        let (ch, p) = pipes::stream();
+        let (p, ch) = pipes::stream();
         po.add(move p);
         task::spawn(|move ch, copy i| child(i, ch) );
         i = i - 1;
diff --git a/src/test/run-pass/task-comm-15.rs b/src/test/run-pass/task-comm-15.rs
index 58bb19e0087c3..d8a537f2c5c21 100644
--- a/src/test/run-pass/task-comm-15.rs
+++ b/src/test/run-pass/task-comm-15.rs
@@ -27,7 +27,7 @@ fn main() {
     // is likely to terminate before the child completes, so from
     // the child's point of view the receiver may die. We should
     // drop messages on the floor in this case, and not crash!
-    let (ch, p) = pipes::stream();
+    let (p, ch) = pipes::stream();
     task::spawn(|move ch| start(ch, 10));
     p.recv();
 }
diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs
index 67450c9b26be8..dcfc6fed20717 100644
--- a/src/test/run-pass/task-comm-16.rs
+++ b/src/test/run-pass/task-comm-16.rs
@@ -20,7 +20,7 @@ use pipes::Chan;
 fn test_rec() {
     type r = {val0: int, val1: u8, val2: char};
 
-    let (ch, po) = pipes::stream();
+    let (po, ch) = pipes::stream();
     let r0: r = {val0: 0, val1: 1u8, val2: '2'};
     ch.send(r0);
     let mut r1: r;
@@ -31,7 +31,7 @@ fn test_rec() {
 }
 
 fn test_vec() {
-    let (ch, po) = pipes::stream();
+    let (po, ch) = pipes::stream();
     let v0: ~[int] = ~[0, 1, 2];
     ch.send(v0);
     let v1 = po.recv();
@@ -41,7 +41,7 @@ fn test_vec() {
 }
 
 fn test_str() {
-    let (ch, po) = pipes::stream();
+    let (po, ch) = pipes::stream();
     let s0 = ~"test";
     ch.send(s0);
     let s1 = po.recv();
@@ -85,7 +85,7 @@ impl t : cmp::Eq {
 }
 
 fn test_tag() {
-    let (ch, po) = pipes::stream();
+    let (po, ch) = pipes::stream();
     ch.send(tag1);
     ch.send(tag2(10));
     ch.send(tag3(10, 11u8, 'A'));
@@ -99,8 +99,8 @@ fn test_tag() {
 }
 
 fn test_chan() {
-    let (ch, po) = pipes::stream();
-    let (ch0, po0) = pipes::stream();
+    let (po, ch) = pipes::stream();
+    let (po0, ch0) = pipes::stream();
     ch.send(move ch0);
     let ch1 = po.recv();
     // Does the transmitted channel still work?
diff --git a/src/test/run-pass/task-comm-4.rs b/src/test/run-pass/task-comm-4.rs
index 2cfb5a66346af..3f42b4d5b57f8 100644
--- a/src/test/run-pass/task-comm-4.rs
+++ b/src/test/run-pass/task-comm-4.rs
@@ -16,7 +16,7 @@ fn main() { test00(); }
 fn test00() {
     let mut r: int = 0;
     let mut sum: int = 0;
-    let (c, p) = pipes::stream();
+    let (p, c) = pipes::stream();
     c.send(1);
     c.send(2);
     c.send(3);
diff --git a/src/test/run-pass/task-comm-5.rs b/src/test/run-pass/task-comm-5.rs
index 162819b6a0033..dbf43df4069bc 100644
--- a/src/test/run-pass/task-comm-5.rs
+++ b/src/test/run-pass/task-comm-5.rs
@@ -15,7 +15,7 @@ fn main() { test00(); }
 fn test00() {
     let r: int = 0;
     let mut sum: int = 0;
-    let (c, p) = pipes::stream();
+    let (p, c) = pipes::stream();
     let number_of_messages: int = 1000;
     let mut i: int = 0;
     while i < number_of_messages { c.send(i + 0); i += 1; }
diff --git a/src/test/run-pass/trivial-message.rs b/src/test/run-pass/trivial-message.rs
index f7a083298beae..e5bcba59ea2cd 100644
--- a/src/test/run-pass/trivial-message.rs
+++ b/src/test/run-pass/trivial-message.rs
@@ -15,7 +15,7 @@ use pipes::{Port, Chan};
   message.
  */
 fn main() {
-    let (ch, po) = pipes::stream();
+    let (po, ch) = pipes::stream();
     ch.send(42);
     let r = po.recv();
     log(error, r);

From 213773ccb2b33c988366ab93993ad31e5c88b32e Mon Sep 17 00:00:00 2001
From: Tim Chevalier <chevalier@alum.wellesley.edu>
Date: Wed, 12 Dec 2012 13:38:19 -0800
Subject: [PATCH 12/23] Fix tasks tutorial tests

---
 doc/tutorial-tasks.md | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md
index 2d203400dda8e..799fcb99fd0fb 100644
--- a/doc/tutorial-tasks.md
+++ b/doc/tutorial-tasks.md
@@ -150,7 +150,7 @@ come in a variety of forms, each one appropriate for a different use case. In
 what follows, we cover the most commonly used varieties.
 
 The simplest way to create a pipe is to use the `pipes::stream`
-function to create a `(Chan, Port)` pair. In Rust parlance, a *channel*
+function to create a `(Port, Chan)` pair. In Rust parlance, a *channel*
 is a sending endpoint of a pipe, and a *port* is the receiving
 endpoint. Consider the following example of calculating two results
 concurrently:
@@ -159,7 +159,7 @@ concurrently:
 use task::spawn;
 use pipes::{stream, Port, Chan};
 
-let (chan, port): (Chan<int>, Port<int>) = stream();
+let (port, chan): (Port<int>, Chan<int>) = stream();
 
 do spawn |move chan| {
     let result = some_expensive_computation();
@@ -179,7 +179,7 @@ a tuple into its component parts).
 
 ~~~~
 # use pipes::{stream, Chan, Port};
-let (chan, port): (Chan<int>, Port<int>) = stream();
+let (port, chan): (Port<int>, Chan<int>) = stream();
 ~~~~
 
 The child task will use the channel to send data to the parent task,
@@ -191,7 +191,7 @@ spawns the child task.
 # use task::spawn;
 # use pipes::{stream, Port, Chan};
 # fn some_expensive_computation() -> int { 42 }
-# let (chan, port) = stream();
+# let (port, chan) = stream();
 do spawn |move chan| {
     let result = some_expensive_computation();
     chan.send(result);
@@ -211,7 +211,7 @@ port:
 ~~~~
 # use pipes::{stream, Port, Chan};
 # fn some_other_expensive_computation() {}
-# let (chan, port) = stream::<int>();
+# let (port, chan) = stream::<int>();
 # chan.send(0);
 some_other_expensive_computation();
 let result = port.recv();
@@ -227,7 +227,7 @@ following program is ill-typed:
 # use task::{spawn};
 # use pipes::{stream, Port, Chan};
 # fn some_expensive_computation() -> int { 42 }
-let (chan, port) = stream();
+let (port, chan) = stream();
 
 do spawn |move chan| {
     chan.send(some_expensive_computation());
@@ -247,7 +247,7 @@ Instead we can use a `SharedChan`, a type that allows a single
 # use task::spawn;
 use pipes::{stream, SharedChan};
 
-let (chan, port) = stream();
+let (port, chan) = stream();
 let chan = SharedChan(move chan);
 
 for uint::range(0, 3) |init_val| {
@@ -282,7 +282,7 @@ might look like the example below.
 
 // Create a vector of ports, one for each child task
 let ports = do vec::from_fn(3) |init_val| {
-    let (chan, port) = stream();
+    let (port, chan) = stream();
     do spawn |move chan| {
         chan.send(some_expensive_computation(init_val));
     }
@@ -397,7 +397,7 @@ before returning. Hence:
 # use task::{spawn, try};
 # fn sleep_forever() { loop { task::yield() } }
 # do task::try {
-let (sender, receiver): (Chan<int>, Port<int>) = stream();
+let (receiver, sender): (Port<int>, Chan<int>) = stream();
 do spawn |move receiver| {  // Bidirectionally linked
     // Wait for the supervised child task to exist.
     let message = receiver.recv();

From 80d6bc899b2c44fc795e9a3db61083520bda8355 Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Wed, 12 Dec 2012 14:47:03 -0800
Subject: [PATCH 13/23] Add Huon Wilson to AUTHORS.txt

---
 AUTHORS.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/AUTHORS.txt b/AUTHORS.txt
index c1b4d221de85b..c7cfc999bb456 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -54,6 +54,7 @@ Gonçalo Cabrita <_@gmcabrita.com>
 Graham Fawcett <fawcett@uwindsor.ca>
 Grahame Bowland <grahame@angrygoats.net>
 Haitao Li <lihaitao@gmail.com>
+Huon Wilson <dbau.pp+github@gmail.com>
 Ian D. Bollinger <ian.bollinger@gmail.com>
 Ivano Coppola <rgbfirefox@gmail.com>
 Jacob Harris Cryer Kragh <jhckragh@gmail.com>

From 9cced55b93a14cdca9bb86ae99b22021fac8685f Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Wed, 12 Dec 2012 10:44:01 -0800
Subject: [PATCH 14/23] syntax: remove all remaining uses of #ast, and #ast /
 qquote itself.

---
 src/librustc/middle/astencode.rs         |  35 ++-
 src/libsyntax/ext/auto_serialize.rs      |   2 +-
 src/libsyntax/ext/base.rs                |   2 -
 src/libsyntax/ext/expand.rs              |   8 +-
 src/libsyntax/ext/qquote.rs              | 370 -----------------------
 src/libsyntax/parse/parser.rs            |   7 -
 src/libsyntax/syntax.rc                  |   3 -
 src/test/compile-fail/qquote-1.rs        |  34 ++-
 src/test/compile-fail/qquote-2.rs        |  35 ++-
 src/test/run-pass-fulldeps/issue-1926.rs |   6 +-
 src/test/run-pass-fulldeps/qquote.rs     |  59 ++--
 11 files changed, 95 insertions(+), 466 deletions(-)
 delete mode 100644 src/libsyntax/ext/qquote.rs

diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index ea018bd528e20..781ac7809e70c 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -1033,6 +1033,8 @@ fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
 trait fake_ext_ctxt {
     fn cfg() -> ast::crate_cfg;
     fn parse_sess() -> parse::parse_sess;
+    fn call_site() -> span;
+    fn ident_of(st: ~str) -> ast::ident;
 }
 
 #[cfg(test)]
@@ -1042,6 +1044,16 @@ type fake_session = parse::parse_sess;
 impl fake_session: fake_ext_ctxt {
     fn cfg() -> ast::crate_cfg { ~[] }
     fn parse_sess() -> parse::parse_sess { self }
+    fn call_site() -> span {
+        codemap::span {
+            lo: codemap::BytePos(0),
+            hi: codemap::BytePos(0),
+            expn_info: None
+        }
+    }
+    fn ident_of(st: ~str) -> ast::ident {
+        self.interner.intern(@st)
+    }
 }
 
 #[cfg(test)]
@@ -1050,7 +1062,8 @@ fn mk_ctxt() -> fake_ext_ctxt {
 }
 
 #[cfg(test)]
-fn roundtrip(in_item: @ast::item) {
+fn roundtrip(in_item: Option<@ast::item>) {
+    let in_item = in_item.get();
     let bytes = do io::with_bytes_writer |wr| {
         let ebml_w = writer::Serializer(wr);
         encode_item_ast(ebml_w, in_item);
@@ -1074,45 +1087,45 @@ fn roundtrip(in_item: @ast::item) {
 #[test]
 fn test_basic() {
     let ext_cx = mk_ctxt();
-    roundtrip(#ast[item]{
+    roundtrip(quote_item!(
         fn foo() {}
-    });
+    ));
 }
 
 #[test]
 fn test_smalltalk() {
     let ext_cx = mk_ctxt();
-    roundtrip(#ast[item]{
+    roundtrip(quote_item!(
         fn foo() -> int { 3 + 4 } // first smalltalk program ever executed.
-    });
+    ));
 }
 
 #[test]
 fn test_more() {
     let ext_cx = mk_ctxt();
-    roundtrip(#ast[item]{
+    roundtrip(quote_item!(
         fn foo(x: uint, y: uint) -> uint {
             let z = x + y;
             return z;
         }
-    });
+    ));
 }
 
 #[test]
 fn test_simplification() {
     let ext_cx = mk_ctxt();
-    let item_in = ast::ii_item(#ast[item] {
+    let item_in = ast::ii_item(quote_item!(
         fn new_int_alist<B: Copy>() -> alist<int, B> {
             fn eq_int(&&a: int, &&b: int) -> bool { a == b }
             return {eq_fn: eq_int, mut data: ~[]};
         }
-    });
+    ).get());
     let item_out = simplify_ast(item_in);
-    let item_exp = ast::ii_item(#ast[item] {
+    let item_exp = ast::ii_item(quote_item!(
         fn new_int_alist<B: Copy>() -> alist<int, B> {
             return {eq_fn: eq_int, mut data: ~[]};
         }
-    });
+    ).get());
     match (item_out, item_exp) {
       (ast::ii_item(item_out), ast::ii_item(item_exp)) => {
         assert pprust::item_to_str(item_out, ext_cx.parse_sess().interner)
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs
index 44fa8ac7a1bc6..9830a5b1434fb 100644
--- a/src/libsyntax/ext/auto_serialize.rs
+++ b/src/libsyntax/ext/auto_serialize.rs
@@ -309,7 +309,7 @@ priv impl ext_ctxt {
     fn lambda(blk: ast::blk) -> @ast::expr {
         let ext_cx = self;
         let blk_e = self.expr(blk.span, ast::expr_block(blk));
-        #ast{ || $(blk_e) }
+        quote_expr!( || $blk_e )
     }
 
     fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk {
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 312c6cc16f7a5..10e42a6facfa5 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -109,8 +109,6 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
     syntax_expanders.insert(~"log_syntax",
                             builtin_normal_tt(
                                 ext::log_syntax::expand_syntax_ext));
-    syntax_expanders.insert(~"ast",
-                            builtin(ext::qquote::expand_ast));
     syntax_expanders.insert(~"deriving_eq",
                             item_decorator(
                                 ext::deriving::expand_deriving_eq));
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index e9d871752aae3..489a1cb3c2205 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -14,7 +14,6 @@ use ast::{crate, expr_, expr_mac, mac_invoc, mac_invoc_tt,
           tt_delim, tt_tok, item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
 use fold::*;
 use ext::base::*;
-use ext::qquote::{qq_helper};
 use parse::{parser, parse_expr_from_source_str, new_parser_from_tts};
 
 
@@ -169,7 +168,12 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
               None | Some(normal(_)) | Some(macro_defining(_))
               | Some(normal_tt(_)) | Some(item_tt(*)) => items,
               Some(item_decorator(dec_fn)) => {
-                dec_fn(cx, attr.span, attr.node.value, items)
+                  cx.bt_push(ExpandedFrom({call_site: attr.span,
+                                           callie: {name: copy mname,
+                                                    span: None}}));
+                  let r = dec_fn(cx, attr.span, attr.node.value, items);
+                  cx.bt_pop();
+                  r
               }
             }
         }
diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs
deleted file mode 100644
index e13dfe750b790..0000000000000
--- a/src/libsyntax/ext/qquote.rs
+++ /dev/null
@@ -1,370 +0,0 @@
-// 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.
-
-use ast::{crate, expr_, mac_invoc,
-                     mac_aq, mac_var};
-use parse::parser;
-use parse::parser::{Parser, parse_from_source_str};
-use dvec::DVec;
-use parse::token::ident_interner;
-use codemap::{CharPos, BytePos};
-
-use fold::*;
-use visit::*;
-use ext::base::*;
-use ext::build::*;
-use print::*;
-use io::*;
-
-use codemap::span;
-
-struct gather_item {
-    lo: BytePos,
-    hi: BytePos,
-    e: @ast::expr,
-    constr: ~str
-}
-
-type aq_ctxt = @{lo: BytePos, gather: DVec<gather_item>};
-enum fragment {
-    from_expr(@ast::expr),
-    from_ty(@ast::Ty)
-}
-
-fn ids_ext(cx: ext_ctxt, strs: ~[~str]) -> ~[ast::ident] {
-    strs.map(|str| cx.parse_sess().interner.intern(@*str))
-}
-fn id_ext(cx: ext_ctxt, str: ~str) -> ast::ident {
-    cx.parse_sess().interner.intern(@str)
-}
-
-
-trait qq_helper {
-    fn span() -> span;
-    fn visit(aq_ctxt, vt<aq_ctxt>);
-    fn extract_mac() -> Option<ast::mac_>;
-    fn mk_parse_fn(ext_ctxt,span) -> @ast::expr;
-    fn get_fold_fn() -> ~str;
-}
-
-impl @ast::crate: qq_helper {
-    fn span() -> span {self.span}
-    fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);}
-    fn extract_mac() -> Option<ast::mac_> {fail}
-    fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
-        mk_path(cx, sp,
-                ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_crate"]))
-    }
-    fn get_fold_fn() -> ~str {~"fold_crate"}
-}
-impl @ast::expr: qq_helper {
-    fn span() -> span {self.span}
-    fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_expr(self, cx, v);}
-    fn extract_mac() -> Option<ast::mac_> {
-        match (self.node) {
-          ast::expr_mac({node: ref mac, _}) => Some((*mac)),
-          _ => None
-        }
-    }
-    fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
-        mk_path(cx, sp,
-                ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_expr"]))
-    }
-    fn get_fold_fn() -> ~str {~"fold_expr"}
-}
-impl @ast::Ty: qq_helper {
-    fn span() -> span {self.span}
-    fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_ty(self, cx, v);}
-    fn extract_mac() -> Option<ast::mac_> {
-        match (self.node) {
-          ast::ty_mac({node: ref mac, _}) => Some((*mac)),
-          _ => None
-        }
-    }
-    fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
-        mk_path(cx, sp,
-                ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_ty"]))
-    }
-    fn get_fold_fn() -> ~str {~"fold_ty"}
-}
-impl @ast::item: qq_helper {
-    fn span() -> span {self.span}
-    fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_item(self, cx, v);}
-    fn extract_mac() -> Option<ast::mac_> {fail}
-    fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
-        mk_path(cx, sp,
-                ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_item"]))
-    }
-    fn get_fold_fn() -> ~str {~"fold_item"}
-}
-impl @ast::stmt: qq_helper {
-    fn span() -> span {self.span}
-    fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_stmt(self, cx, v);}
-    fn extract_mac() -> Option<ast::mac_> {fail}
-    fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
-        mk_path(cx, sp,
-                ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_stmt"]))
-    }
-    fn get_fold_fn() -> ~str {~"fold_stmt"}
-}
-impl @ast::pat: qq_helper {
-    fn span() -> span {self.span}
-    fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);}
-    fn extract_mac() -> Option<ast::mac_> {fail}
-    fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
-        mk_path(cx, sp, ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote",
-                                      ~"parse_pat"]))
-    }
-    fn get_fold_fn() -> ~str {~"fold_pat"}
-}
-
-fn gather_anti_quotes<N: qq_helper>(lo: BytePos, node: N) -> aq_ctxt
-{
-    let v = @{visit_expr: |node, &&cx, v| visit_aq(node, ~"from_expr", cx, v),
-              visit_ty: |node, &&cx, v| visit_aq(node, ~"from_ty", cx, v),
-              .. *default_visitor()};
-    let cx = @{lo:lo, gather: DVec()};
-    node.visit(cx, mk_vt(v));
-    // FIXME (#2250): Maybe this is an overkill (merge_sort), it might
-    // be better to just keep the gather array in sorted order.
-    do cx.gather.swap |v| {
-        pure fn by_lo(a: &gather_item, b: &gather_item) -> bool {
-            a.lo < b.lo
-        }
-        std::sort::merge_sort(v, by_lo)
-    };
-    return cx;
-}
-
-fn visit_aq<T:qq_helper>(node: T, constr: ~str, &&cx: aq_ctxt, v: vt<aq_ctxt>)
-{
-    match (node.extract_mac()) {
-      Some(mac_aq(sp, e)) => {
-        cx.gather.push(gather_item {
-            lo: sp.lo - cx.lo,
-            hi: sp.hi - cx.lo,
-            e: e,
-            constr: constr});
-      }
-      _ => node.visit(cx, v)
-    }
-}
-
-fn is_space(c: char) -> bool {
-    parse::lexer::is_whitespace(c)
-}
-
-fn expand_ast(ecx: ext_ctxt, _sp: span,
-              arg: ast::mac_arg, body: ast::mac_body)
-    -> @ast::expr
-{
-    let mut what = ~"expr";
-    do arg.iter |arg| {
-        let args: ~[@ast::expr] =
-            match arg.node {
-              ast::expr_vec(elts, _) => elts,
-              _ => {
-                ecx.span_fatal
-                    (_sp, ~"#ast requires arguments of the form `~[...]`.")
-              }
-            };
-        if vec::len::<@ast::expr>(args) != 1u {
-            ecx.span_fatal(_sp, ~"#ast requires exactly one arg");
-        }
-        match (args[0].node) {
-          ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u
-            => what = *ecx.parse_sess().interner.get(id[0]),
-          _ => ecx.span_fatal(args[0].span, ~"expected an identifier")
-        }
-    }
-    let body = get_mac_body(ecx,_sp,body);
-
-    return match what {
-      ~"crate" => finish(ecx, body, parse_crate),
-      ~"expr" => finish(ecx, body, parse_expr),
-      ~"ty" => finish(ecx, body, parse_ty),
-      ~"item" => finish(ecx, body, parse_item),
-      ~"stmt" => finish(ecx, body, parse_stmt),
-      ~"pat" => finish(ecx, body, parse_pat),
-      _ => ecx.span_fatal(_sp, ~"unsupported ast type")
-    };
-}
-
-fn parse_crate(p: Parser) -> @ast::crate { p.parse_crate_mod(~[]) }
-fn parse_ty(p: Parser) -> @ast::Ty { p.parse_ty(false) }
-fn parse_stmt(p: Parser) -> @ast::stmt { p.parse_stmt(~[]) }
-fn parse_expr(p: Parser) -> @ast::expr { p.parse_expr() }
-fn parse_pat(p: Parser) -> @ast::pat { p.parse_pat(true) }
-
-fn parse_item(p: Parser) -> @ast::item {
-    match p.parse_item(~[]) {
-      Some(item) => item,
-      None       => fail ~"parse_item: parsing an item failed"
-    }
-}
-
-fn finish<T: qq_helper>
-    (ecx: ext_ctxt, body: ast::mac_body_, f: fn (p: Parser) -> T)
-    -> @ast::expr
-{
-    let cm = ecx.codemap();
-    let str = @cm.span_to_snippet(body.span);
-    debug!("qquote--str==%?", str);
-    let fname = cm.mk_substr_filename(body.span);
-    let node = parse_from_source_str
-        (f, fname, codemap::FssInternal(body.span), str,
-         ecx.cfg(), ecx.parse_sess());
-    let loc = cm.lookup_char_pos(body.span.lo);
-
-    let sp = node.span();
-    let qcx = gather_anti_quotes(sp.lo, node);
-    let cx = qcx;
-
-    for uint::range(1u, cx.gather.len()) |i| {
-        assert cx.gather[i-1u].lo < cx.gather[i].lo;
-        // ^^ check that the vector is sorted
-        assert cx.gather[i-1u].hi <= cx.gather[i].lo;
-        // ^^ check that the spans are non-overlapping
-    }
-
-    let mut str2 = ~"";
-    enum state {active, skip(uint), blank};
-    let mut state = active;
-    let mut i = BytePos(0u);
-    let mut j = 0u;
-    let g_len = cx.gather.len();
-    for str::chars_each(*str) |ch| {
-        if (j < g_len && i == cx.gather[j].lo) {
-            assert ch == '$';
-            let repl = fmt!("$%u ", j);
-            state = skip(str::char_len(repl));
-            str2 += repl;
-        }
-        match copy state {
-          active => str::push_char(&mut str2, ch),
-          skip(1u) => state = blank,
-          skip(sk) => state = skip (sk-1u),
-          blank if is_space(ch) => str::push_char(&mut str2, ch),
-          blank => str::push_char(&mut str2, ' ')
-        }
-        i += BytePos(1u);
-        if (j < g_len && i == cx.gather[j].hi) {
-            assert ch == ')';
-            state = active;
-            j += 1u;
-        }
-    }
-
-    let cx = ecx;
-
-    let cfg_call = || mk_call_(
-        cx, sp, mk_access(cx, sp, ids_ext(cx, ~[~"ext_cx"]),
-                          id_ext(cx, ~"cfg")), ~[]);
-
-    let parse_sess_call = || mk_call_(
-        cx, sp, mk_access(cx, sp, ids_ext(cx, ~[~"ext_cx"]),
-                          id_ext(cx, ~"parse_sess")), ~[]);
-
-    let pcall = mk_call(cx,sp,
-                       ids_ext(cx, ~[~"syntax", ~"parse", ~"parser",
-                        ~"parse_from_source_str"]),
-                       ~[node.mk_parse_fn(cx,sp),
-                        mk_uniq_str(cx,sp, fname),
-                        mk_call(cx,sp,
-                                ids_ext(cx, ~[~"syntax",~"ext",
-                                 ~"qquote", ~"mk_file_substr"]),
-                                ~[mk_uniq_str(cx,sp, loc.file.name),
-                                 mk_uint(cx,sp, loc.line),
-                                 mk_uint(cx,sp, loc.col.to_uint())]),
-                        mk_unary(cx,sp, ast::box(ast::m_imm),
-                                 mk_uniq_str(cx,sp, str2)),
-                        cfg_call(),
-                        parse_sess_call()]
-                      );
-    let mut rcall = pcall;
-    if (g_len > 0u) {
-        rcall = mk_call(cx,sp,
-                        ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote",
-                                      ~"replace"]),
-                        ~[pcall,
-                          mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec(|g| {
-                             mk_call(cx,sp,
-                                     ids_ext(cx, ~[~"syntax", ~"ext",
-                                                   ~"qquote", g.constr]),
-                                     ~[g.e])})),
-                         mk_path(cx,sp,
-                                 ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote",
-                                               node.get_fold_fn()]))]);
-    }
-    return rcall;
-}
-
-fn replace<T>(node: T, repls: ~[fragment], ff: fn (ast_fold, T) -> T)
-    -> T
-{
-    let aft = default_ast_fold();
-    let f_pre = @{fold_expr: |a,b,c|replace_expr(repls, a, b, c,
-                                                  aft.fold_expr),
-                  fold_ty: |a,b,c|replace_ty(repls, a, b, c,
-                                              aft.fold_ty),
-                  .. *aft};
-    return ff(make_fold(f_pre), node);
-}
-fn fold_crate(f: ast_fold, &&n: @ast::crate) -> @ast::crate {
-    @f.fold_crate(*n)
-}
-fn fold_expr(f: ast_fold, &&n: @ast::expr) -> @ast::expr {f.fold_expr(n)}
-fn fold_ty(f: ast_fold, &&n: @ast::Ty) -> @ast::Ty {f.fold_ty(n)}
-fn fold_item(f: ast_fold, &&n: @ast::item) -> @ast::item {
-    f.fold_item(n).get() //HACK: we know we don't drop items
-}
-fn fold_stmt(f: ast_fold, &&n: @ast::stmt) -> @ast::stmt {f.fold_stmt(n)}
-fn fold_pat(f: ast_fold, &&n: @ast::pat) -> @ast::pat {f.fold_pat(n)}
-
-fn replace_expr(repls: ~[fragment],
-                e: ast::expr_, s: span, fld: ast_fold,
-                orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span))
-    -> (ast::expr_, span)
-{
-    match e {
-      ast::expr_mac({node: mac_var(i), _}) => match (repls[i]) {
-        from_expr(r) => (r.node, r.span),
-        _ => fail /* fixme error message */
-      },
-      _ => orig(e,s,fld)
-    }
-}
-
-fn replace_ty(repls: ~[fragment],
-                e: ast::ty_, s: span, fld: ast_fold,
-                orig: fn@(ast::ty_, span, ast_fold)->(ast::ty_, span))
-    -> (ast::ty_, span)
-{
-    match e {
-      ast::ty_mac({node: mac_var(i), _}) => match (repls[i]) {
-        from_ty(r) => (r.node, r.span),
-        _ => fail /* fixme error message */
-      },
-      _ => orig(e,s,fld)
-    }
-}
-
-fn mk_file_substr(fname: ~str, line: uint, col: uint) ->
-    codemap::FileSubstr {
-    codemap::FssExternal({filename: fname, line: line, col: CharPos(col)})
-}
-
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 709d1537d4178..ead0de78f6e7f 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -81,13 +81,6 @@ use ast::{_mod, add, arg, arm, attribute,
 
 export Parser;
 
-// FIXME (#3726): #ast expects to find this here but it's actually
-// defined in `parse` Fixing this will be easier when we have export
-// decls on individual items -- then parse can export this publicly, and
-// everything else crate-visibly.
-use parse::parse_from_source_str;
-export parse_from_source_str;
-
 export item_or_view_item, iovi_none, iovi_view_item, iovi_item;
 
 enum restriction {
diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc
index 66052767bd4d7..c85b033be84e4 100644
--- a/src/libsyntax/syntax.rc
+++ b/src/libsyntax/syntax.rc
@@ -75,9 +75,6 @@ mod ext {
     #[legacy_exports]
     #[path = "ext/expand.rs"]
     mod expand;
-    #[legacy_exports]
-    #[path = "ext/qquote.rs"]
-    mod qquote;
 
     #[path = "ext/quote.rs"]
     mod quote;
diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs
index 2f854c57a0755..a343158337d09 100644
--- a/src/test/compile-fail/qquote-1.rs
+++ b/src/test/compile-fail/qquote-1.rs
@@ -21,36 +21,44 @@ use syntax::codemap;
 use syntax::parse;
 use syntax::print::*;
 
-fn new_parse_sess() -> parse::parse_sess {
-  fail;
-}
 
 trait fake_ext_ctxt {
-    fn session() -> fake_session;
+    fn cfg() -> ast::crate_cfg;
+    fn parse_sess() -> parse::parse_sess;
+    fn call_site() -> span;
+    fn ident_of(st: ~str) -> ast::ident;
 }
 
-type fake_options = {cfg: ast::crate_cfg};
-
-type fake_session = {opts: @fake_options,
-                     parse_sess: parse::parse_sess};
+type fake_session = parse::parse_sess;
 
 impl fake_session: fake_ext_ctxt {
-    fn session() -> fake_session {self}
+    fn cfg() -> ast::crate_cfg { ~[] }
+    fn parse_sess() -> parse::parse_sess { self }
+    fn call_site() -> span {
+        codemap::span {
+            lo: codemap::BytePos(0),
+            hi: codemap::BytePos(0),
+            expn_info: None
+        }
+    }
+    fn ident_of(st: ~str) -> ast::ident {
+        self.interner.intern(@st)
+    }
 }
 
 fn mk_ctxt() -> fake_ext_ctxt {
-    let opts : fake_options = {cfg: ~[]};
-    {opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt
+    parse::new_parse_sess(None) as fake_ext_ctxt
 }
 
 
+
 fn main() {
     let ext_cx = mk_ctxt();
 
-    let abc = #ast{23};
+    let abc = quote_expr!(23);
     check_pp(abc,  pprust::print_expr, "23");
 
-    let expr3 = #ast{2 - $(abcd) + 7}; //~ ERROR unresolved name: abcd
+    let expr3 = quote_expr!(2 - $abcd + 7); //~ ERROR unresolved name: abcd
     check_pp(expr3,  pprust::print_expr, "2 - 23 + 7");
 }
 
diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs
index 1abb8a8fa696a..b7e33f99e3b48 100644
--- a/src/test/compile-fail/qquote-2.rs
+++ b/src/test/compile-fail/qquote-2.rs
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// xfail-test Can't use syntax crate here
 
 extern mod std;
-use syntax;
+extern mod syntax;
 
 use std::io::*;
 
@@ -20,33 +21,39 @@ use syntax::codemap;
 use syntax::parse::parser;
 use syntax::print::*;
 
-fn new_parse_sess() -> parser::parse_sess {
-  fail;
-}
-
 trait fake_ext_ctxt {
-    fn session() -> fake_session;
+    fn cfg() -> ast::crate_cfg;
+    fn parse_sess() -> parse::parse_sess;
+    fn call_site() -> span;
+    fn ident_of(st: ~str) -> ast::ident;
 }
 
-type fake_options = {cfg: ast::crate_cfg};
-
-type fake_session = {opts: @fake_options,
-                     parse_sess: parser::parse_sess};
+type fake_session = parse::parse_sess;
 
 impl fake_session: fake_ext_ctxt {
-    fn session() -> fake_session {self}
+    fn cfg() -> ast::crate_cfg { ~[] }
+    fn parse_sess() -> parse::parse_sess { self }
+    fn call_site() -> span {
+        codemap::span {
+            lo: codemap::BytePos(0),
+            hi: codemap::BytePos(0),
+            expn_info: None
+        }
+    }
+    fn ident_of(st: ~str) -> ast::ident {
+        self.interner.intern(@st)
+    }
 }
 
 fn mk_ctxt() -> fake_ext_ctxt {
-    let opts : fake_options = {cfg: ~[]};
-    {opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt
+    parse::new_parse_sess(None) as fake_ext_ctxt
 }
 
 
 fn main() {
     let ext_cx = mk_ctxt();
 
-    let stmt = #ast[stmt]{let x int = 20;}; //~ ERROR expected end-of-string
+    let stmt = quote_stmt!(let x int = 20;); //~ ERROR expected end-of-string
     check_pp(*stmt,  pprust::print_stmt, "");
 }
 
diff --git a/src/test/run-pass-fulldeps/issue-1926.rs b/src/test/run-pass-fulldeps/issue-1926.rs
index 03cd6d3fed41b..7d52f13b0750a 100644
--- a/src/test/run-pass-fulldeps/issue-1926.rs
+++ b/src/test/run-pass-fulldeps/issue-1926.rs
@@ -55,8 +55,8 @@ fn mk_ctxt() -> fake_ext_ctxt {
 
 fn main() {
     let ext_cx = mk_ctxt();
-    let s = #ast[expr]{__s};
-    let e = #ast[expr]{__e};
-    let f = #ast[expr]{$(s).foo {|__e| $(e)}};
+    let s = quote_expr!(__s);
+    let e = quote_expr!(__e);
+    let f = quote_expr!($s.foo {|__e| $e});
     log(error, pprust::expr_to_str(f));
 }
diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs
index e3b7928b7ac5a..3345dcaaad02a 100644
--- a/src/test/run-pass-fulldeps/qquote.rs
+++ b/src/test/run-pass-fulldeps/qquote.rs
@@ -20,12 +20,16 @@ use io::*;
 use syntax::diagnostic;
 use syntax::ast;
 use syntax::codemap;
+use syntax::codemap::span;
 use syntax::parse;
 use syntax::print::*;
 
+
 trait fake_ext_ctxt {
     fn cfg() -> ast::crate_cfg;
     fn parse_sess() -> parse::parse_sess;
+    fn call_site() -> span;
+    fn ident_of(st: ~str) -> ast::ident;
 }
 
 type fake_session = parse::parse_sess;
@@ -33,66 +37,41 @@ type fake_session = parse::parse_sess;
 impl fake_session: fake_ext_ctxt {
     fn cfg() -> ast::crate_cfg { ~[] }
     fn parse_sess() -> parse::parse_sess { self }
+    fn call_site() -> span {
+        codemap::span {
+            lo: codemap::BytePos(0),
+            hi: codemap::BytePos(0),
+            expn_info: None
+        }
+    }
+    fn ident_of(st: ~str) -> ast::ident {
+        self.interner.intern(@copy st)
+    }
 }
 
 fn mk_ctxt() -> fake_ext_ctxt {
     parse::new_parse_sess(None) as fake_ext_ctxt
 }
 
-
 fn main() {
     let ext_cx = mk_ctxt();
 
-    let abc = #ast{23};
+    let abc = quote_expr!(23);
     check_pp(ext_cx, abc,  pprust::print_expr, ~"23");
 
-    let expr3 = #ast{2 - $(abc) + 7};
-    check_pp(ext_cx, expr3,  pprust::print_expr, ~"2 - 23 + 7");
-
-    let expr4 = #ast{2 - $(#ast{3}) + 9};
-    check_pp(ext_cx, expr4,  pprust::print_expr, ~"2 - 3 + 9");
 
-    let ty = #ast[ty]{int};
+    let ty = quote_ty!(int);
     check_pp(ext_cx, ty, pprust::print_type, ~"int");
 
-    let ty2 = #ast[ty]{option<$(ty)>};
-    check_pp(ext_cx, ty2, pprust::print_type, ~"option<int>");
-
-    let item = #ast[item]{const x : int = 10;};
+    let item = quote_item!(const x : int = 10;).get();
     check_pp(ext_cx, item, pprust::print_item, ~"const x: int = 10;");
 
-    let item2: @ast::item = #ast[item]{const x : int = $(abc);};
-    check_pp(ext_cx, item2, pprust::print_item, ~"const x: int = 23;");
-
-    let stmt = #ast[stmt]{let x = 20;};
+    let stmt = quote_stmt!(let x = 20;);
     check_pp(ext_cx, *stmt, pprust::print_stmt, ~"let x = 20;");
 
-    let stmt2 = #ast[stmt]{let x : $(ty) = $(abc);};
-    check_pp(ext_cx, *stmt2, pprust::print_stmt, ~"let x: int = 23;");
-
-    let pat = #ast[pat]{some(_)};
+    let pat = quote_pat!(some(_));
     check_pp(ext_cx, pat, pprust::print_refutable_pat, ~"some(_)");
 
-    // issue #1785
-    let x = #ast{1};
-    let test1 = #ast{1+$(x)};
-    check_pp(ext_cx, test1, pprust::print_expr, ~"1 + 1");
-
-    let test2 = #ast{$(x)+1};
-    check_pp(ext_cx, test2, pprust::print_expr, ~"1 + 1");
-
-    let y = #ast{2};
-    let test3 = #ast{$(x) + $(y)};
-    check_pp(ext_cx, test3, pprust::print_expr, ~"1 + 2");
-
-    let crate = #ast[crate] { fn a() { } };
-    check_pp(ext_cx, crate, pprust::print_crate_, ~"fn a() { }\n");
-
-    // issue #1926
-    let s = #ast[expr]{__s};
-    let e = #ast[expr]{__e};
-    let call = #ast[expr]{$(s).foo(|__e| $(e) )};
-    check_pp(ext_cx, call, pprust::print_expr, ~"__s.foo(|__e| __e)")
 }
 
 fn check_pp<T>(cx: fake_ext_ctxt,

From e24ae85025e40aa17915f6c604d89aefbca274bd Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Wed, 12 Dec 2012 12:25:40 -0800
Subject: [PATCH 15/23] syntax: remove most code handling old-style syntax
 extensions.

---
 src/libsyntax/ast.rs                          |   6 -
 src/libsyntax/ext/base.rs                     |  17 +-
 src/libsyntax/ext/expand.rs                   |  97 +--
 src/libsyntax/ext/quote.rs                    |   1 -
 src/libsyntax/ext/simplext.rs                 | 750 ------------------
 src/libsyntax/fold.rs                         |   7 -
 src/libsyntax/parse/attr.rs                   |  35 -
 src/libsyntax/parse/lexer.rs                  |   5 -
 src/libsyntax/parse/parser.rs                 | 112 +--
 src/libsyntax/parse/token.rs                  |   8 -
 src/libsyntax/print/pprust.rs                 |  16 -
 src/libsyntax/syntax.rc                       |   3 -
 src/libsyntax/visit.rs                        |  11 +-
 src/test/compile-fail/issue-1448-1.rs         |  17 -
 src/test/compile-fail/macro-2.rs              |  20 -
 src/test/compile-fail/macro.rs                |  18 -
 src/test/run-pass/macro-3.rs                  |  22 -
 src/test/run-pass/macro-by-example-1.rs       |  24 -
 src/test/run-pass/macro-by-example-2.rs       |  60 --
 src/test/run-pass/macro.rs                    |  21 -
 .../includeme.fragment                        |   6 +-
 21 files changed, 30 insertions(+), 1226 deletions(-)
 delete mode 100644 src/libsyntax/ext/simplext.rs
 delete mode 100644 src/test/compile-fail/issue-1448-1.rs
 delete mode 100644 src/test/compile-fail/macro-2.rs
 delete mode 100644 src/test/compile-fail/macro.rs
 delete mode 100644 src/test/run-pass/macro-3.rs
 delete mode 100644 src/test/run-pass/macro-by-example-1.rs
 delete mode 100644 src/test/run-pass/macro-by-example-2.rs
 delete mode 100644 src/test/run-pass/macro.rs

diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index b36555e01ef7e..160dc43a3b91e 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -842,13 +842,7 @@ type mac_body = Option<mac_body_>;
 #[auto_serialize]
 #[auto_deserialize]
 enum mac_ {
-    mac_invoc(@path, mac_arg, mac_body), // old macro-invocation
     mac_invoc_tt(@path,~[token_tree]),   // new macro-invocation
-    mac_ellipsis,                        // old pattern-match (obsolete)
-
-    // the span is used by the quoter/anti-quoter ...
-    mac_aq(span /* span of quote */, @expr), // anti-quote
-    mac_var(uint)
 }
 
 type lit = spanned<lit_>;
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 10e42a6facfa5..08f8746c45e2a 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -16,16 +16,16 @@ use ast_util::dummy_sp;
 
 // obsolete old-style #macro code:
 //
-//    syntax_expander, normal, macro_defining, macro_definer,
-//    builtin
+//    syntax_expander, normal, builtin
 //
 // new-style macro! tt code:
 //
 //    syntax_expander_tt, syntax_expander_tt_item, mac_result,
 //    normal_tt, item_tt
 //
-// also note that ast::mac has way too many cases and can probably
-// be trimmed down substantially.
+// also note that ast::mac used to have a bunch of extraneous cases and
+// is now probably a redundant AST node, can be merged with
+// ast::mac_invoc_tt.
 
 // second argument is the span to blame for general argument problems
 type syntax_expander_ =
@@ -35,10 +35,6 @@ type syntax_expander = {expander: syntax_expander_, span: Option<span>};
 
 type macro_def = {name: ~str, ext: syntax_extension};
 
-// macro_definer is obsolete, remove when #old_macros go away.
-type macro_definer =
-    fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> macro_def;
-
 type item_decorator =
     fn@(ext_ctxt, span, ast::meta_item, ~[@ast::item]) -> ~[@ast::item];
 
@@ -63,9 +59,6 @@ enum syntax_extension {
     // normal() is obsolete, remove when #old_macros go away.
     normal(syntax_expander),
 
-    // macro_defining() is obsolete, remove when #old_macros go away.
-    macro_defining(macro_definer),
-
     // #[auto_serialize] and such. will probably survive death of #old_macros
     item_decorator(item_decorator),
 
@@ -89,8 +82,6 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
         item_tt({expander: f, span: None})
     }
     let syntax_expanders = HashMap();
-    syntax_expanders.insert(~"macro",
-                            macro_defining(ext::simplext::add_new_extension));
     syntax_expanders.insert(~"macro_rules",
                             builtin_item_tt(
                                 ext::tt::macro_rules::add_new_extension));
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 489a1cb3c2205..391edbbb7993e 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -10,7 +10,7 @@
 
 use std::map::HashMap;
 
-use ast::{crate, expr_, expr_mac, mac_invoc, mac_invoc_tt,
+use ast::{crate, expr_, expr_mac, mac_invoc_tt,
           tt_delim, tt_tok, item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
 use fold::*;
 use ext::base::*;
@@ -31,51 +31,6 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
           expr_mac(ref mac) => {
 
             match (*mac).node {
-              // Old-style macros. For compatibility, will erase this whole
-              // block once we've transitioned.
-              mac_invoc(pth, args, body) => {
-                assert (vec::len(pth.idents) > 0u);
-                /* using idents and token::special_idents would make the
-                the macro names be hygienic */
-                let extname = cx.parse_sess().interner.get(pth.idents[0]);
-                match exts.find(*extname) {
-                  None => {
-                    cx.span_fatal(pth.span,
-                                  fmt!("macro undefined: '%s'", *extname))
-                  }
-                  Some(item_decorator(_)) => {
-                    cx.span_fatal(
-                        pth.span,
-                        fmt!("%s can only be used as a decorator", *extname));
-                  }
-                  Some(normal({expander: exp, span: exp_sp})) => {
-
-                    cx.bt_push(ExpandedFrom({call_site: s,
-                                callie: {name: *extname, span: exp_sp}}));
-                    let expanded = exp(cx, (*mac).span, args, body);
-
-                    //keep going, outside-in
-                    let fully_expanded = fld.fold_expr(expanded).node;
-                    cx.bt_pop();
-
-                    (fully_expanded, s)
-                  }
-                  Some(macro_defining(ext)) => {
-                    let named_extension = ext(cx, (*mac).span, args, body);
-                    exts.insert(named_extension.name, named_extension.ext);
-                    (ast::expr_rec(~[], None), s)
-                  }
-                  Some(normal_tt(_)) => {
-                    cx.span_fatal(pth.span,
-                                  fmt!("this tt-style macro should be \
-                                        invoked '%s!(...)'", *extname))
-                  }
-                  Some(item_tt(*)) => {
-                    cx.span_fatal(pth.span,
-                                  ~"cannot use item macros in this context");
-                  }
-                }
-              }
 
               // Token-tree macros, these will be the only case when we're
               // finished transitioning.
@@ -130,7 +85,6 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
 
                 }
               }
-              _ => cx.span_bug((*mac).span, ~"naked syntactic bit")
             }
           }
           _ => orig(e, s, fld)
@@ -165,8 +119,8 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
               ast::meta_list(ref n, _) => (*n)
             };
             match exts.find(mname) {
-              None | Some(normal(_)) | Some(macro_defining(_))
-              | Some(normal_tt(_)) | Some(item_tt(*)) => items,
+              None | Some(normal(_))
+                | Some(normal_tt(_)) | Some(item_tt(*)) => items,
               Some(item_decorator(dec_fn)) => {
                   cx.bt_push(ExpandedFrom({call_site: attr.span,
                                            callie: {name: copy mname,
@@ -209,36 +163,16 @@ fn expand_item(exts: HashMap<~str, syntax_extension>,
     }
 }
 
-// avoid excess indentation when a series of nested `match`es
-// has only one "good" outcome
-macro_rules! biased_match (
-    (   ($e    :expr) ~ ($p    :pat) else $err    :stmt ;
-     $( ($e_cdr:expr) ~ ($p_cdr:pat) else $err_cdr:stmt ; )*
-     => $body:expr
-    ) => (
-        match $e {
-            $p => {
-                biased_match!($( ($e_cdr) ~ ($p_cdr) else $err_cdr ; )*
-                              => $body)
-            }
-            _ => { $err }
-        }
-    );
-    ( => $body:expr ) => ( $body )
-)
-
-
 // Support for item-position macro invocations, exactly the same
 // logic as for expression-position macro invocations.
 fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
                    cx: ext_ctxt, &&it: @ast::item,
                    fld: ast_fold) -> Option<@ast::item> {
-    let (pth, tts) = biased_match!(
-        (it.node) ~ (item_mac({node: mac_invoc_tt(pth, ref tts), _})) else {
-            cx.span_bug(it.span, ~"invalid item macro invocation")
-        };
-        => (pth, (*tts))
-    );
+
+    let (pth, tts) = match it.node {
+        item_mac({node: mac_invoc_tt(pth, ref tts), _}) => (pth, (*tts)),
+        _ => cx.span_bug(it.span, ~"invalid item macro invocation")
+    };
 
     let extname = cx.parse_sess().interner.get(pth.idents[0]);
     let expanded = match exts.find(*extname) {
@@ -293,12 +227,15 @@ fn expand_stmt(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
                orig: fn@(&&s: stmt_, span, ast_fold) -> (stmt_, span))
     -> (stmt_, span)
 {
-    let (mac, pth, tts, semi) = biased_match! (
-        (s)        ~ (stmt_mac(ref mac, semi))   else return orig(s, sp, fld);
-        ((*mac).node) ~ (mac_invoc_tt(pth, ref tts)) else {
-            cx.span_bug((*mac).span, ~"naked syntactic bit")
-        };
-        => ((*mac), pth, (*tts), semi));
+
+    let (mac, pth, tts, semi) = match s {
+        stmt_mac(ref mac, semi) => {
+            match (*mac).node {
+                mac_invoc_tt(pth, ref tts) => ((*mac), pth, (*tts), semi)
+            }
+        }
+        _ => return orig(s, sp, fld)
+    };
 
     assert(vec::len(pth.idents) == 1u);
     let extname = cx.parse_sess().interner.get(pth.idents[0]);
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 60918121e9547..1e5d4ea8d16f8 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -406,7 +406,6 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr {
         AT => "AT",
         DOT => "DOT",
         DOTDOT => "DOTDOT",
-        ELLIPSIS => "ELLIPSIS",
         COMMA => "COMMA",
         SEMI => "SEMI",
         COLON => "COLON",
diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs
deleted file mode 100644
index f13c5c9aff9ea..0000000000000
--- a/src/libsyntax/ext/simplext.rs
+++ /dev/null
@@ -1,750 +0,0 @@
-// 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.
-
-use codemap::span;
-use std::map::HashMap;
-use dvec::DVec;
-
-use base::*;
-
-use fold::*;
-use ast_util::respan;
-use ast::{ident, path, Ty, blk_, expr, expr_path,
-             expr_vec, expr_mac, mac_invoc, node_id, expr_index};
-
-export add_new_extension;
-
-fn path_to_ident(pth: @path) -> Option<ident> {
-    if vec::len(pth.idents) == 1u && vec::len(pth.types) == 0u {
-        return Some(pth.idents[0u]);
-    }
-    return None;
-}
-
-//a vec of binders might be a little big.
-type clause = {params: binders, body: @expr};
-
-/* logically, an arb_depth should contain only one kind of matchable */
-enum arb_depth<T> { leaf(T), seq(@~[arb_depth<T>], span), }
-
-
-enum matchable {
-    match_expr(@expr),
-    match_path(@path),
-    match_ident(ast::spanned<ident>),
-    match_ty(@Ty),
-    match_block(ast::blk),
-    match_exact, /* don't bind anything, just verify the AST traversal */
-}
-
-/* for when given an incompatible bit of AST */
-fn match_error(cx: ext_ctxt, m: matchable, expected: ~str) -> ! {
-    match m {
-      match_expr(x) => cx.span_fatal(
-          x.span, ~"this argument is an expr, expected " + expected),
-      match_path(x) => cx.span_fatal(
-          x.span, ~"this argument is a path, expected " + expected),
-      match_ident(x) => cx.span_fatal(
-          x.span, ~"this argument is an ident, expected " + expected),
-      match_ty(x) => cx.span_fatal(
-          x.span, ~"this argument is a type, expected " + expected),
-      match_block(ref x) => cx.span_fatal(
-          (*x).span, ~"this argument is a block, expected " + expected),
-      match_exact => cx.bug(~"what is a match_exact doing in a bindings?")
-    }
-}
-
-// We can't make all the matchables in a match_result the same type because
-// idents can be paths, which can be exprs.
-
-// If we want better match failure error messages (like in Fortifying Syntax),
-// we'll want to return something indicating amount of progress and location
-// of failure instead of `none`.
-type match_result = Option<arb_depth<matchable>>;
-type selector = fn@(matchable) -> match_result;
-
-fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) ->
-   {pre: ~[@expr], rep: Option<@expr>, post: ~[@expr]} {
-    let mut idx: uint = 0u;
-    let mut res = None;
-    for elts.each |elt| {
-        match elt.node {
-          expr_mac(ref m) => match (*m).node {
-            ast::mac_ellipsis => {
-                if res.is_some() {
-                    cx.span_fatal((*m).span, ~"only one ellipsis allowed");
-                }
-                res =
-                    Some({pre: vec::slice(elts, 0u, idx - 1u),
-                          rep: Some(elts[idx - 1u]),
-                          post: vec::slice(elts, idx + 1u, vec::len(elts))});
-            }
-            _ => ()
-          },
-          _ => ()
-        }
-        idx += 1u;
-    }
-    return match res {
-          Some(val) => val,
-          None => {pre: elts, rep: None, post: ~[]}
-    }
-}
-
-fn option_flatten_map<T: Copy, U: Copy>(f: fn@(T) -> Option<U>, v: ~[T]) ->
-   Option<~[U]> {
-    let mut res = ~[];
-    for v.each |elem| {
-        match f(*elem) {
-          None => return None,
-          Some(ref fv) => res.push((*fv))
-        }
-    }
-    return Some(res);
-}
-
-fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result {
-    match ad {
-      leaf(ref x) => return f((*x)),
-      seq(ads, span) => match option_flatten_map(|x| a_d_map(x, f), *ads) {
-        None => return None,
-        Some(ts) => return Some(seq(@ts, span))
-      }
-    }
-}
-
-fn compose_sels(s1: selector, s2: selector) -> selector {
-    fn scomp(s1: selector, s2: selector, m: matchable) -> match_result {
-        return match s1(m) {
-              None => None,
-              Some(ref matches) => a_d_map((*matches), s2)
-            }
-    }
-    return { |x| scomp(s1, s2, x) };
-}
-
-
-
-type binders =
-    {real_binders: HashMap<ident, selector>,
-     literal_ast_matchers: DVec<selector>};
-type bindings = HashMap<ident, arb_depth<matchable>>;
-
-fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
-
-/* these three functions are the big moving parts */
-
-/* create the selectors needed to bind and verify the pattern */
-
-fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
-    let res: binders =
-        {real_binders: HashMap(),
-         literal_ast_matchers: DVec()};
-    //this oughta return binders instead, but macro args are a sequence of
-    //expressions, rather than a single expression
-    fn trivial_selector(m: matchable) -> match_result {
-        return Some(leaf(m));
-    }
-    p_t_s_rec(cx, match_expr(e), trivial_selector, res);
-    move res
-}
-
-
-
-/* use the selectors on the actual arguments to the macro to extract
-bindings. Most of the work is done in p_t_s, which generates the
-selectors. */
-
-fn use_selectors_to_bind(b: binders, e: @expr) -> Option<bindings> {
-    let res = HashMap();
-    //need to do this first, to check vec lengths.
-    for b.literal_ast_matchers.each |sel| {
-        match (*sel)(match_expr(e)) { None => return None, _ => () }
-    }
-    let mut never_mind: bool = false;
-    for b.real_binders.each |key, val| {
-        match val(match_expr(e)) {
-          None => never_mind = true,
-          Some(ref mtc) => { res.insert(key, (*mtc)); }
-        }
-    };
-    //HACK: `ret` doesn't work in `for each`
-    if never_mind { return None; }
-    return Some(res);
-}
-
-/* use the bindings on the body to generate the expanded code */
-
-fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr {
-    let idx_path: @mut ~[uint] = @mut ~[];
-    fn new_id(_old: node_id, cx: ext_ctxt) -> node_id { return cx.next_id(); }
-    fn new_span(cx: ext_ctxt, sp: span) -> span {
-        /* this discards information in the case of macro-defining macros */
-        return span {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()};
-    }
-    let afp = default_ast_fold();
-    let f_pre =
-        @{fold_ident: |x,y|transcribe_ident(cx, b, idx_path, x, y),
-          fold_path: |x,y|transcribe_path(cx, b, idx_path, x, y),
-          fold_expr: |x,y,z|
-              transcribe_expr(cx, b, idx_path, x, y, z, afp.fold_expr)
-          ,
-          fold_ty: |x,y,z|
-              transcribe_type(cx, b, idx_path,
-                              x, y, z, afp.fold_ty)
-          ,
-          fold_block: |x,y,z|
-              transcribe_block(cx, b, idx_path, x, y, z, afp.fold_block)
-          ,
-          map_exprs: |x,y|
-              transcribe_exprs(cx, b, idx_path, x, y)
-          ,
-          new_id: |x|new_id(x, cx),
-          .. *afp};
-    let f = make_fold(f_pre);
-    let result = f.fold_expr(body);
-    return result;
-}
-
-
-/* helper: descend into a matcher */
-pure fn follow(m: arb_depth<matchable>, idx_path: &[uint]) ->
-   arb_depth<matchable> {
-    let mut res: arb_depth<matchable> = m;
-    for vec::each(idx_path) |idx| {
-        res = match res {
-          leaf(_) => return res,/* end of the line */
-          seq(new_ms, _) => new_ms[*idx]
-        }
-    }
-    return res;
-}
-
-fn follow_for_trans(cx: ext_ctxt, mmaybe: Option<arb_depth<matchable>>,
-                    idx_path: @mut ~[uint]) -> Option<matchable> {
-    match mmaybe {
-      None => return None,
-      Some(ref m) => {
-        return match follow((*m), *idx_path) {
-              seq(_, sp) => {
-                cx.span_fatal(sp,
-                              ~"syntax matched under ... but not " +
-                                  ~"used that way.")
-              }
-              leaf(ref m) => return Some((*m))
-            }
-      }
-    }
-
-}
-
-/* helper for transcribe_exprs: what vars from `b` occur in `e`? */
-fn free_vars(b: bindings, e: @expr, it: fn(ident)) {
-    let idents = HashMap();
-    fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings,
-                  idents: HashMap<ident, ()>) -> ident {
-        if b.contains_key(i) { idents.insert(i, ()); }
-        return i;
-    }
-    // using fold is a hack: we want visit, but it doesn't hit idents ) :
-    // solve this with macros
-    let f_pre =
-        @{fold_ident: |x,y|mark_ident(x, y, b, idents),
-          .. *default_ast_fold()};
-    let f = make_fold(f_pre);
-    f.fold_expr(e); // ignore result
-    for idents.each_key |x| { it(x); };
-}
-
-fn wrong_occurs(cx: ext_ctxt, l: ident, l_c: uint, r: ident, r_c: uint)
-    -> ~str {
-    fmt!("'%s' occurs %u times, but '%s' occurs %u times",
-         *cx.parse_sess().interner.get(l), l_c,
-         *cx.parse_sess().interner.get(r), r_c)
-}
-
-/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
-fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
-                    recur: fn@(&&v: @expr) -> @expr,
-                    exprs: ~[@expr]) -> ~[@expr] {
-    match elts_to_ell(cx, exprs) {
-      {pre: pre, rep: repeat_me_maybe, post: post} => {
-        let mut res = vec::map(pre, |x| recur(*x));
-        match repeat_me_maybe {
-          None => (),
-          Some(repeat_me) => {
-            let mut repeat: Option<{rep_count: uint, name: ident}> = None;
-            /* we need to walk over all the free vars in lockstep, except for
-            the leaves, which are just duplicated */
-            do free_vars(b, repeat_me) |fv| {
-                let fv_depth = b.get(fv);
-                let cur_pos = follow(fv_depth, *idx_path);
-                match cur_pos {
-                  leaf(_) => (),
-                  seq(ms, _) => {
-                    match repeat {
-                      None => {
-                        repeat = Some({rep_count: vec::len(*ms), name: fv});
-                      }
-                      Some({rep_count: old_len, name: old_name}) => {
-                        let len = vec::len(*ms);
-                        if old_len != len {
-                            let msg = wrong_occurs(cx, fv, len,
-                                                   old_name, old_len);
-                            cx.span_fatal(repeat_me.span, msg);
-                        }
-                      }
-                    }
-                  }
-                }
-            };
-            match repeat {
-              None => {
-                cx.span_fatal(repeat_me.span,
-                              ~"'...' surrounds an expression without any" +
-                                  ~" repeating syntax variables");
-              }
-              Some({rep_count: rc, _}) => {
-                /* Whew, we now know how how many times to repeat */
-                let mut idx: uint = 0u;
-                while idx < rc {
-                    idx_path.push(idx);
-                    res.push(recur(repeat_me)); // whew!
-                    idx_path.pop();
-                    idx += 1u;
-                }
-              }
-            }
-          }
-        }
-        res = vec::append(res, vec::map(post, |x| recur(*x)));
-        return res;
-      }
-    }
-}
-
-
-
-// substitute, in a position that's required to be an ident
-fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
-                    &&i: ident, _fld: ast_fold) -> ident {
-    return match follow_for_trans(cx, b.find(i), idx_path) {
-          Some(match_ident(a_id)) => a_id.node,
-          Some(ref m) => match_error(cx, (*m), ~"an identifier"),
-          None => i
-        }
-}
-
-
-fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
-                   p: path, _fld: ast_fold) -> path {
-    // Don't substitute into qualified names.
-    if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { return p; }
-    match follow_for_trans(cx, b.find(p.idents[0]), idx_path) {
-      Some(match_ident(id)) => {
-        {span: id.span, global: false, idents: ~[id.node],
-         rp: None, types: ~[]}
-      }
-      Some(match_path(a_pth)) => *a_pth,
-      Some(ref m) => match_error(cx, (*m), ~"a path"),
-      None => p
-    }
-}
-
-
-fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
-                   e: ast::expr_, s: span, fld: ast_fold,
-                   orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span))
-    -> (ast::expr_, span)
-{
-    return match e {
-          expr_path(p) => {
-            // Don't substitute into qualified names.
-            if vec::len(p.types) > 0u || vec::len(p.idents) != 1u {
-                (e, s);
-            }
-            match follow_for_trans(cx, b.find(p.idents[0]), idx_path) {
-              Some(match_ident(id)) => {
-                (expr_path(@{span: id.span,
-                             global: false,
-                             idents: ~[id.node],
-                             rp: None,
-                             types: ~[]}), id.span)
-              }
-              Some(match_path(a_pth)) => (expr_path(a_pth), s),
-              Some(match_expr(a_exp)) => (a_exp.node, a_exp.span),
-              Some(ref m) => match_error(cx, (*m), ~"an expression"),
-              None => orig(e, s, fld)
-            }
-          }
-          _ => orig(e, s, fld)
-        }
-}
-
-fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
-                   t: ast::ty_, s: span, fld: ast_fold,
-                   orig: fn@(ast::ty_, span, ast_fold) -> (ast::ty_, span))
-    -> (ast::ty_, span)
-{
-    return match t {
-          ast::ty_path(pth, _) => {
-            match path_to_ident(pth) {
-              Some(id) => {
-                match follow_for_trans(cx, b.find(id), idx_path) {
-                  Some(match_ty(ty)) => (ty.node, ty.span),
-                  Some(ref m) => match_error(cx, (*m), ~"a type"),
-                  None => orig(t, s, fld)
-                }
-              }
-              None => orig(t, s, fld)
-            }
-          }
-          _ => orig(t, s, fld)
-        }
-}
-
-
-/* for parsing reasons, syntax variables bound to blocks must be used like
-`{v}` */
-
-fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
-                    blk: blk_, s: span, fld: ast_fold,
-                    orig: fn@(blk_, span, ast_fold) -> (blk_, span))
-    -> (blk_, span)
-{
-    return match block_to_ident(blk) {
-          Some(id) => {
-            match follow_for_trans(cx, b.find(id), idx_path) {
-              Some(match_block(ref new_blk)) => {
-                ((*new_blk).node, (*new_blk).span)
-              }
-
-              // possibly allow promotion of ident/path/expr to blocks?
-              Some(ref m) => match_error(cx, (*m), ~"a block"),
-              None => orig(blk, s, fld)
-            }
-          }
-          None => orig(blk, s, fld)
-        }
-}
-
-
-/* traverse the pattern, building instructions on how to bind the actual
-argument. ps accumulates instructions on navigating the tree.*/
-fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) {
-
-    //it might be possible to traverse only exprs, not matchables
-    match m {
-      match_expr(e) => {
-        match e.node {
-          expr_path(p_pth) => p_t_s_r_path(cx, p_pth, s, b),
-          expr_vec(p_elts, _) => {
-            match elts_to_ell(cx, p_elts) {
-              {pre: pre, rep: Some(repeat_me), post: post} => {
-                p_t_s_r_length(cx, vec::len(pre) + vec::len(post), true, s,
-                               b);
-                if vec::len(pre) > 0u {
-                    p_t_s_r_actual_vector(cx, pre, true, s, b);
-                }
-                p_t_s_r_ellipses(cx, repeat_me, vec::len(pre), s, b);
-
-                if vec::len(post) > 0u {
-                    cx.span_unimpl(e.span,
-                                   ~"matching after `...` not yet supported");
-                }
-              }
-              {pre: pre, rep: None, post: post} => {
-                if post.len() > 0 {
-                    cx.bug(~"elts_to_ell provided an invalid result");
-                }
-                p_t_s_r_length(cx, vec::len(pre), false, s, b);
-                p_t_s_r_actual_vector(cx, pre, false, s, b);
-              }
-            }
-          }
-          /* FIXME (#2251): handle embedded types and blocks, at least */
-          expr_mac(ref mac) => {
-            p_t_s_r_mac(cx, (*mac), s, b);
-          }
-          _ => {
-            fn select(cx: ext_ctxt, m: matchable, pat: @expr) ->
-               match_result {
-                return match m {
-                      match_expr(e) => {
-                        if managed::ptr_eq(e, pat) {
-                            // XXX: Is this right?
-                            Some(leaf(match_exact))
-                        } else {
-                            None
-                        }
-                      }
-                      _ => cx.bug(~"broken traversal in p_t_s_r")
-                    }
-            }
-            b.literal_ast_matchers.push(|x| select(cx, x, e));
-          }
-        }
-      }
-      _ => cx.bug(~"undocumented invariant in p_t_s_rec")
-    }
-}
-
-
-/* make a match more precise */
-fn specialize_match(m: matchable) -> matchable {
-    return match m {
-          match_expr(e) => {
-            match e.node {
-              expr_path(pth) => {
-                match path_to_ident(pth) {
-                  Some(id) => match_ident(respan(pth.span, id)),
-                  None => match_path(pth)
-                }
-              }
-              _ => m
-            }
-          }
-          _ => m
-        }
-}
-
-/* pattern_to_selectors helper functions */
-fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) {
-    match path_to_ident(p) {
-      Some(p_id) => {
-        fn select(cx: ext_ctxt, m: matchable) -> match_result {
-            return match m {
-                  match_expr(*) => Some(leaf(specialize_match(m))),
-                  _ => cx.bug(~"broken traversal in p_t_s_r")
-                }
-        }
-        if b.real_binders.contains_key(p_id) {
-            cx.span_fatal(p.span, ~"duplicate binding identifier");
-        }
-        b.real_binders.insert(p_id, compose_sels(s, |x| select(cx, x)));
-      }
-      None => ()
-    }
-}
-
-fn block_to_ident(blk: blk_) -> Option<ident> {
-    if vec::len(blk.stmts) != 0u { return None; }
-    return match blk.expr {
-          Some(expr) => match expr.node {
-            expr_path(pth) => path_to_ident(pth),
-            _ => None
-          },
-          None => None
-        }
-}
-
-fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) {
-    fn select_pt_1(cx: ext_ctxt, m: matchable,
-                   fn_m: fn(ast::mac) -> match_result) -> match_result {
-        return match m {
-              match_expr(e) => match e.node {
-                expr_mac(ref mac) => fn_m((*mac)),
-                _ => None
-              },
-              _ => cx.bug(~"broken traversal in p_t_s_r")
-            }
-    }
-    fn no_des(cx: ext_ctxt, sp: span, syn: ~str) -> ! {
-        cx.span_fatal(sp, ~"destructuring " + syn + ~" is not yet supported");
-    }
-    match mac.node {
-      ast::mac_ellipsis => cx.span_fatal(mac.span, ~"misused `...`"),
-      ast::mac_invoc(_, _, _) => no_des(cx, mac.span, ~"macro calls"),
-      ast::mac_invoc_tt(_, _) => no_des(cx, mac.span, ~"macro calls"),
-      ast::mac_aq(_,_) => no_des(cx, mac.span, ~"antiquotes"),
-      ast::mac_var(_) => no_des(cx, mac.span, ~"antiquote variables")
-    }
-}
-
-fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector,
-                    b: binders) {
-    fn select(cx: ext_ctxt, repeat_me: @expr, offset: uint, m: matchable) ->
-       match_result {
-        return match m {
-              match_expr(e) => {
-                match e.node {
-                  expr_vec(arg_elts, _) => {
-                    let mut elts = ~[];
-                    let mut idx = offset;
-                    while idx < vec::len(arg_elts) {
-                        elts.push(leaf(match_expr(arg_elts[idx])));
-                        idx += 1u;
-                    }
-
-                    // using repeat_me.span is a little wacky, but the
-                    // error we want to report is one in the macro def
-                    Some(seq(@elts, repeat_me.span))
-                  }
-                  _ => None
-                }
-              }
-              _ => cx.bug(~"broken traversal in p_t_s_r")
-            }
-    }
-    p_t_s_rec(cx, match_expr(repeat_me),
-              compose_sels(s, |x| select(cx, repeat_me, offset, x)), b);
-}
-
-
-fn p_t_s_r_length(cx: ext_ctxt, len: uint, at_least: bool, s: selector,
-                  b: binders) {
-    fn len_select(_cx: ext_ctxt, m: matchable, at_least: bool, len: uint) ->
-       match_result {
-        return match m {
-              match_expr(e) => {
-                match e.node {
-                  expr_vec(arg_elts, _) => {
-                    let actual_len = vec::len(arg_elts);
-                    if at_least && actual_len >= len || actual_len == len {
-                        Some(leaf(match_exact))
-                    } else { None }
-                  }
-                  _ => None
-                }
-              }
-              _ => None
-            }
-    }
-    b.literal_ast_matchers.push(
-        compose_sels(s, |x| len_select(cx, x, at_least, len)));
-}
-
-fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool,
-                         s: selector, b: binders) {
-    let mut idx: uint = 0u;
-    while idx < vec::len(elts) {
-        fn select(cx: ext_ctxt, m: matchable, idx: uint) -> match_result {
-            return match m {
-                  match_expr(e) => {
-                    match e.node {
-                      expr_vec(arg_elts, _) => {
-                        Some(leaf(match_expr(arg_elts[idx])))
-                      }
-                      _ => None
-                    }
-                  }
-                  _ => cx.bug(~"broken traversal in p_t_s_r")
-                }
-        }
-        p_t_s_rec(cx, match_expr(elts[idx]),
-                  compose_sels(s, |x, copy idx| select(cx, x, idx)), b);
-        idx += 1u;
-    }
-}
-
-fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-                     _body: ast::mac_body) -> base::macro_def {
-    let args = get_mac_args_no_max(cx, sp, arg, 0u, ~"macro");
-
-    let mut macro_name: Option<~str> = None;
-    let mut clauses: ~[@clause] = ~[];
-    for args.each |arg| {
-        match arg.node {
-          expr_vec(elts, _) => {
-            if vec::len(elts) != 2u {
-                cx.span_fatal((*arg).span,
-                              ~"extension clause must consist of ~[" +
-                                  ~"macro invocation, expansion body]");
-            }
-
-
-            match elts[0u].node {
-              expr_mac(ref mac) => {
-                match (*mac).node {
-                  mac_invoc(pth, invoc_arg, _) => {
-                    match path_to_ident(pth) {
-                      Some(id) => {
-                        let id_str = cx.str_of(id);
-                        match macro_name {
-                          None => macro_name = Some(id_str),
-                          Some(ref other_id) => if id_str != (*other_id) {
-                            cx.span_fatal(pth.span,
-                                          ~"macro name must be " +
-                                          ~"consistent");
-                          }
-                        }
-                      },
-                      None => cx.span_fatal(pth.span,
-                                            ~"macro name must not be a path")
-                    }
-                    let arg = match invoc_arg {
-                      Some(arg) => arg,
-                      None => cx.span_fatal((*mac).span,
-                                           ~"macro must have arguments")
-                    };
-                    clauses.push(@{params: pattern_to_selectors(cx, arg),
-                                   body: elts[1u]});
-
-                    // FIXME (#2251): check duplicates (or just simplify
-                    // the macro arg situation)
-                  }
-                  _ => {
-                      cx.span_bug((*mac).span, ~"undocumented invariant in \
-                         add_extension");
-                  }
-                }
-              }
-              _ => {
-                cx.span_fatal(elts[0u].span,
-                              ~"extension clause must" +
-                                  ~" start with a macro invocation.");
-              }
-            }
-          }
-          _ => {
-            cx.span_fatal((*arg).span,
-                          ~"extension must be ~[clause, " + ~" ...]");
-          }
-        }
-    }
-
-    let ext = |a,b,c,d, move clauses| generic_extension(a,b,c,d,clauses);
-
-    return {name:
-             match macro_name {
-               Some(ref id) => (*id),
-               None => cx.span_fatal(sp, ~"macro definition must have " +
-                                     ~"at least one clause")
-             },
-         ext: normal({expander: ext, span: Some(arg.get().span)})};
-
-    fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-                         _body: ast::mac_body,
-                         clauses: ~[@clause]) -> @expr {
-        let arg = match arg {
-          Some(arg) => arg,
-          None => cx.span_fatal(sp, ~"macro must have arguments")
-        };
-        for clauses.each |c| {
-            match use_selectors_to_bind(c.params, arg) {
-              Some(bindings) => return transcribe(cx, bindings, c.body),
-              None => loop
-            }
-        }
-        cx.span_fatal(sp, ~"no clauses match macro invocation");
-    }
-}
-
-
-
-//
-// Local Variables:
-// mode: rust
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 110fc664b0704..93845f3dbb859 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -120,14 +120,7 @@ fn fold_arg_(a: arg, fld: ast_fold) -> arg {
 fn fold_mac_(m: mac, fld: ast_fold) -> mac {
     return {node:
              match m.node {
-               mac_invoc(pth, arg, body) => {
-                 mac_invoc(fld.fold_path(pth),
-                           option::map(&arg, |x| fld.fold_expr(*x)), body)
-               }
                mac_invoc_tt(*) => m.node,
-               mac_ellipsis => mac_ellipsis,
-               mac_aq(_,_) => /* FIXME (#2543) */ copy m.node,
-               mac_var(_) => /* FIXME (#2543) */ copy m.node,
              },
          span: fld.new_span(m.span)};
 }
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index 3f0b031bd066b..7248a0e224476 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -12,16 +12,9 @@ use either::{Either, Left, Right};
 use ast_util::spanned;
 use common::*; //resolve bug?
 
-export attr_or_ext;
 export parser_attr;
 
-// A type to distingush between the parsing of item attributes or syntax
-// extensions, which both begin with token.POUND
-type attr_or_ext = Option<Either<~[ast::attribute], @ast::expr>>;
-
 trait parser_attr {
-    fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute])
-        -> attr_or_ext;
     fn parse_outer_attributes() -> ~[ast::attribute];
     fn parse_attribute(style: ast::attr_style) -> ast::attribute;
     fn parse_attribute_naked(style: ast::attr_style, lo: BytePos) ->
@@ -35,34 +28,6 @@ trait parser_attr {
 
 impl Parser: parser_attr {
 
-    fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute])
-        -> attr_or_ext
-    {
-        let expect_item_next = vec::is_not_empty(first_item_attrs);
-        match self.token {
-          token::POUND => {
-            let lo = self.span.lo;
-            if self.look_ahead(1u) == token::LBRACKET {
-                self.bump();
-                let first_attr =
-                    self.parse_attribute_naked(ast::attr_outer, lo);
-                return Some(Left(vec::append(~[first_attr],
-                                          self.parse_outer_attributes())));
-            } else if !(self.look_ahead(1u) == token::LT
-                        || self.look_ahead(1u) == token::LBRACKET
-                        || self.look_ahead(1u) == token::POUND
-                        || expect_item_next) {
-                self.bump();
-                return Some(Right(self.parse_syntax_ext_naked(lo)));
-            } else { return None; }
-        }
-        token::DOC_COMMENT(_) => {
-          return Some(Left(self.parse_outer_attributes()));
-        }
-        _ => return None
-      }
-    }
-
     // Parse attributes that appear before an item
     fn parse_outer_attributes() -> ~[ast::attribute] {
         let mut attrs: ~[ast::attribute] = ~[];
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 3763a74b9d24d..c4e34311b8898 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -515,11 +515,6 @@ fn next_token_inner(rdr: string_reader) -> token::Token {
             bump(rdr);
             return token::DOTDOT;
         }
-        if rdr.curr == '.' && nextch(rdr) == '.' {
-            bump(rdr);
-            bump(rdr);
-            return token::ELLIPSIS;
-        }
         return token::DOT;
       }
       '(' => { bump(rdr); return token::LPAREN; }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index ead0de78f6e7f..625ff289607f6 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -54,8 +54,8 @@ use ast::{_mod, add, arg, arm, attribute,
              item_foreign_mod, item_impl, item_mac, item_mod, item_trait,
              item_ty, lit, lit_, lit_bool, lit_float, lit_float_unsuffixed,
              lit_int, lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local,
-             m_const, m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis, mac_invoc,
-             mac_invoc_tt, mac_var, matcher, match_nonterminal, match_seq,
+             m_const, m_imm, m_mutbl, mac_,
+             mac_invoc_tt, matcher, match_nonterminal, match_seq,
              match_tok, method, mode, module_ns, mt, mul, mutability,
              named_field, neg, noreturn, not, pat, pat_box, pat_enum,
              pat_ident, pat_lit, pat_range, pat_rec, pat_region, pat_struct,
@@ -510,15 +510,6 @@ impl Parser {
 
         let lo = self.span.lo;
 
-        match self.maybe_parse_dollar_mac() {
-          Some(ref e) => {
-            return @{id: self.get_id(),
-                  node: ty_mac(spanned(lo, self.span.hi, (*e))),
-                  span: mk_sp(lo, self.span.hi)};
-          }
-          None => ()
-        }
-
         let t = if self.token == token::LPAREN {
             self.bump();
             if self.token == token::RPAREN {
@@ -730,32 +721,6 @@ impl Parser {
         }
     }
 
-    fn maybe_parse_dollar_mac() -> Option<mac_> {
-        match copy self.token {
-          token::DOLLAR => {
-            let lo = self.span.lo;
-            self.bump();
-            match copy self.token {
-              token::LIT_INT_UNSUFFIXED(num) => {
-                self.bump();
-                Some(mac_var(num as uint))
-              }
-              token::LPAREN => {
-                self.bump();
-                let e = self.parse_expr();
-                self.expect(token::RPAREN);
-                let hi = self.last_span.hi;
-                Some(mac_aq(mk_sp(lo,hi), e))
-              }
-              _ => {
-                self.fatal(~"expected `(` or unsuffixed integer literal");
-              }
-            }
-          }
-          _ => None
-        }
-    }
-
     fn maybe_parse_fixed_vstore_with_star() -> Option<uint> {
         if self.eat(token::BINOP(token::STAR)) {
             match copy self.token {
@@ -928,11 +893,6 @@ impl Parser {
 
         let mut ex: expr_;
 
-        match self.maybe_parse_dollar_mac() {
-          Some(ref x) => return self.mk_mac_expr(lo, self.span.hi, (*x)),
-          _ => ()
-        }
-
         if self.token == token::LPAREN {
             self.bump();
             if self.token == token::RPAREN {
@@ -1022,13 +982,6 @@ impl Parser {
                 }
             }
             hi = self.span.hi;
-        } else if self.token == token::ELLIPSIS {
-            self.bump();
-            return self.mk_mac_expr(lo, self.span.hi, mac_ellipsis);
-        } else if self.token == token::POUND {
-            let ex_ext = self.parse_syntax_ext();
-            hi = ex_ext.span.hi;
-            ex = ex_ext.node;
         } else if self.eat_keyword(~"fail") {
             if can_begin_expr(self.token) {
                 let e = self.parse_expr();
@@ -1141,54 +1094,6 @@ impl Parser {
         return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk));
     }
 
-    fn parse_syntax_ext() -> @expr {
-        let lo = self.span.lo;
-        self.expect(token::POUND);
-        return self.parse_syntax_ext_naked(lo);
-    }
-
-    fn parse_syntax_ext_naked(lo: BytePos) -> @expr {
-        match self.token {
-          token::IDENT(_, _) => (),
-          _ => self.fatal(~"expected a syntax expander name")
-        }
-        let pth = self.parse_path_without_tps();
-        //temporary for a backwards-compatible cycle:
-        let sep = seq_sep_trailing_disallowed(token::COMMA);
-        let mut e = None;
-        if (self.token == token::LPAREN || self.token == token::LBRACKET) {
-            let lo = self.span.lo;
-            let es =
-                if self.token == token::LPAREN {
-                    self.parse_unspanned_seq(token::LPAREN, token::RPAREN,
-                                             sep, |p| p.parse_expr())
-                } else {
-                    self.parse_unspanned_seq(token::LBRACKET, token::RBRACKET,
-                                             sep, |p| p.parse_expr())
-                };
-            let hi = self.span.hi;
-            e = Some(self.mk_expr(lo, hi, expr_vec(es, m_imm)));
-        }
-        let mut b = None;
-        if self.token == token::LBRACE {
-            self.bump();
-            let lo = self.span.lo;
-            let mut depth = 1u;
-            while (depth > 0u) {
-                match (self.token) {
-                  token::LBRACE => depth += 1u,
-                  token::RBRACE => depth -= 1u,
-                  token::EOF => self.fatal(~"unexpected EOF in macro body"),
-                  _ => ()
-                }
-                self.bump();
-            }
-            let hi = self.last_span.lo;
-            b = Some({span: mk_sp(lo,hi)});
-        }
-        return self.mk_mac_expr(lo, self.span.hi, mac_invoc(pth, e, b));
-    }
-
     fn parse_dot_or_call_expr() -> @expr {
         let b = self.parse_bottom_expr();
         self.parse_dot_or_call_expr_with(b)
@@ -2253,17 +2158,8 @@ impl Parser {
             }
 
         } else {
-            let mut item_attrs;
-            match self.parse_outer_attrs_or_ext(first_item_attrs) {
-              None => item_attrs = ~[],
-              Some(Left(ref attrs)) => item_attrs = (*attrs),
-              Some(Right(ext)) => {
-                return @spanned(lo, ext.span.hi,
-                                stmt_expr(ext, self.get_id()));
-              }
-            }
-
-            let item_attrs = vec::append(first_item_attrs, item_attrs);
+            let item_attrs = vec::append(first_item_attrs,
+                                         self.parse_outer_attributes());
 
             match self.parse_item_or_view_item(item_attrs,
                                                true, false, false) {
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index a0aecd0375eba..7e7c61d2bf249 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -49,7 +49,6 @@ enum Token {
     AT,
     DOT,
     DOTDOT,
-    ELLIPSIS,
     COMMA,
     SEMI,
     COLON,
@@ -137,7 +136,6 @@ fn to_str(in: @ident_interner, t: Token) -> ~str {
       AT => ~"@",
       DOT => ~".",
       DOTDOT => ~"..",
-      ELLIPSIS => ~"...",
       COMMA => ~",",
       SEMI => ~";",
       COLON => ~":",
@@ -578,12 +576,6 @@ impl Token : cmp::Eq {
                     _ => false
                 }
             }
-            ELLIPSIS => {
-                match (*other) {
-                    ELLIPSIS => true,
-                    _ => false
-                }
-            }
             COMMA => {
                 match (*other) {
                     COMMA => true,
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index eda5ca1f91c1a..684f74f3575c4 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -590,9 +590,6 @@ fn print_item(s: ps, &&item: @ast::item) {
         pclose(s);
         end(s);
       }
-      ast::item_mac(_) => {
-        fail ~"invalid item-position syntax bit"
-      }
     }
     (s.ann.post)(ann_node);
 }
@@ -1000,16 +997,6 @@ fn print_if(s: ps, test: @ast::expr, blk: ast::blk,
 
 fn print_mac(s: ps, m: ast::mac) {
     match m.node {
-      ast::mac_invoc(path, arg, _body) => {
-        word(s.s, ~"#");
-        print_path(s, path, false);
-        match arg {
-          Some(@{node: ast::expr_vec(_, _), _}) => (),
-          _ => word(s.s, ~" ")
-        }
-        arg.iter(|a| print_expr(s, *a));
-        // FIXME: extension 'body' (#2339)
-      }
       ast::mac_invoc_tt(pth, ref tts) => {
         print_path(s, pth, false);
         word(s.s, ~"!");
@@ -1017,9 +1004,6 @@ fn print_mac(s: ps, m: ast::mac) {
         for (*tts).each() |tt| { print_tt(s, *tt); }
         pclose(s);
       }
-      ast::mac_ellipsis => word(s.s, ~"..."),
-      ast::mac_var(v) => word(s.s, fmt!("$%u", v)),
-      _ => { /* fixme */ }
     }
 }
 
diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc
index c85b033be84e4..00c3804cce16c 100644
--- a/src/libsyntax/syntax.rc
+++ b/src/libsyntax/syntax.rc
@@ -99,9 +99,6 @@ mod ext {
     }
 
 
-    #[legacy_exports]
-    #[path = "ext/simplext.rs"]
-    mod simplext;
     #[legacy_exports]
     #[path = "ext/fmt.rs"]
     mod fmt;
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 72a605dcf1168..7b406564114b8 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -379,15 +379,8 @@ fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) {
     for exprs.each |ex| { (v.visit_expr)(*ex, e, v); }
 }
 
-fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
-    match m.node {
-      ast::mac_invoc(_, arg, _) => {
-        option::map(&arg, |arg| (v.visit_expr)(*arg, e, v)); }
-      ast::mac_invoc_tt(*) => { /* no user-serviceable parts inside */ }
-      ast::mac_ellipsis => (),
-      ast::mac_aq(*) => { /* FIXME: maybe visit (Issue #2340) */ }
-      ast::mac_var(_) => ()
-    }
+fn visit_mac<E>(_m: mac, _e: E, _v: vt<E>) {
+    /* no user-serviceable parts inside */
 }
 
 fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
diff --git a/src/test/compile-fail/issue-1448-1.rs b/src/test/compile-fail/issue-1448-1.rs
deleted file mode 100644
index 187956b645af8..0000000000000
--- a/src/test/compile-fail/issue-1448-1.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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.
-
-// Regresion test for issue #1448 and #1386
-
-fn main() {
-    #macro[[#apply[f, [x, ...]], f(x, ...)]];
-    fn add(a: int, b: int) -> int { return a + b; }
-    assert (apply!(add, [y, 15]) == 16); //~ ERROR unresolved name: y
-}
diff --git a/src/test/compile-fail/macro-2.rs b/src/test/compile-fail/macro-2.rs
deleted file mode 100644
index 57ed12789ab6e..0000000000000
--- a/src/test/compile-fail/macro-2.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.
-
-//error-pattern:is an expr, expected a path
-fn main() {
-    #macro[[#mylambda[x, body],
-            {
-                fn f(x: int) -> int { return body }
-                f
-            }]];
-
-    assert (mylambda!(y * 1, y * 2)(8) == 16);
-}
diff --git a/src/test/compile-fail/macro.rs b/src/test/compile-fail/macro.rs
deleted file mode 100644
index 43ce05845ec58..0000000000000
--- a/src/test/compile-fail/macro.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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.
-
-//error-pattern:no clauses match
-
-fn main() {
-    #macro[[#trivial[], 1 * 2 * 4 * 2 * 1]];
-
-    assert (trivial!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) ==
-                16);
-}
diff --git a/src/test/run-pass/macro-3.rs b/src/test/run-pass/macro-3.rs
deleted file mode 100644
index e23651d262cc9..0000000000000
--- a/src/test/run-pass/macro-3.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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.
-
-// xfail-pretty - token trees can't pretty print
-
-fn main() {
-    #macro[[#trivial[], 1 * 2 * 4 * 2 * 1]];
-
-    assert (trivial!() == 16);
-
-    macro_rules! trivial_tt(
-        () => {1*2*4*2*1}
-    )
-    assert(trivial_tt!() == 16);
-}
diff --git a/src/test/run-pass/macro-by-example-1.rs b/src/test/run-pass/macro-by-example-1.rs
deleted file mode 100644
index 3e8bced1b889c..0000000000000
--- a/src/test/run-pass/macro-by-example-1.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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.
-
-
-fn main() {
-    #macro[[#apply[f, [x, ...]], f(x, ...)]];
-
-    macro_rules! apply_tt(
-        ($f:expr, ($($x:expr),*)) => {$f($($x),*)}
-    )
-
-    fn add(a: int, b: int) -> int { return a + b; }
-
-    assert(apply!(add, [1, 15]) == 16);
-    assert(apply!(add, [1, 15]) == 16);
-    assert(apply_tt!(add, (1, 15)) == 16);
-}
diff --git a/src/test/run-pass/macro-by-example-2.rs b/src/test/run-pass/macro-by-example-2.rs
deleted file mode 100644
index 903dc0439e580..0000000000000
--- a/src/test/run-pass/macro-by-example-2.rs
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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.
-
-// xfail-test
-// I can't for the life of me manage to untangle all of the brackets
-// in this test, so I am xfailing it...
-
-fn main() {
-    #macro[[#zip_or_unzip[[x, ...], [y, ...]], [[x, y], ...]],
-           [#zip_or_unzip[[xx, yy], ...], [[xx, ...], [yy, ...]]]];
-
-
-    assert (zip_or_unzip!([1, 2, 3, 4], [5, 6, 7, 8]) ==
-                [[1, 5], [2, 6], [3, 7], [4, 8]]);
-    assert (zip_or_unzip!([1, 5], [2, 6], [3, 7], [4, 8]) ==
-                [[1, 2, 3, 4], [5, 6, 7, 8]]);
-
-
-    #macro[[#nested[[[x, ...], ...], [[y, ...], ...]], [[[x, y], ...], ...]]];
-    assert (nested!([[1, 2, 3, 4, 5], [7, 8, 9, 10, 11, 12]],
-                    [[-1, -2, -3, -4, -5], [-7, -8, -9, -10, -11, -12]]) ==
-                [[[1, -1], [2, -2], [3, -3], [4, -4], [5, -5]],
-                 [[7, -7], [8, -8], [9, -9], [10, -10], [11, -11],
-                  [12, -12]]]);
-
-    #macro[[#dup[y, [x, ...]], [[y, x], ...]]];
-
-    assert (dup!(1, [1, 2, 3, 4]) == [[1, 1], [1, 2], [1, 3], [1, 4]]);
-
-
-    #macro[[#lambda[x, #<t>, body, #<s>],
-            {
-                fn result(x: t) -> s { return body }
-                result
-            }]];
-
-
-    assert (lambda!(i, #<uint>, i + 4u, #<uint>)(12u) == 16u);
-
-    #macro[[#sum[x, xs, ...], x + #sum[xs, ...]], [#sum[], 0]];
-
-    assert (sum!(1, 2, 3, 4) == 10);
-
-
-    #macro[[#transcr_mixed[a, as, ...], #sum[6, as, ...] * a]];
-
-    assert (transcr_mixed!(10, 5, 4, 3, 2, 1) == 210);
-
-    #macro[[#surround[pre, [xs, ...], post], [pre, xs, ..., post]]];
-
-    assert (surround!(1, [2, 3, 4], 5) == [1, 2, 3, 4, 5]);
-
-}
diff --git a/src/test/run-pass/macro.rs b/src/test/run-pass/macro.rs
deleted file mode 100644
index f928043150ede..0000000000000
--- a/src/test/run-pass/macro.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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.
-
-// xfail-pretty - token trees can't pretty print
-
-fn main() {
-    #macro[[#m1[a], a * 4]];
-    assert (m1!(2) == 8);
-
-    macro_rules! m1tt (
-        ($a:expr) => {$a*4}
-    );
-    assert(m1tt!(2) == 8);
-}
diff --git a/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment b/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment
index 17682fd67fd39..eca0881deafd5 100644
--- a/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment
+++ b/src/test/run-pass/syntax-extension-source-utils-files/includeme.fragment
@@ -1,7 +1,7 @@
 /* this is for run-pass/syntax-extension-source-utils.rs */
 
 {
-    assert(#file[].ends_with("includeme.fragment"));
-    assert(#line[] == 5u);
-    #fmt["victory robot %u", #line[]]
+    assert(file!().ends_with("includeme.fragment"));
+    assert(line!() == 5u);
+    fmt!("victory robot %u", line!())
 }

From 0138d87f8f1b9f9614e439deb14cbaabad6d104c Mon Sep 17 00:00:00 2001
From: Tim Chevalier <chevalier@alum.wellesley.edu>
Date: Wed, 12 Dec 2012 16:22:30 -0800
Subject: [PATCH 16/23] Document pub use foo::* in the reference manual

r=brson

Closes #3788
---
 doc/rust.md | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/doc/rust.md b/doc/rust.md
index 7a88086e0ddd7..a17e3dcd2308d 100644
--- a/doc/rust.md
+++ b/doc/rust.md
@@ -847,10 +847,25 @@ fn main() {
 
 Like items, `use` declarations are private to the containing module, by default.
 Also like items, a `use` declaration can be public, if qualified by the `pub` keyword.
+Such a `use` declaration serves to _re-export_ a name.
 A public `use` declaration can therefore be used to _redirect_ some public name to a different target definition,
 even a definition with a private canonical path, inside a different module.
 If a sequence of such redirections form a cycle or cannot be unambiguously resolved, they represent a compile-time error.
 
+An example of re-exporting:
+~~~~
+mod quux {
+    mod foo {
+        pub fn bar() { }
+        pub fn baz() { }
+    }
+    
+    pub use foo::*;
+}
+~~~~
+
+In this example, the module `quux` re-exports all of the public names defined in `foo`.
+
 ### Functions
 
 A _function item_ defines a sequence of [statements](#statements) and an optional final [expression](#expressions), along with a name and a set of parameters.

From 9a4c669867765d42bdd13fc09eb9a32b7a667a43 Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Wed, 12 Dec 2012 17:08:09 -0800
Subject: [PATCH 17/23] syntax: remove remaining #syntaxext machinery. Close
 #3516.

---
 src/libsyntax/ast.rs                          |   8 -
 src/libsyntax/ext/base.rs                     | 151 ++++++------------
 src/libsyntax/ext/concat_idents.rs            |  35 ++--
 src/libsyntax/ext/env.rs                      |  17 +-
 src/libsyntax/ext/expand.rs                   |  35 +---
 src/libsyntax/ext/fmt.rs                      |  11 +-
 src/libsyntax/ext/ident_to_str.rs             |  20 ---
 src/libsyntax/ext/source_util.rs              |  76 ++++-----
 src/libsyntax/print/pp.rs                     |   4 +-
 src/libsyntax/print/pprust.rs                 |  35 ++--
 src/libsyntax/syntax.rc                       |   3 -
 src/test/compile-fail/ext-noname.rs           |  15 --
 src/test/compile-fail/extenv-no-args.rs       |   2 +-
 src/test/compile-fail/extenv-too-many-args.rs |   2 +-
 src/test/compile-fail/extfmt-no-args.rs       |   2 +-
 src/test/run-pass/class-attributes-1.rs       |   2 +-
 src/test/run-pass/syntax-extension-minor.rs   |   2 +-
 .../run-pass/syntax-extension-source-utils.rs |   2 +-
 18 files changed, 150 insertions(+), 272 deletions(-)
 delete mode 100644 src/libsyntax/ext/ident_to_str.rs
 delete mode 100644 src/test/compile-fail/ext-noname.rs

diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 160dc43a3b91e..c21aa7d248ea0 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -831,14 +831,6 @@ enum matcher_ {
 
 type mac = spanned<mac_>;
 
-type mac_arg = Option<@expr>;
-
-#[auto_serialize]
-#[auto_deserialize]
-type mac_body_ = {span: span};
-
-type mac_body = Option<mac_body_>;
-
 #[auto_serialize]
 #[auto_deserialize]
 enum mac_ {
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 08f8746c45e2a..a5ed1f5e10189 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -13,11 +13,8 @@ use parse::parser;
 use diagnostic::span_handler;
 use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom};
 use ast_util::dummy_sp;
+use parse::token;
 
-// obsolete old-style #macro code:
-//
-//    syntax_expander, normal, builtin
-//
 // new-style macro! tt code:
 //
 //    syntax_expander_tt, syntax_expander_tt_item, mac_result,
@@ -27,12 +24,6 @@ use ast_util::dummy_sp;
 // is now probably a redundant AST node, can be merged with
 // ast::mac_invoc_tt.
 
-// second argument is the span to blame for general argument problems
-type syntax_expander_ =
-    fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> @ast::expr;
-// second argument is the origin of the macro, if user-defined
-type syntax_expander = {expander: syntax_expander_, span: Option<span>};
-
 type macro_def = {name: ~str, ext: syntax_extension};
 
 type item_decorator =
@@ -56,10 +47,7 @@ enum mac_result {
 
 enum syntax_extension {
 
-    // normal() is obsolete, remove when #old_macros go away.
-    normal(syntax_expander),
-
-    // #[auto_serialize] and such. will probably survive death of #old_macros
+    // #[auto_serialize] and such
     item_decorator(item_decorator),
 
     // Token-tree expanders
@@ -73,8 +61,6 @@ enum syntax_extension {
 // A temporary hard-coded map of methods for expanding syntax extension
 // AST nodes into full ASTs
 fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
-    fn builtin(f: syntax_expander_) -> syntax_extension
-        {normal({expander: f, span: None})}
     fn builtin_normal_tt(f: syntax_expander_tt_) -> syntax_extension {
         normal_tt({expander: f, span: None})
     }
@@ -85,18 +71,19 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
     syntax_expanders.insert(~"macro_rules",
                             builtin_item_tt(
                                 ext::tt::macro_rules::add_new_extension));
-    syntax_expanders.insert(~"fmt", builtin(ext::fmt::expand_syntax_ext));
+    syntax_expanders.insert(~"fmt",
+                            builtin_normal_tt(ext::fmt::expand_syntax_ext));
     syntax_expanders.insert(
         ~"auto_serialize",
         item_decorator(ext::auto_serialize::expand_auto_serialize));
     syntax_expanders.insert(
         ~"auto_deserialize",
         item_decorator(ext::auto_serialize::expand_auto_deserialize));
-    syntax_expanders.insert(~"env", builtin(ext::env::expand_syntax_ext));
+    syntax_expanders.insert(~"env",
+                            builtin_normal_tt(ext::env::expand_syntax_ext));
     syntax_expanders.insert(~"concat_idents",
-                            builtin(ext::concat_idents::expand_syntax_ext));
-    syntax_expanders.insert(~"ident_to_str",
-                            builtin(ext::ident_to_str::expand_syntax_ext));
+                            builtin_normal_tt(
+                                ext::concat_idents::expand_syntax_ext));
     syntax_expanders.insert(~"log_syntax",
                             builtin_normal_tt(
                                 ext::log_syntax::expand_syntax_ext));
@@ -122,21 +109,29 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
                             builtin_normal_tt(ext::quote::expand_quote_stmt));
 
     syntax_expanders.insert(~"line",
-                            builtin(ext::source_util::expand_line));
+                            builtin_normal_tt(
+                                ext::source_util::expand_line));
     syntax_expanders.insert(~"col",
-                            builtin(ext::source_util::expand_col));
+                            builtin_normal_tt(
+                                ext::source_util::expand_col));
     syntax_expanders.insert(~"file",
-                            builtin(ext::source_util::expand_file));
+                            builtin_normal_tt(
+                                ext::source_util::expand_file));
     syntax_expanders.insert(~"stringify",
-                            builtin(ext::source_util::expand_stringify));
+                            builtin_normal_tt(
+                                ext::source_util::expand_stringify));
     syntax_expanders.insert(~"include",
-                            builtin(ext::source_util::expand_include));
+                            builtin_normal_tt(
+                                ext::source_util::expand_include));
     syntax_expanders.insert(~"include_str",
-                            builtin(ext::source_util::expand_include_str));
+                            builtin_normal_tt(
+                                ext::source_util::expand_include_str));
     syntax_expanders.insert(~"include_bin",
-                            builtin(ext::source_util::expand_include_bin));
+                            builtin_normal_tt(
+                                ext::source_util::expand_include_bin));
     syntax_expanders.insert(~"module_path",
-                            builtin(ext::source_util::expand_mod));
+                            builtin_normal_tt(
+                                ext::source_util::expand_mod));
     syntax_expanders.insert(~"proto",
                             builtin_item_tt(ext::pipes::expand_proto));
     syntax_expanders.insert(
@@ -292,87 +287,39 @@ fn expr_to_ident(cx: ext_ctxt,
     }
 }
 
-fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-                       min: uint, name: ~str) -> ~[@ast::expr] {
-    return get_mac_args(cx, sp, arg, min, None, name);
+fn check_zero_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree],
+                  name: &str) {
+    if tts.len() != 0 {
+        cx.span_fatal(sp, fmt!("%s takes no arguments", name));
+    }
 }
 
-fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-                min: uint, max: Option<uint>, name: ~str) -> ~[@ast::expr] {
-    match arg {
-      Some(expr) => match expr.node {
-        ast::expr_vec(elts, _) => {
-            let elts_len = vec::len(elts);
-              match max {
-                Some(max) if ! (min <= elts_len && elts_len <= max) => {
-                  cx.span_fatal(sp,
-                                fmt!("%s! takes between %u and %u arguments.",
-                                     name, min, max));
-                }
-                None if ! (min <= elts_len) => {
-                  cx.span_fatal(sp, fmt!("%s! needs at least %u arguments.",
-                                         name, min));
-                }
-                _ => return elts /* we are good */
-              }
-          }
-        _ => {
-            cx.span_fatal(sp, fmt!("%s!: malformed invocation", name))
-        }
-      },
-      None => cx.span_fatal(sp, fmt!("%s!: missing arguments", name))
+fn get_single_str_from_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree],
+                           name: &str) -> ~str {
+    if tts.len() != 1 {
+        cx.span_fatal(sp, fmt!("%s takes 1 argument.", name));
     }
-}
 
-fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body)
-    -> ast::mac_body_
-{
-    match (args) {
-      Some(body) => body,
-      None => cx.span_fatal(sp, ~"missing macro body")
+    match tts[0] {
+        ast::tt_tok(_, token::LIT_STR(ident)) => cx.str_of(ident),
+        _ =>
+        cx.span_fatal(sp, fmt!("%s requires a string.", name))
     }
 }
 
-// Massage syntactic form of new-style arguments to internal representation
-// of old-style macro args, such that old-style macro can be run and invoked
-// using new syntax. This will be obsolete when #old_macros go away.
-fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree])
-    -> ast::mac_arg {
-    use ast::{matcher, matcher_, match_tok, match_seq, match_nonterminal};
-    use parse::lexer::{new_tt_reader, reader};
-    use tt::macro_parser::{parse_or_else, matched_seq,
-                              matched_nonterminal};
-
-    // these spans won't matter, anyways
-    fn ms(m: matcher_) -> matcher {
-        {node: m, span: dummy_sp()}
+fn get_exprs_from_tts(cx: ext_ctxt, tts: ~[ast::token_tree])
+    -> ~[@ast::expr] {
+    let p = parse::new_parser_from_tts(cx.parse_sess(),
+                                       cx.cfg(),
+                                       tts);
+    let mut es = ~[];
+    while p.token != token::EOF {
+        if es.len() != 0 {
+            p.eat(token::COMMA);
+        }
+        es.push(p.parse_expr());
     }
-    let arg_nm = cx.parse_sess().interner.gensym(@~"arg");
-
-    let argument_gram = ~[ms(match_seq(~[
-        ms(match_nonterminal(arg_nm, parse::token::special_idents::expr, 0u))
-    ], Some(parse::token::COMMA), true, 0u, 1u))];
-
-    let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic,
-                                   cx.parse_sess().interner, None, arg);
-    let args =
-        match parse_or_else(cx.parse_sess(), cx.cfg(), arg_reader as reader,
-                          argument_gram).get(arg_nm) {
-          @matched_seq(s, _) => {
-            do s.map() |lf| {
-                match *lf {
-                  @matched_nonterminal(parse::token::nt_expr(arg)) =>
-                    arg, /* whew! list of exprs, here we come! */
-                  _ => fail ~"badly-structured parse result"
-                }
-            }
-          },
-          _ => fail ~"badly-structured parse result"
-        };
-
-    return Some(@{id: parse::next_node_id(cx.parse_sess()),
-               callee_id: parse::next_node_id(cx.parse_sess()),
-               node: ast::expr_vec(args, ast::m_imm), span: sp});
+    es
 }
 
 //
diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs
index b6fb3a75938af..a47b64bea3af1 100644
--- a/src/libsyntax/ext/concat_idents.rs
+++ b/src/libsyntax/ext/concat_idents.rs
@@ -10,19 +10,32 @@
 
 use base::*;
 
-fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
-                     _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args_no_max(cx,sp,arg,1u,~"concat_idents");
+fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
     let mut res_str = ~"";
-    for args.each |e| {
-        res_str += *cx.parse_sess().interner.get(
-            expr_to_ident(cx, *e, ~"expected an ident"));
+    for tts.eachi |i, e| {
+        if i & 1 == 1 {
+            match *e {
+                ast::tt_tok(_, token::COMMA) => (),
+                _ => cx.span_fatal(sp, ~"concat_idents! \
+                                         expecting comma.")
+            }
+        } else {
+            match *e {
+                ast::tt_tok(_, token::IDENT(ident,_)) =>
+                res_str += cx.str_of(ident),
+                _ => cx.span_fatal(sp, ~"concat_idents! \
+                                         requires ident args.")
+            }
+        }
     }
     let res = cx.parse_sess().interner.intern(@res_str);
 
-    return @{id: cx.next_id(),
-          callee_id: cx.next_id(),
-          node: ast::expr_path(@{span: sp, global: false, idents: ~[res],
-                                 rp: None, types: ~[]}),
-          span: sp};
+    let e = @{id: cx.next_id(),
+              callee_id: cx.next_id(),
+              node: ast::expr_path(@{span: sp, global: false,
+                                     idents: ~[res],
+                                     rp: None, types: ~[]}),
+              span: sp};
+    mr_expr(e)
 }
diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs
index 51db63c819aef..68db1b41781e4 100644
--- a/src/libsyntax/ext/env.rs
+++ b/src/libsyntax/ext/env.rs
@@ -18,18 +18,19 @@ use base::*;
 use build::mk_uniq_str;
 export expand_syntax_ext;
 
-fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
-                     _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"env");
+fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+
+    let var = get_single_str_from_tts(cx, sp, tts, "env!");
 
     // FIXME (#2248): if this was more thorough it would manufacture an
     // Option<str> rather than just an maybe-empty string.
 
-    let var = expr_to_str(cx, args[0], ~"env! requires a string");
-    match os::getenv(var) {
-      option::None => return mk_uniq_str(cx, sp, ~""),
-      option::Some(ref s) => return mk_uniq_str(cx, sp, (*s))
-    }
+    let e = match os::getenv(var) {
+      option::None => mk_uniq_str(cx, sp, ~""),
+      option::Some(ref s) => mk_uniq_str(cx, sp, (*s))
+    };
+    mr_expr(e)
 }
 
 //
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 391edbbb7993e..a35f351451bdc 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -62,21 +62,6 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
 
                     (fully_expanded, s)
                   }
-                  Some(normal({expander: exp, span: exp_sp})) => {
-                    cx.bt_push(ExpandedFrom({call_site: s,
-                                callie: {name: *extname, span: exp_sp}}));
-
-                    //convert the new-style invoc for the old-style macro
-                    let arg = base::tt_args_to_original_flavor(cx, pth.span,
-                                                               (*tts));
-                    let expanded = exp(cx, (*mac).span, arg, None);
-
-                    //keep going, outside-in
-                    let fully_expanded = fld.fold_expr(expanded).node;
-                    cx.bt_pop();
-
-                    (fully_expanded, s)
-                  }
                   _ => {
                     cx.span_fatal(pth.span,
                                   fmt!("'%s' is not a tt-style macro",
@@ -119,8 +104,7 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
               ast::meta_list(ref n, _) => (*n)
             };
             match exts.find(mname) {
-              None | Some(normal(_))
-                | Some(normal_tt(_)) | Some(item_tt(*)) => items,
+              None | Some(normal_tt(_)) | Some(item_tt(*)) => items,
               Some(item_decorator(dec_fn)) => {
                   cx.bt_push(ExpandedFrom({call_site: attr.span,
                                            callie: {name: copy mname,
@@ -262,23 +246,6 @@ fn expand_stmt(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
             (fully_expanded, sp)
         }
 
-        Some(normal({expander: exp, span: exp_sp})) => {
-            cx.bt_push(ExpandedFrom({call_site: sp,
-                                      callie: {name: *extname,
-                                               span: exp_sp}}));
-            //convert the new-style invoc for the old-style macro
-            let arg = base::tt_args_to_original_flavor(cx, pth.span, tts);
-            let exp_expr = exp(cx, mac.span, arg, None);
-            let expanded = @{node: stmt_expr(exp_expr, cx.next_id()),
-                             span: exp_expr.span};
-
-            //keep going, outside-in
-            let fully_expanded = fld.fold_stmt(expanded).node;
-            cx.bt_pop();
-
-            (fully_expanded, sp)
-        }
-
         _ => {
             cx.span_fatal(pth.span,
                           fmt!("'%s' is not a tt-style macro", *extname))
diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs
index e0d3bd03f42a4..46003624a76e5 100644
--- a/src/libsyntax/ext/fmt.rs
+++ b/src/libsyntax/ext/fmt.rs
@@ -21,9 +21,12 @@ use codemap::span;
 use ext::build::*;
 export expand_syntax_ext;
 
-fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-                     _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args_no_max(cx, sp, arg, 1u, ~"fmt");
+fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    let args = get_exprs_from_tts(cx, copy tts);
+    if args.len() == 0 {
+        cx.span_fatal(sp, "fmt! takes at least 1 argument.");
+    }
     let fmt =
         expr_to_str(cx, args[0],
                     ~"first argument to fmt! must be a string literal.");
@@ -37,7 +40,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
         parse_fmt_err_(cx, fmtspan, s)
     };
     let pieces = parse_fmt_string(fmt, parse_fmt_err);
-    return pieces_to_expr(cx, sp, pieces, args);
+    mr_expr(pieces_to_expr(cx, sp, pieces, args))
 }
 
 // FIXME (#2249): A lot of these functions for producing expressions can
diff --git a/src/libsyntax/ext/ident_to_str.rs b/src/libsyntax/ext/ident_to_str.rs
deleted file mode 100644
index ededc1a5f7ffc..0000000000000
--- a/src/libsyntax/ext/ident_to_str.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.
-
-use base::*;
-use build::mk_uniq_str;
-
-fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
-                     _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"ident_to_str");
-
-    return mk_uniq_str(cx, sp, *cx.parse_sess().interner.get(
-        expr_to_ident(cx, args[0u], ~"expected an ident")));
-}
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index aa97646c05429..8d2b9163f152f 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -23,63 +23,58 @@ export expand_include_str;
 export expand_include_bin;
 
 /* line!(): expands to the current line number */
-fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-               _body: ast::mac_body) -> @ast::expr {
-    get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"line");
+fn expand_line(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    base::check_zero_tts(cx, sp, tts, "line!");
     let loc = cx.codemap().lookup_char_pos(sp.lo);
-    return mk_uint(cx, sp, loc.line);
+    base::mr_expr(mk_uint(cx, sp, loc.line))
 }
 
 /* col!(): expands to the current column number */
-fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-              _body: ast::mac_body) -> @ast::expr {
-    get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"col");
+fn expand_col(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    base::check_zero_tts(cx, sp, tts, "col!");
     let loc = cx.codemap().lookup_char_pos(sp.lo);
-    return mk_uint(cx, sp, loc.col.to_uint());
+    base::mr_expr(mk_uint(cx, sp, loc.col.to_uint()))
 }
 
 /* file!(): expands to the current filename */
 /* The filemap (`loc.file`) contains a bunch more information we could spit
  * out if we wanted. */
-fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-               _body: ast::mac_body) -> @ast::expr {
-    get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"file");
+fn expand_file(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    base::check_zero_tts(cx, sp, tts, "file!");
     let Loc { file: @FileMap { name: filename, _ }, _ } =
         cx.codemap().lookup_char_pos(sp.lo);
-    return mk_uniq_str(cx, sp, filename);
+    base::mr_expr(mk_uniq_str(cx, sp, filename))
 }
 
-fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-                    _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"stringify");
-    let s = pprust::expr_to_str(args[0], cx.parse_sess().interner);
-    return mk_uniq_str(cx, sp, s);
+fn expand_stringify(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    let s = pprust::tts_to_str(tts, cx.parse_sess().interner);
+    base::mr_expr(mk_uniq_str(cx, sp, s))
 }
 
-fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body)
-    -> @ast::expr {
-    get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"file");
-    return mk_uniq_str(cx, sp,
-                       str::connect(cx.mod_path().map(
-                           |x| cx.str_of(*x)), ~"::"));
+fn expand_mod(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    base::check_zero_tts(cx, sp, tts, "module_path!");
+    base::mr_expr(mk_uniq_str(cx, sp,
+                              str::connect(cx.mod_path().map(
+                                  |x| cx.str_of(*x)), ~"::")))
 }
 
-fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
-                  _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"include");
-    let file = expr_to_str(cx, args[0], ~"include_str! requires a string");
+fn expand_include(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    let file = get_single_str_from_tts(cx, sp, tts, "include!");
     let p = parse::new_sub_parser_from_file(
         cx.parse_sess(), cx.cfg(),
         &res_rel_file(cx, sp, &Path(file)), sp);
-    return p.parse_expr();
+    base::mr_expr(p.parse_expr())
 }
 
-fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
-                      _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_str");
-
-    let file = expr_to_str(cx, args[0], ~"include_str! requires a string");
-
+fn expand_include_str(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    let file = get_single_str_from_tts(cx, sp, tts, "include_str!");
     let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file)));
     match res {
       result::Ok(_) => { /* Continue. */ }
@@ -88,21 +83,18 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
       }
     }
 
-    return mk_uniq_str(cx, sp, result::unwrap(res));
+    base::mr_expr(mk_uniq_str(cx, sp, result::unwrap(res)))
 }
 
-fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
-                      _body: ast::mac_body) -> @ast::expr {
-    let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_bin");
-
-    let file = expr_to_str(cx, args[0], ~"include_bin! requires a string");
-
+fn expand_include_bin(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
+    -> base::mac_result {
+    let file = get_single_str_from_tts(cx, sp, tts, "include_bin!");
     match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
       result::Ok(src) => {
         let u8_exprs = vec::map(src, |char| {
             mk_u8(cx, sp, *char)
         });
-        return mk_base_vec_e(cx, sp, u8_exprs);
+        base::mr_expr(mk_base_vec_e(cx, sp, u8_exprs))
       }
       result::Err(ref e) => {
         cx.parse_sess().span_diagnostic.handler().fatal((*e))
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index 3e9fe80526000..d90341254cc34 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -154,8 +154,7 @@ fn mk_printer(out: io::Writer, linewidth: uint) -> printer {
                mut top: 0,
                mut bottom: 0,
                print_stack: DVec(),
-               mut pending_indentation: 0,
-               mut token_tree_last_was_ident: false})
+               mut pending_indentation: 0 })
 }
 
 
@@ -261,7 +260,6 @@ type printer_ = {
     print_stack: DVec<print_stack_elt>,
     // buffered indentation to avoid writing trailing whitespace
     mut pending_indentation: int,
-    mut token_tree_last_was_ident: bool
 };
 
 enum printer {
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 684f74f3575c4..fa384341fb973 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -118,6 +118,10 @@ fn tt_to_str(tt: ast::token_tree, intr: @ident_interner) -> ~str {
     to_str(tt, print_tt, intr)
 }
 
+fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~str {
+    to_str(tts, print_tts, intr)
+}
+
 fn stmt_to_str(s: ast::stmt, intr: @ident_interner) -> ~str {
     to_str(s, print_stmt, intr)
 }
@@ -584,9 +588,7 @@ fn print_item(s: ps, &&item: @ast::item) {
         print_ident(s, item.ident);
         cbox(s, indent_unit);
         popen(s);
-        for (*tts).each |tt| {
-            print_tt(s, *tt);
-        }
+        print_tts(s, *tts);
         pclose(s);
         end(s);
       }
@@ -736,17 +738,9 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
 /// expression arguments as expressions). It can be done! I think.
 fn print_tt(s: ps, tt: ast::token_tree) {
     match tt {
-      ast::tt_delim(ref tts) =>
-        for (*tts).each() |tt_elt| { print_tt(s, *tt_elt); },
+      ast::tt_delim(ref tts) => print_tts(s, *tts),
       ast::tt_tok(_, ref tk) => {
-        match (*tk) {
-          parse::token::IDENT(*) => { // don't let idents run together
-            if s.s.token_tree_last_was_ident { word(s.s, ~" ") }
-            s.s.token_tree_last_was_ident = true;
-          }
-          _ => { s.s.token_tree_last_was_ident = false; }
-        }
-        word(s.s, parse::token::to_str(s.intr, (*tk)));
+          word(s.s, parse::token::to_str(s.intr, (*tk)));
       }
       ast::tt_seq(_, ref tts, ref sep, zerok) => {
         word(s.s, ~"$(");
@@ -757,16 +751,25 @@ fn print_tt(s: ps, tt: ast::token_tree) {
           None => ()
         }
         word(s.s, if zerok { ~"*" } else { ~"+" });
-        s.s.token_tree_last_was_ident = false;
       }
       ast::tt_nonterminal(_, name) => {
         word(s.s, ~"$");
         print_ident(s, name);
-        s.s.token_tree_last_was_ident = true;
       }
     }
 }
 
+fn print_tts(s: ps, &&tts: &[ast::token_tree]) {
+    ibox(s, 0);
+    for tts.eachi |i, tt| {
+        if i != 0 {
+            space(s.s);
+        }
+        print_tt(s, *tt);
+    }
+    end(s);
+}
+
 fn print_variant(s: ps, v: ast::variant) {
     print_visibility(s, v.node.vis);
     match v.node.kind {
@@ -1001,7 +1004,7 @@ fn print_mac(s: ps, m: ast::mac) {
         print_path(s, pth, false);
         word(s.s, ~"!");
         popen(s);
-        for (*tts).each() |tt| { print_tt(s, *tt); }
+        print_tts(s, *tts);
         pclose(s);
       }
     }
diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc
index 00c3804cce16c..fbc5f10fcd6f9 100644
--- a/src/libsyntax/syntax.rc
+++ b/src/libsyntax/syntax.rc
@@ -109,9 +109,6 @@ mod ext {
     #[path = "ext/concat_idents.rs"]
     mod concat_idents;
     #[legacy_exports]
-    #[path = "ext/ident_to_str.rs"]
-    mod ident_to_str;
-    #[legacy_exports]
     #[path = "ext/log_syntax.rs"]
     mod log_syntax;
     #[legacy_exports]
diff --git a/src/test/compile-fail/ext-noname.rs b/src/test/compile-fail/ext-noname.rs
deleted file mode 100644
index bf6bcd6f0817d..0000000000000
--- a/src/test/compile-fail/ext-noname.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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.
-
-// error-pattern:expected a syntax expander name
-
-fn main() {
-  #();
-}
diff --git a/src/test/compile-fail/extenv-no-args.rs b/src/test/compile-fail/extenv-no-args.rs
index 0c59ed9d33991..7ff1357dcf3c9 100644
--- a/src/test/compile-fail/extenv-no-args.rs
+++ b/src/test/compile-fail/extenv-no-args.rs
@@ -8,6 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern: env! takes between 1 and 1 arguments
+// error-pattern: env! takes 1 argument
 
 fn main() { env!(); }
diff --git a/src/test/compile-fail/extenv-too-many-args.rs b/src/test/compile-fail/extenv-too-many-args.rs
index abd7487f50c06..b1b2001abc358 100644
--- a/src/test/compile-fail/extenv-too-many-args.rs
+++ b/src/test/compile-fail/extenv-too-many-args.rs
@@ -8,6 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern: env! takes between 1 and 1 arguments
+// error-pattern: env! takes 1 argument
 
 fn main() { env!("one", "two"); }
diff --git a/src/test/compile-fail/extfmt-no-args.rs b/src/test/compile-fail/extfmt-no-args.rs
index b5d0462b436cc..cd9308e7b3f25 100644
--- a/src/test/compile-fail/extfmt-no-args.rs
+++ b/src/test/compile-fail/extfmt-no-args.rs
@@ -8,6 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:fmt! needs at least 1 arguments
+// error-pattern:fmt! takes at least 1 argument
 
 fn main() { fmt!(); }
diff --git a/src/test/run-pass/class-attributes-1.rs b/src/test/run-pass/class-attributes-1.rs
index d3a24488ca89b..ef3a82d1e2b69 100644
--- a/src/test/run-pass/class-attributes-1.rs
+++ b/src/test/run-pass/class-attributes-1.rs
@@ -16,7 +16,7 @@ struct cat {
 
 impl cat: Drop {
     #[cat_dropper]
-    fn finalize(&self) { error!("%s landed on hir feet",self.name); }
+    fn finalize(&self) { error!("%s landed on hir feet" , self . name); }
 }
 
 
diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/run-pass/syntax-extension-minor.rs
index dd08605ae61e5..aafd71d9162c8 100644
--- a/src/test/run-pass/syntax-extension-minor.rs
+++ b/src/test/run-pass/syntax-extension-minor.rs
@@ -13,6 +13,6 @@ fn main() {
     let asdf_fdsa = ~"<.<";
     assert (concat_idents!(asd, f_f, dsa) == ~"<.<");
 
-    assert (ident_to_str!(use_mention_distinction) ==
+    assert (stringify!(use_mention_distinction) ==
                 ~"use_mention_distinction");
 }
diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs
index 44eb6337a6fa4..0d7174370a084 100644
--- a/src/test/run-pass/syntax-extension-source-utils.rs
+++ b/src/test/run-pass/syntax-extension-source-utils.rs
@@ -24,7 +24,7 @@ fn main() {
     assert(line!() == 24);
     assert(col!() == 11);
     assert(file!().ends_with(~"syntax-extension-source-utils.rs"));
-    assert(stringify!((2*3) + 5) == ~"(2 * 3) + 5");
+    assert(stringify!((2*3) + 5) == ~"( 2 * 3 ) + 5");
     assert(include!("syntax-extension-source-utils-files/includeme.fragment")
            == ~"victory robot 6");
 

From 6047dd35bbe5b0b7c14cab6184bd39c607be19c1 Mon Sep 17 00:00:00 2001
From: Brian Anderson <banderson@mozilla.com>
Date: Wed, 12 Dec 2012 16:50:28 -0800
Subject: [PATCH 18/23] Fix vtable calculations when translating static
 methods. Closes #4165

---
 src/librustc/middle/trans/meth.rs             | 10 +---------
 .../run-pass/static-methods-in-traits2.rs     | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 9 deletions(-)
 create mode 100644 src/test/run-pass/static-methods-in-traits2.rs

diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index b5c7e1f6195a6..d214208560419 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -515,15 +515,7 @@ fn combine_impl_and_methods_origins(bcx: block,
     let m_boundss = vec::view(*r_m_bounds, n_r_m_tps - n_m_tps, n_r_m_tps);
 
     // Flatten out to find the number of vtables the method expects.
-    let m_vtables = m_boundss.foldl(0, |sum, m_bounds| {
-        m_bounds.foldl(*sum, |sum, m_bound| {
-            (*sum) + match (*m_bound) {
-                ty::bound_copy | ty::bound_owned |
-                ty::bound_send | ty::bound_const => 0,
-                ty::bound_trait(_) => 1
-            }
-        })
-    });
+    let m_vtables = ty::count_traits_and_supertraits(tcx, m_boundss);
 
     // Find the vtables we computed at type check time and monomorphize them
     let r_m_origins = match node_vtables(bcx, callee_id) {
diff --git a/src/test/run-pass/static-methods-in-traits2.rs b/src/test/run-pass/static-methods-in-traits2.rs
new file mode 100644
index 0000000000000..1545c98156ded
--- /dev/null
+++ b/src/test/run-pass/static-methods-in-traits2.rs
@@ -0,0 +1,19 @@
+pub trait Number: NumConv {
+    static pure fn from<T:Number>(n: T) -> self;
+}
+
+pub impl float: Number {
+    static pure fn from<T:Number>(n: T) -> float { n.to_float() }
+}
+
+pub trait NumConv {
+    pure fn to_float(&self) -> float;
+}
+
+pub impl float: NumConv {
+    pure fn to_float(&self) -> float { *self }
+}
+
+fn main() {
+    let _: float = Number::from(0.0f);
+}
\ No newline at end of file

From 948754b572efd8c1b94875cee4210bd8770c95fb Mon Sep 17 00:00:00 2001
From: Brian Anderson <banderson@mozilla.com>
Date: Wed, 12 Dec 2012 18:41:30 -0800
Subject: [PATCH 19/23] Fix the test for transmute

---
 src/libcore/cast.rs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs
index 46ac2824efbfa..4ae891915455c 100644
--- a/src/libcore/cast.rs
+++ b/src/libcore/cast.rs
@@ -130,10 +130,11 @@ pub mod tests {
 
     #[test]
     pub fn test_transmute() {
+        use managed::raw::BoxRepr;
         unsafe {
-            let x = @1;
-            let x: *int = transmute(move x);
-            assert *x == 1;
+            let x = @100u8;
+            let x: *BoxRepr = transmute(move x);
+            assert (*x).data == 100;
             let _x: @int = transmute(move x);
         }
     }

From 0d59e86d808b4f01bf4a004941408529b91f7166 Mon Sep 17 00:00:00 2001
From: Brian Anderson <banderson@mozilla.com>
Date: Wed, 12 Dec 2012 15:38:50 -0800
Subject: [PATCH 20/23] core: Remove some uses of 'move'

---
 src/libcore/at_vec.rs  |   6 +-
 src/libcore/char.rs    |   2 +-
 src/libcore/cleanup.rs |   2 +-
 src/libcore/str.rs     |  62 ++++++++---------
 src/libcore/vec.rs     | 152 ++++++++++++++++++++---------------------
 5 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs
index 26bae14d1608d..dc5faf49ea4c7 100644
--- a/src/libcore/at_vec.rs
+++ b/src/libcore/at_vec.rs
@@ -61,7 +61,7 @@ pub pure fn build_sized<A>(size: uint,
                            builder: &fn(push: pure fn(v: A))) -> @[A] {
     let mut vec: @[const A] = @[];
     unsafe { raw::reserve(&mut vec, size); }
-    builder(|+x| unsafe { raw::push(&mut vec, move x) });
+    builder(|+x| unsafe { raw::push(&mut vec, x) });
     return unsafe { transmute(vec) };
 }
 
@@ -178,10 +178,10 @@ pub mod raw {
         let repr: **VecRepr = ::cast::reinterpret_cast(&v);
         let fill = (**repr).unboxed.fill;
         if (**repr).unboxed.alloc > fill {
-            push_fast(v, move initval);
+            push_fast(v, initval);
         }
         else {
-            push_slow(v, move initval);
+            push_slow(v, initval);
         }
     }
 
diff --git a/src/libcore/char.rs b/src/libcore/char.rs
index 057b03c954623..f16268c34583f 100644
--- a/src/libcore/char.rs
+++ b/src/libcore/char.rs
@@ -149,7 +149,7 @@ pub pure fn escape_unicode(c: char) -> ~str {
             { str::push_str(&mut out, ~"0"); }
         str::push_str(&mut out, s);
     }
-    move out
+    out
 }
 
 /**
diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs
index fe512a936615b..9fd0a50a99c5e 100644
--- a/src/libcore/cleanup.rs
+++ b/src/libcore/cleanup.rs
@@ -152,7 +152,7 @@ pub unsafe fn annihilate() {
         assert (*box).header.prev == null();
 
         debug!("freeing box: %x", box as uint);
-        rt_free(transmute(move box));
+        rt_free(transmute(box));
     }
 }
 
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index fbdf2ce2e44b5..1154a86f96ca8 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -133,7 +133,7 @@ pub fn push_char(s: &mut ~str, ch: char) {
 pub pure fn from_char(ch: char) -> ~str {
     let mut buf = ~"";
     unsafe { push_char(&mut buf, ch); }
-    move buf
+    buf
 }
 
 /// Convert a vector of chars to a string
@@ -145,7 +145,7 @@ pub pure fn from_chars(chs: &[char]) -> ~str {
             push_char(&mut buf, *ch);
         }
     }
-    move buf
+    buf
 }
 
 /// Appends a string slice to the back of a string, without overallocating
@@ -186,11 +186,11 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) {
 /// Concatenate two strings together
 #[inline(always)]
 pub pure fn append(lhs: ~str, rhs: &str) -> ~str {
-    let mut v = move lhs;
+    let mut v = lhs;
     unsafe {
         push_str_no_overallocate(&mut v, rhs);
     }
-    move v
+    v
 }
 
 
@@ -200,7 +200,7 @@ pub pure fn concat(v: &[~str]) -> ~str {
     for vec::each(v) |ss| {
         unsafe { push_str(&mut s, *ss) };
     }
-    move s
+    s
 }
 
 /// Concatenate a vector of strings, placing a given separator between each
@@ -210,14 +210,14 @@ pub pure fn connect(v: &[~str], sep: &str) -> ~str {
         if first { first = false; } else { unsafe { push_str(&mut s, sep); } }
         unsafe { push_str(&mut s, *ss) };
     }
-    move s
+    s
 }
 
 /// Given a string, make a new string with repeated copies of it
 pub fn repeat(ss: &str, nn: uint) -> ~str {
     let mut acc = ~"";
     for nn.times { acc += ss; }
-    move acc
+    acc
 }
 
 /*
@@ -359,7 +359,7 @@ Section: Transforming strings
 pub pure fn to_bytes(s: &str) -> ~[u8] unsafe {
     let mut v: ~[u8] = ::cast::transmute(from_slice(s));
     vec::raw::set_len(&mut v, len(s));
-    move v
+    v
 }
 
 /// Work with the string as a byte slice, not including trailing null.
@@ -379,7 +379,7 @@ pub pure fn chars(s: &str) -> ~[char] {
         unsafe { buf.push(ch); }
         i = next;
     }
-    move buf
+    buf
 }
 
 /**
@@ -455,7 +455,7 @@ pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool)
         if allow_empty || start < l {
             unsafe { result.push(raw::slice_bytes(s, start, l) ) };
         }
-        move result
+        result
     } else {
         splitn(s, |cur| cur == sep, count)
     }
@@ -498,7 +498,7 @@ pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint,
     if allow_empty || start < l unsafe {
         result.push(unsafe { raw::slice_bytes(s, start, l) });
     }
-    move result
+    result
 }
 
 // See Issue #1932 for why this is a naive search
@@ -552,7 +552,7 @@ pub pure fn split_str(s: &a/str, sep: &b/str) -> ~[~str] {
     do iter_between_matches(s, sep) |from, to| {
         unsafe { result.push(raw::slice_bytes(s, from, to)); }
     }
-    move result
+    result
 }
 
 pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] {
@@ -562,7 +562,7 @@ pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] {
             unsafe { result.push(raw::slice_bytes(s, from, to)); }
         }
     }
-    move result
+    result
 }
 
 /**
@@ -581,7 +581,7 @@ pub pure fn lines_any(s: &str) -> ~[~str] {
         if l > 0u && s[l - 1u] == '\r' as u8 {
             unsafe { raw::set_len(&mut cp, l - 1u); }
         }
-        move cp
+        cp
     })
 }
 
@@ -609,7 +609,7 @@ pub fn split_within(ss: &str, lim: uint) -> ~[~str] {
         // then start a new row
         if row.len() + word.len() + 1 > lim {
             rows.push(copy row); // save previous row
-            row = move word;    // start a new one
+            row = word;    // start a new one
         } else {
             if row.len() > 0 { row += ~" " } // separate words
             row += word;  // append to this row
@@ -617,9 +617,9 @@ pub fn split_within(ss: &str, lim: uint) -> ~[~str] {
     }
 
     // save the last row
-    if row != ~"" { rows.push(move row); }
+    if row != ~"" { rows.push(row); }
 
-    move rows
+    rows
 }
 
 
@@ -661,7 +661,7 @@ pub pure fn replace(s: &str, from: &str, to: &str) -> ~str {
         }
         unsafe { push_str(&mut result, raw::slice_bytes(s, start, end)); }
     }
-    move result
+    result
 }
 
 /*
@@ -840,7 +840,7 @@ pub pure fn map(ss: &str, ff: fn(char) -> char) -> ~str {
             str::push_char(&mut result, ff(cc));
         }
     }
-    move result
+    result
 }
 
 /// Iterate over the bytes in a string
@@ -1493,7 +1493,7 @@ pub pure fn to_utf16(s: &str) -> ~[u16] {
             u.push_all(~[w1, w2])
         }
     }
-    move u
+    u
 }
 
 pub pure fn utf16_chars(v: &[u16], f: fn(char)) {
@@ -1527,13 +1527,13 @@ pub pure fn from_utf16(v: &[u16]) -> ~str {
         reserve(&mut buf, vec::len(v));
         utf16_chars(v, |ch| push_char(&mut buf, ch));
     }
-    move buf
+    buf
 }
 
 pub pure fn with_capacity(capacity: uint) -> ~str {
     let mut buf = ~"";
     unsafe { reserve(&mut buf, capacity); }
-    move buf
+    buf
 }
 
 /**
@@ -1921,7 +1921,7 @@ pub pure fn escape_default(s: &str) -> ~str {
             push_str(&mut out, char::escape_default(c));
         }
     }
-    move out
+    out
 }
 
 /// Escape each char in `s` with char::escape_unicode.
@@ -1933,7 +1933,7 @@ pub pure fn escape_unicode(s: &str) -> ~str {
             push_str(&mut out, char::escape_unicode(c));
         }
     }
-    move out
+    out
 }
 
 /// Unsafe operations
@@ -1959,7 +1959,7 @@ pub mod raw {
         v.push(0u8);
 
         assert is_utf8(v);
-        return ::cast::transmute(move v);
+        return ::cast::transmute(v);
     }
 
     /// Create a Rust string from a null-terminated C string
@@ -1987,7 +1987,7 @@ pub mod raw {
                               f: fn(v: &str) -> T) -> T {
         let v = (buf, len + 1);
         assert is_utf8(::cast::reinterpret_cast(&v));
-        f(::cast::transmute(move v))
+        f(::cast::transmute(v))
     }
 
     /**
@@ -2014,7 +2014,7 @@ pub mod raw {
                 }
                 vec::raw::set_len(&mut v, end - begin);
                 v.push(0u8);
-                ::cast::transmute(move v)
+                ::cast::transmute(v)
             }
         }
     }
@@ -2667,13 +2667,13 @@ mod tests {
                 let mut i = 0;
                 let mut rs = ~"";
                 while i < 100000 { push_str(&mut rs, ~"aaaaaaaaaa"); i += 1; }
-                move rs
+                rs
             }
             fn half_a_million_letter_a() -> ~str {
                 let mut i = 0;
                 let mut rs = ~"";
                 while i < 100000 { push_str(&mut rs, ~"aaaaa"); i += 1; }
-                move rs
+                rs
             }
             assert half_a_million_letter_a() ==
                 raw::slice_bytes(a_million_letter_a(), 0u, 500000);
@@ -2780,13 +2780,13 @@ mod tests {
                 push_str(&mut rs, ~"华华华华华华华华华华");
                 i += 1;
             }
-            move rs
+            rs
         }
         fn half_a_million_letter_X() -> ~str {
             let mut i = 0;
             let mut rs = ~"";
             while i < 100000 { push_str(&mut rs, ~"华华华华华"); i += 1; }
-            move rs
+            rs
         }
         assert half_a_million_letter_X() ==
             slice(a_million_letter_X(), 0u, 3u * 500000u);
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index 3386214ce1335..c0910ab86127c 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -120,7 +120,7 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
             }
         }
         raw::set_len(&mut v, n_elts);
-        return move v;
+        return v;
     }
 }
 
@@ -142,7 +142,7 @@ pub pure fn from_slice<T: Copy>(t: &[T]) -> ~[T] {
 pub pure fn with_capacity<T>(capacity: uint) -> ~[T] {
     let mut vec = ~[];
     unsafe { reserve(&mut vec, capacity); }
-    return move vec;
+    return vec;
 }
 
 /**
@@ -161,8 +161,8 @@ pub pure fn with_capacity<T>(capacity: uint) -> ~[T] {
 pub pure fn build_sized<A>(size: uint,
                        builder: fn(push: pure fn(v: A))) -> ~[A] {
     let mut vec = with_capacity(size);
-    builder(|x| unsafe { vec.push(move x) });
-    move vec
+    builder(|x| unsafe { vec.push(x) });
+    vec
 }
 
 /**
@@ -200,12 +200,12 @@ pub pure fn build_sized_opt<A>(size: Option<uint>,
 
 /// Produces a mut vector from an immutable vector.
 pub pure fn to_mut<T>(v: ~[T]) -> ~[mut T] {
-    unsafe { ::cast::transmute(move v) }
+    unsafe { ::cast::transmute(v) }
 }
 
 /// Produces an immutable vector from a mut vector.
 pub pure fn from_mut<T>(v: ~[mut T]) -> ~[T] {
-    unsafe { ::cast::transmute(move v) }
+    unsafe { ::cast::transmute(v) }
 }
 
 // Accessors
@@ -255,7 +255,7 @@ pub pure fn slice<T: Copy>(v: &[const T], start: uint, end: uint) -> ~[T] {
     unsafe {
         for uint::range(start, end) |i| { result.push(v[i]) }
     }
-    move result
+    result
 }
 
 /// Return a slice that points into another slice.
@@ -315,7 +315,7 @@ pub fn split<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] {
         }
     }
     result.push(slice(v, start, ln));
-    move result
+    result
 }
 
 /**
@@ -341,7 +341,7 @@ pub fn splitn<T: Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] {
         }
     }
     result.push(slice(v, start, ln));
-    move result
+    result
 }
 
 /**
@@ -365,7 +365,7 @@ pub fn rsplit<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] {
     }
     result.push(slice(v, 0u, end));
     reverse(result);
-    return move result;
+    return result;
 }
 
 /**
@@ -392,7 +392,7 @@ pub fn rsplitn<T: Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] {
     }
     result.push(slice(v, 0u, end));
     reverse(result);
-    move result
+    result
 }
 
 // Mutators
@@ -413,20 +413,20 @@ pub fn shift<T>(v: &mut ~[T]) -> T {
 
             for uint::range(1, ln) |i| {
                 let r = move *ptr::offset(vv, i);
-                v.push(move r);
+                v.push(r);
             }
         }
         raw::set_len(&mut vv, 0);
 
-        move rr
+        rr
     }
 }
 
 /// Prepend an element to the vector
 pub fn unshift<T>(v: &mut ~[T], x: T) {
-    let mut vv = ~[move x];
+    let mut vv = ~[x];
     *v <-> vv;
-    v.push_all_move(move vv);
+    v.push_all_move(vv);
 }
 
 /// Insert an element at position i within v, shifting all
@@ -435,7 +435,7 @@ pub fn insert<T>(v: &mut ~[T], i: uint, x: T) {
     let len = v.len();
     assert i <= len;
 
-    v.push(move x);
+    v.push(x);
     let mut j = len;
     while j > i {
         v[j] <-> v[j - 1];
@@ -454,16 +454,16 @@ pub fn remove<T>(v: &mut ~[T], i: uint) -> T {
         v[j] <-> v[j + 1];
         j += 1;
     }
-    move v.pop()
+    v.pop()
 }
 
 pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) unsafe {
-    let mut v = move v; // FIXME(#3488)
+    let mut v = v; // FIXME(#3488)
 
     do as_imm_buf(v) |p, ln| {
         for uint::range(0, ln) |i| {
             let x = move *ptr::offset(p, i);
-            f(i, move x);
+            f(i, x);
         }
     }
 
@@ -471,7 +471,7 @@ pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) unsafe {
 }
 
 pub fn consume_mut<T>(v: ~[mut T], f: fn(uint, v: T)) {
-    consume(vec::from_mut(move v), f)
+    consume(vec::from_mut(v), f)
 }
 
 /// Remove the last element from a vector and return it
@@ -484,7 +484,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
     unsafe {
         let val = move *valptr;
         raw::set_len(v, ln - 1u);
-        move val
+        val
     }
 }
 
@@ -512,10 +512,10 @@ pub fn push<T>(v: &mut ~[T], initval: T) {
         let repr: **raw::VecRepr = ::cast::transmute(copy v);
         let fill = (**repr).unboxed.fill;
         if (**repr).unboxed.alloc > fill {
-            push_fast(v, move initval);
+            push_fast(v, initval);
         }
         else {
-            push_slow(v, move initval);
+            push_slow(v, initval);
         }
     }
 }
@@ -534,7 +534,7 @@ unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
 #[inline(never)]
 fn push_slow<T>(v: &mut ~[T], initval: T) {
     reserve_at_least(v, v.len() + 1u);
-    unsafe { push_fast(v, move initval) }
+    unsafe { push_fast(v, initval) }
 }
 
 #[inline(always)]
@@ -548,13 +548,13 @@ pub fn push_all<T: Copy>(v: &mut ~[T], rhs: &[const T]) {
 
 #[inline(always)]
 pub fn push_all_move<T>(v: &mut ~[T], rhs: ~[T]) {
-    let mut rhs = move rhs; // FIXME(#3488)
+    let mut rhs = rhs; // FIXME(#3488)
     reserve(v, v.len() + rhs.len());
     unsafe {
         do as_imm_buf(rhs) |p, len| {
             for uint::range(0, len) |i| {
                 let x = move *ptr::offset(p, i);
-                push(v, move x);
+                push(v, x);
             }
         }
         raw::set_len(&mut rhs, 0);
@@ -613,23 +613,23 @@ pub fn dedup<T: Eq>(v: &mut ~[T]) unsafe {
 // Appending
 #[inline(always)]
 pub pure fn append<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] {
-    let mut v = move lhs;
+    let mut v = lhs;
     unsafe {
         v.push_all(rhs);
     }
-    move v
+    v
 }
 
 #[inline(always)]
 pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
-    let mut v = move lhs;
-    unsafe { v.push(move x); }
-    move v
+    let mut v = lhs;
+    unsafe { v.push(x); }
+    v
 }
 
 #[inline(always)]
 pure fn append_mut<T: Copy>(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] {
-    to_mut(append(from_mut(move lhs), rhs))
+    to_mut(append(from_mut(lhs), rhs))
 }
 
 /**
@@ -684,7 +684,7 @@ pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: iter::InitOp<T>) {
 pub fn grow_set<T: Copy>(v: &mut ~[T], index: uint, initval: &T, val: T) {
     let l = v.len();
     if index >= l { grow(v, index - l + 1u, initval); }
-    v[index] = move val;
+    v[index] = val;
 }
 
 // Functional utilities
@@ -697,15 +697,15 @@ pub pure fn map<T, U>(v: &[T], f: fn(t: &T) -> U) -> ~[U] {
             result.push(f(elem));
         }
     }
-    move result
+    result
 }
 
 pub fn map_consume<T, U>(v: ~[T], f: fn(v: T) -> U) -> ~[U] {
     let mut result = ~[];
-    do consume(move v) |_i, x| {
-        result.push(f(move x));
+    do consume(v) |_i, x| {
+        result.push(f(x));
     }
-    move result
+    result
 }
 
 /// Apply a function to each element of a vector and return the results
@@ -724,7 +724,7 @@ pub pure fn mapi<T, U>(v: &[T], f: fn(uint, t: &T) -> U) -> ~[U] {
 pub pure fn flat_map<T, U>(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] {
     let mut result = ~[];
     for each(v) |elem| { unsafe{ result.push_all_move(f(elem)); } }
-    move result
+    result
 }
 
 /// Apply a function to each pair of elements and return the results
@@ -738,7 +738,7 @@ pub pure fn map2<T: Copy, U: Copy, V>(v0: &[T], v1: &[U],
         unsafe { u.push(f(&v0[i], &v1[i])) };
         i += 1u;
     }
-    move u
+    u
 }
 
 /**
@@ -753,10 +753,10 @@ pub pure fn filter_map<T, U: Copy>(v: &[T], f: fn(t: &T) -> Option<U>)
     for each(v) |elem| {
         match f(elem) {
           None => {/* no-op */ }
-          Some(move result_elem) => unsafe { result.push(result_elem); }
+          Some(result_elem) => unsafe { result.push(result_elem); }
         }
     }
-    move result
+    result
 }
 
 /**
@@ -771,7 +771,7 @@ pub pure fn filter<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] {
     for each(v) |elem| {
         if f(elem) { unsafe { result.push(*elem); } }
     }
-    move result
+    result
 }
 
 /**
@@ -803,7 +803,7 @@ pub fn retain<T>(v: &mut ~[T], f: pure fn(t: &T) -> bool) {
 pub pure fn concat<T: Copy>(v: &[~[T]]) -> ~[T] {
     let mut r = ~[];
     for each(v) |inner| { unsafe { r.push_all(*inner); } }
-    move r
+    r
 }
 
 /// Concatenate a vector of vectors, placing a given separator between each
@@ -814,21 +814,21 @@ pub pure fn connect<T: Copy>(v: &[~[T]], sep: &T) -> ~[T] {
         if first { first = false; } else { unsafe { r.push(*sep); } }
         unsafe { r.push_all(*inner) };
     }
-    move r
+    r
 }
 
 /// Reduce a vector from left to right
 pub pure fn foldl<T, U>(z: T, v: &[U], p: fn(t: T, u: &U) -> T) -> T {
-    let mut accum = move z;
+    let mut accum = z;
     let mut i = 0;
     let l = v.len();
     while i < l {
         // Use a while loop so that liveness analysis can handle moving
         // the accumulator.
-        accum = p(move accum, &v[i]);
+        accum = p(accum, &v[i]);
         i += 1;
     }
-    return move accum;
+    return accum;
 }
 
 /// Reduce a vector from right to left
@@ -1044,7 +1044,7 @@ pure fn unzip_slice<T: Copy, U: Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
             us.push(u);
         }
     }
-    return (move ts, move us);
+    return (ts, us);
 }
 
 /**
@@ -1058,13 +1058,13 @@ pure fn unzip_slice<T: Copy, U: Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
 pub pure fn unzip<T,U>(v: ~[(T, U)]) -> (~[T], ~[U]) {
     let mut ts = ~[], us = ~[];
     unsafe {
-        do consume(move v) |_i, p| {
-            let (t, u) = move p;
-            ts.push(move t);
-            us.push(move u);
+        do consume(v) |_i, p| {
+            let (t, u) = p;
+            ts.push(t);
+            us.push(u);
         }
     }
-    (move ts, move us)
+    (ts, us)
 }
 
 /**
@@ -1077,7 +1077,7 @@ pub pure fn zip_slice<T: Copy, U: Copy>(v: &[const T], u: &[const U])
     let mut i = 0u;
     assert sz == len(u);
     while i < sz unsafe { zipped.push((v[i], u[i])); i += 1u; }
-    move zipped
+    zipped
 }
 
 /**
@@ -1087,7 +1087,7 @@ pub pure fn zip_slice<T: Copy, U: Copy>(v: &[const T], u: &[const U])
  * i-th elements from each of the input vectors.
  */
 pub pure fn zip<T, U>(v: ~[T], u: ~[U]) -> ~[(T, U)] {
-    let mut v = move v, u = move u; // FIXME(#3488)
+    let mut v = v, u = u; // FIXME(#3488)
     let mut i = len(v);
     assert i == len(u);
     let mut w = with_capacity(i);
@@ -1096,7 +1096,7 @@ pub pure fn zip<T, U>(v: ~[T], u: ~[U]) -> ~[(T, U)] {
         i -= 1;
     }
     unsafe { reverse(w); }
-    move w
+    w
 }
 
 /**
@@ -1123,12 +1123,12 @@ pub fn reverse<T>(v: &[mut T]) {
 pub pure fn reversed<T: Copy>(v: &[const T]) -> ~[T] {
     let mut rs: ~[T] = ~[];
     let mut i = len::<T>(v);
-    if i == 0 { return (move rs); } else { i -= 1; }
+    if i == 0 { return (rs); } else { i -= 1; }
     unsafe {
         while i != 0 { rs.push(v[i]); i -= 1; }
         rs.push(v[0]);
     }
-    move rs
+    rs
 }
 
 /**
@@ -1286,7 +1286,7 @@ pub pure fn windowed<TT: Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] {
             ww.push(vec::slice(xx, ii, ii+nn));
         }
     }
-    move ww
+    ww
 }
 
 /**
@@ -1548,7 +1548,7 @@ impl<T> &[T]: ImmutableVector<T> {
             r.push(f(&self[i]));
             i += 1;
         }
-        move r
+        r
     }
 
     /**
@@ -1674,11 +1674,11 @@ trait MutableEqVector<T: Eq> {
 
 impl<T> ~[T]: MutableVector<T> {
     fn push(&mut self, t: T) {
-        push(self, move t);
+        push(self, t);
     }
 
     fn push_all_move(&mut self, rhs: ~[T]) {
-        push_all_move(self, move rhs);
+        push_all_move(self, rhs);
     }
 
     fn pop(&mut self) -> T {
@@ -1690,11 +1690,11 @@ impl<T> ~[T]: MutableVector<T> {
     }
 
     fn unshift(&mut self, x: T) {
-        unshift(self, move x)
+        unshift(self, x)
     }
 
     fn insert(&mut self, i: uint, x:T) {
-        insert(self, i, move x)
+        insert(self, i, x)
     }
 
     fn remove(&mut self, i: uint) -> T {
@@ -1844,12 +1844,12 @@ mod raw {
      */
     #[inline(always)]
     pub unsafe fn init_elem<T>(v: &[mut T], i: uint, val: T) {
-        let mut box = Some(move val);
+        let mut box = Some(val);
         do as_mut_buf(v) |p, _len| {
             let mut box2 = None;
             box2 <-> box;
             rusti::move_val_init(&mut(*ptr::mut_offset(p, i)),
-                                 option::unwrap(move box2));
+                                 option::unwrap(box2));
         }
     }
 
@@ -1867,7 +1867,7 @@ mod raw {
         let mut dst = with_capacity(elts);
         set_len(&mut dst, elts);
         as_mut_buf(dst, |p_dst, _len_dst| ptr::memcpy(p_dst, ptr, elts));
-        move dst
+        dst
     }
 
     /**
@@ -1993,7 +1993,7 @@ impl<A> &[A]: iter::ExtendedIter<A> {
     pub pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) }
     pub pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) }
     pub pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B {
-        iter::foldl(&self, move b0, blk)
+        iter::foldl(&self, b0, blk)
     }
     pub pure fn position(f: fn(&A) -> bool) -> Option<uint> {
         iter::position(&self, f)
@@ -2320,7 +2320,7 @@ mod tests {
     #[test]
     fn test_dedup() {
         fn case(a: ~[uint], b: ~[uint]) {
-            let mut v = move a;
+            let mut v = a;
             v.dedup();
             assert(v == b);
         }
@@ -2576,13 +2576,13 @@ mod tests {
         let v1 = ~[1, 2, 3];
         let v2 = ~[4, 5, 6];
 
-        let z1 = zip(move v1, move v2);
+        let z1 = zip(v1, v2);
 
         assert ((1, 4) == z1[0]);
         assert ((2, 5) == z1[1]);
         assert ((3, 6) == z1[2]);
 
-        let (left, right) = unzip(move z1);
+        let (left, right) = unzip(z1);
 
         assert ((1, 4) == (left[0], right[0]));
         assert ((2, 5) == (left[1], right[1]));
@@ -2880,7 +2880,7 @@ mod tests {
         unsafe {
             let x = ~[1, 2, 3];
             let addr = raw::to_ptr(x);
-            let x_mut = to_mut(move x);
+            let x_mut = to_mut(x);
             let addr_mut = raw::to_ptr(x_mut);
             assert addr == addr_mut;
         }
@@ -2891,7 +2891,7 @@ mod tests {
         unsafe {
             let x = ~[mut 1, 2, 3];
             let addr = raw::to_ptr(x);
-            let x_imm = from_mut(move x);
+            let x_imm = from_mut(x);
             let addr_imm = raw::to_ptr(x_imm);
             assert addr == addr_imm;
         }
@@ -3139,7 +3139,7 @@ mod tests {
     fn test_consume_fail() {
         let v = ~[(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;
-        do consume(move v) |_i, _elt| {
+        do consume(v) |_i, _elt| {
             if i == 2 {
                 fail
             }
@@ -3153,7 +3153,7 @@ mod tests {
     fn test_consume_mut_fail() {
         let v = ~[mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;
-        do consume_mut(move v) |_i, _elt| {
+        do consume_mut(v) |_i, _elt| {
             if i == 2 {
                 fail
             }
@@ -3196,7 +3196,7 @@ mod tests {
     fn test_map_consume_fail() {
         let v = ~[(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;
-        do map_consume(move v) |_elt| {
+        do map_consume(v) |_elt| {
             if i == 2 {
                 fail
             }

From 3c8dca429a9f8048227449cb9a5c5bb974c9891e Mon Sep 17 00:00:00 2001
From: Graydon Hoare <graydon@mozilla.com>
Date: Thu, 13 Dec 2012 12:04:27 -0800
Subject: [PATCH 21/23] syntax: normalize paths when parsing, close #4173.

---
 src/libsyntax/parse/parser.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 625ff289607f6..0f1c346762521 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3023,6 +3023,7 @@ impl Parser {
         } else {
             prefix.push_many(path.components)
         };
+        let full_path = full_path.normalize();
         let p0 =
             new_sub_parser_from_file(self.sess, self.cfg,
                                      &full_path, id_sp);

From 4c2e4c37ce01a98c768a986b0b87a6e93ef72699 Mon Sep 17 00:00:00 2001
From: Patrick Walton <pcwalton@mimiga.net>
Date: Thu, 13 Dec 2012 13:05:22 -0800
Subject: [PATCH 22/23] librustc: Make `use` statements crate-relative by
 default. r=brson

---
 src/libcargo/cargo.rc                         |  29 ++-
 src/libcore/core.rc                           |   2 +-
 src/libcore/int-template.rs                   |   5 +
 src/libcore/int-template/int.rs               |   6 +-
 src/libcore/iter-trait.rs                     |   5 +
 src/libcore/libc.rs                           | 182 ++++++++++--------
 src/libcore/os.rs                             |  24 +--
 src/libcore/send_map.rs                       |   2 +-
 src/libcore/task/local_data.rs                |   2 +-
 src/libcore/task/local_data_priv.rs           |   7 +-
 src/libcore/task/mod.rs                       |   6 +-
 src/libcore/task/spawn.rs                     |   4 +-
 src/libcore/to_str.rs                         |   2 +-
 src/libcore/uint-template.rs                  |   5 +
 src/libcore/uint-template/u8.rs               |   4 +
 src/libcore/uint-template/uint.rs             |   9 +-
 src/librustc/driver/session.rs                |  13 +-
 src/librustc/front/intrinsic.rs               |   2 +-
 src/librustc/metadata/creader.rs              |   4 +-
 src/librustc/metadata/csearch.rs              |  19 +-
 src/librustc/metadata/decoder.rs              |  31 +--
 src/librustc/metadata/encoder.rs              |   4 +-
 src/librustc/metadata/loader.rs               |   2 +-
 src/librustc/metadata/mod.rs                  |  32 ---
 src/librustc/metadata/tydecode.rs             |   5 +-
 src/librustc/middle/astencode.rs              |  56 +++---
 src/librustc/middle/borrowck/gather_loans.rs  |   6 +-
 src/librustc/middle/borrowck/mod.rs           |  36 ++--
 src/librustc/middle/check_alt.rs              |  17 +-
 src/librustc/middle/const_eval.rs             |   4 +-
 src/librustc/middle/kind.rs                   |  15 +-
 src/librustc/middle/liveness.rs               |  17 +-
 src/librustc/middle/privacy.rs                |   6 +-
 src/librustc/middle/region.rs                 |  15 +-
 src/librustc/middle/resolve.rs                | 182 +++++++++++++++---
 src/librustc/middle/trans/alt.rs              |  29 +--
 src/librustc/middle/trans/base.rs             |  63 +++---
 src/librustc/middle/trans/build.rs            |  15 +-
 src/librustc/middle/trans/callee.rs           |  15 +-
 src/librustc/middle/trans/closure.rs          |  31 ++-
 src/librustc/middle/trans/consts.rs           |   5 +-
 src/librustc/middle/trans/controlflow.rs      |   6 +-
 src/librustc/middle/trans/datum.rs            |   8 +-
 src/librustc/middle/trans/debuginfo.rs        |  25 +--
 src/librustc/middle/trans/expr.rs             |  19 +-
 src/librustc/middle/trans/foreign.rs          |  35 ++--
 src/librustc/middle/trans/glue.rs             |   8 +-
 src/librustc/middle/trans/inline.rs           |  10 +-
 src/librustc/middle/trans/meth.rs             |  28 +--
 src/librustc/middle/trans/monomorphize.rs     |  21 +-
 src/librustc/middle/trans/reflect.rs          |  23 +--
 src/librustc/middle/trans/shape.rs            |  20 +-
 src/librustc/middle/trans/tvec.rs             |  19 +-
 src/librustc/middle/trans/type_of.rs          |   8 +-
 src/librustc/middle/trans/type_use.rs         |  13 +-
 src/librustc/middle/trans/uniq.rs             |  11 +-
 src/librustc/middle/typeck/astconv.rs         |  13 +-
 src/librustc/middle/typeck/check/alt.rs       |   6 +-
 src/librustc/middle/typeck/check/demand.rs    |  12 +-
 src/librustc/middle/typeck/check/method.rs    |  12 +-
 src/librustc/middle/typeck/check/mod.rs       |  90 +++++----
 src/librustc/middle/typeck/check/regionck.rs  |  12 +-
 .../middle/typeck/check/regionmanip.rs        |  12 +-
 src/librustc/middle/typeck/check/vtable.rs    |  24 +--
 src/librustc/middle/typeck/check/writeback.rs |  12 +-
 src/librustc/middle/typeck/coherence.rs       |   8 +-
 src/librustc/middle/typeck/collect.rs         |  24 ++-
 .../middle/typeck/infer/assignment.rs         |   4 +-
 src/librustc/middle/typeck/infer/combine.rs   |   9 +-
 src/librustc/middle/typeck/infer/floating.rs  |   2 +-
 src/librustc/middle/typeck/infer/glb.rs       |   7 +-
 src/librustc/middle/typeck/infer/integral.rs  |   2 +-
 src/librustc/middle/typeck/infer/lattice.rs   |   6 +-
 src/librustc/middle/typeck/infer/lub.rs       |   7 +-
 src/librustc/middle/typeck/infer/mod.rs       |  76 +++++---
 .../middle/typeck/infer/region_inference.rs   |  16 +-
 src/librustc/middle/typeck/infer/resolve.rs   |   6 +-
 src/librustc/middle/typeck/infer/sub.rs       |   7 +-
 src/librustc/middle/typeck/infer/to_str.rs    |   6 +-
 src/librustc/middle/typeck/infer/unify.rs     |   9 +-
 src/librustc/middle/typeck/mod.rs             |  77 ++++----
 src/librustc/middle/typeck/rscope.rs          |   2 +-
 src/librustc/rustc.rc                         |   2 +-
 src/librustdoc/astsrv.rs                      |  20 +-
 src/librustdoc/parse.rs                       |   4 +-
 src/librusti/rusti.rc                         |   6 +-
 src/libstd/serialization.rs                   |   2 +-
 src/libstd/timer.rs                           |   3 +-
 src/libstd/uv_global_loop.rs                  |   4 +-
 src/libstd/uv_iotask.rs                       |   2 +-
 src/libsyntax/ext/auto_serialize.rs           |   2 +-
 src/libsyntax/ext/build.rs                    |   2 +-
 src/libsyntax/ext/concat_idents.rs            |   2 +-
 src/libsyntax/ext/deriving.rs                 |   2 +-
 src/libsyntax/ext/env.rs                      |   4 +-
 src/libsyntax/ext/fmt.rs                      |   2 +-
 src/libsyntax/ext/log_syntax.rs               |   2 +-
 src/libsyntax/ext/pipes/ast_builder.rs        |   2 +-
 src/libsyntax/ext/pipes/check.rs              |   2 +-
 src/libsyntax/ext/pipes/mod.rs                |   5 +-
 src/libsyntax/ext/pipes/parse_proto.rs        |   2 +-
 src/libsyntax/ext/pipes/pipec.rs              |  13 +-
 src/libsyntax/ext/pipes/proto.rs              |   2 +-
 src/libsyntax/ext/quote.rs                    |   4 +-
 src/libsyntax/ext/source_util.rs              |   4 +-
 src/libsyntax/ext/tt/macro_rules.rs           |   7 +-
 src/libsyntax/ext/tt/transcribe.rs            |   2 +-
 src/libsyntax/parse/attr.rs                   |   2 +-
 src/libsyntax/parse/comments.rs               |   5 +-
 src/libsyntax/parse/common.rs                 |   4 +-
 src/libsyntax/parse/mod.rs                    |  11 +-
 src/libsyntax/parse/obsolete.rs               |   2 +-
 src/libsyntax/parse/parser.rs                 |  16 +-
 src/libsyntax/parse/prec.rs                   |   4 +-
 src/libsyntax/print/pprust.rs                 |   4 +-
 src/libsyntax/syntax.rc                       |   5 +
 src/test/auxiliary/cci_capture_clause.rs      |   2 +-
 src/test/auxiliary/pub_use_mods_xcrate.rs     |   2 +-
 src/test/compile-fail/super-at-top-level.rs   |   7 +
 src/test/run-pass/alias-uninit-value.rs       |   2 -
 src/test/run-pass/alt-pattern-drop.rs         |  18 +-
 .../run-pass/auto-ref-bounded-ty-param.rs     |   4 +-
 src/test/run-pass/auto_serialize.rs           |   2 +
 src/test/run-pass/basic-1.rs                  |  20 +-
 src/test/run-pass/basic-2.rs                  |  24 ++-
 src/test/run-pass/basic.rs                    |  19 +-
 src/test/run-pass/bind-by-move.rs             |   1 +
 src/test/run-pass/binops.rs                   |  13 +-
 src/test/run-pass/bitv-perf-test.rs           |   2 +
 .../borrowck-borrow-from-expr-block.rs        |   6 +-
 .../call-closure-from-overloaded-op.rs        |   6 +-
 src/test/run-pass/capture_nil.rs              |   7 +-
 src/test/run-pass/chan-leak.rs                |  32 ++-
 src/test/run-pass/class-exports.rs            |   2 +
 src/test/run-pass/comm.rs                     |  13 +-
 src/test/run-pass/conditional-compile.rs      |   2 +
 src/test/run-pass/core-export-f64-sqrt.rs     |   6 +-
 src/test/run-pass/decl-with-recv.rs           |  18 +-
 src/test/run-pass/dvec-test.rs                |   4 +-
 .../run-pass/export-glob-imports-target.rs    |   4 +-
 src/test/run-pass/export-glob.rs              |   5 +-
 src/test/run-pass/export-multi.rs             |   2 +
 src/test/run-pass/extern-mod-syntax.rs        |   2 +
 src/test/run-pass/getopts_ref.rs              |   2 +
 src/test/run-pass/guards-not-exhaustive.rs    |   4 +-
 src/test/run-pass/hashmap-memory.rs           |   4 +-
 src/test/run-pass/import-from-foreign.rs      |   2 +
 src/test/run-pass/import-from.rs              |   2 +
 src/test/run-pass/import-glob-0.rs            |   2 +
 src/test/run-pass/import-glob-1.rs            |   2 +
 src/test/run-pass/import-glob-crate.rs        |   2 +
 src/test/run-pass/import-in-block.rs          |   2 -
 src/test/run-pass/import-trailing-comma.rs    |   2 +
 src/test/run-pass/import.rs                   |   2 +
 src/test/run-pass/import2.rs                  |   2 +
 src/test/run-pass/import3.rs                  |   2 +
 src/test/run-pass/import4.rs                  |   2 +
 src/test/run-pass/import5.rs                  |   5 +-
 src/test/run-pass/import6.rs                  |   2 +
 src/test/run-pass/import7.rs                  |   2 +
 src/test/run-pass/import8.rs                  |   2 +
 src/test/run-pass/intrinsics-math.rs          |   2 +
 src/test/run-pass/issue-1112.rs               |   5 +-
 src/test/run-pass/issue-1696.rs               |   2 +
 src/test/run-pass/issue-2214.rs               |   4 +-
 src/test/run-pass/issue-2383.rs               |   2 +
 src/test/run-pass/issue-2445.rs               |   2 -
 src/test/run-pass/issue-2718.rs               |   2 +
 src/test/run-pass/issue-2804-2.rs             |   2 +
 src/test/run-pass/issue-2804.rs               |   2 +
 src/test/run-pass/issue-2895.rs               |  11 +-
 src/test/run-pass/issue-2904.rs               |   2 +
 src/test/run-pass/issue-3026.rs               |   2 +
 src/test/run-pass/issue-3052.rs               |   2 -
 src/test/run-pass/issue-3424.rs               |   2 +
 src/test/run-pass/issue-3559.rs               |   2 +
 src/test/run-pass/issue-3702.rs               |   4 +-
 src/test/run-pass/issue-507.rs                |  17 +-
 src/test/run-pass/issue-687.rs                |  36 ++--
 src/test/run-pass/issue-783.rs                |  20 +-
 src/test/run-pass/ivec-tag.rs                 |  17 +-
 src/test/run-pass/lazychan.rs                 |  14 +-
 .../log-knows-the-names-of-variants-in-std.rs |   2 +
 src/test/run-pass/mod-merge-hack-template.rs  |   2 +-
 src/test/run-pass/mod-view-items.rs           |   2 +
 src/test/run-pass/nested-pattern.rs           |   3 -
 src/test/run-pass/non-boolean-pure-fns.rs     |   2 +
 src/test/run-pass/pipe-bank-proto.rs          |   2 +
 src/test/run-pass/pipe-detect-term.rs         |   2 +
 src/test/run-pass/pipe-peek.rs                |   2 +
 src/test/run-pass/pipe-pingpong-bounded.rs    |   2 +
 src/test/run-pass/pipe-pingpong-proto.rs      |   2 +
 .../run-pass/pipe-presentation-examples.rs    |   2 +
 src/test/run-pass/pipe-select.rs              |   2 +
 src/test/run-pass/pipe-sleep.rs               |   4 +-
 src/test/run-pass/placement-new-arena.rs      |   2 +
 src/test/run-pass/reexport-star.rs            |   2 +
 src/test/run-pass/regions-mock-trans-impls.rs |   2 +
 src/test/run-pass/regions-mock-trans.rs       |   2 -
 src/test/run-pass/rt-circular-buffer.rs       |  51 +++--
 src/test/run-pass/rt-sched-1.rs               |   2 -
 src/test/run-pass/self-shadowing-import.rs    |   2 +
 src/test/run-pass/send-resource.rs            |  13 +-
 src/test/run-pass/send-type-inference.rs      |  11 +-
 src/test/run-pass/sendfn-deep-copy.rs         |   5 -
 src/test/run-pass/sendfn-spawn-with-fn-arg.rs |   5 -
 .../run-pass/shape_intrinsic_tag_then_rec.rs  |   2 +
 src/test/run-pass/spawn-fn.rs                 |   5 +-
 src/test/run-pass/spawn2.rs                   |   6 +-
 src/test/run-pass/tag-exports.rs              |   2 +
 src/test/run-pass/task-comm-16.rs             |   1 -
 src/test/run-pass/task-comm-4.rs              |   1 -
 src/test/run-pass/task-comm-6.rs              |   1 -
 src/test/run-pass/task-comm.rs                |  52 +++--
 src/test/run-pass/task-killjoin-rsrc.rs       |   2 -
 src/test/run-pass/task-killjoin.rs            |   2 -
 src/test/run-pass/trait-inheritance-num.rs    |   2 +
 src/test/run-pass/trait-inheritance-num0.rs   |   2 +
 src/test/run-pass/trait-inheritance-num2.rs   |   4 +-
 src/test/run-pass/unique-copy-box.rs          |   7 +-
 src/test/run-pass/use-mod.rs                  |   2 +
 src/test/run-pass/use.rs                      |   4 +-
 src/test/run-pass/yield.rs                    |   9 +-
 src/test/run-pass/yield1.rs                   |   5 +-
 src/test/run-pass/yield2.rs                   |   2 -
 src/test/run-pass/zip-same-length.rs          |   1 -
 226 files changed, 1315 insertions(+), 1131 deletions(-)
 create mode 100644 src/test/compile-fail/super-at-top-level.rs

diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc
index 2ced2026f6d8e..4fc8ddd9cdb12 100644
--- a/src/libcargo/cargo.rc
+++ b/src/libcargo/cargo.rc
@@ -42,26 +42,25 @@ extern mod std(vers = "0.5");
 extern mod rustc(vers = "0.5");
 extern mod syntax(vers = "0.5");
 
-use core::*;
-
 #[legacy_exports]
 mod pgp;
 
-use syntax::{ast, codemap, parse, visit, attr};
-use syntax::diagnostic::span_handler;
-use codemap::span;
-use rustc::metadata::filesearch::{get_cargo_root, get_cargo_root_nearest,
-                                     get_cargo_sysroot, libdir};
-use syntax::diagnostic;
+use rustc::metadata::filesearch::{get_cargo_root, get_cargo_root_nearest};
+use rustc::metadata::filesearch::{get_cargo_sysroot, libdir};
 
-use result::{Ok, Err};
-use io::WriterUtil;
-use send_map::linear::LinearMap;
+use core::*;
+
+use core::dvec::DVec;
+use core::io::WriterUtil;
+use core::result::{Ok, Err};
+use core::send_map::linear::LinearMap;
+use std::getopts::{optflag, optopt, opt_present};
+use std::map::HashMap;
 use std::{map, json, tempfile, term, sort, getopts};
-use map::HashMap;
-use to_str::to_str;
-use getopts::{optflag, optopt, opt_present};
-use dvec::DVec;
+use syntax::codemap::span;
+use syntax::diagnostic::span_handler;
+use syntax::diagnostic;
+use syntax::{ast, codemap, parse, visit, attr};
 
 struct Package {
     name: ~str,
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index 5f313244e2758..bfdc0a6eb0d68 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -247,7 +247,7 @@ mod core {
 #[cfg(test)]
 mod std {
     extern mod std(vers = "0.5");
-    pub use std::test;
+    pub use std::std::test;
 }
 
 
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index dbeb51b813ff2..3878d6a520533 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -12,7 +12,12 @@
 #[forbid(deprecated_mode)];
 #[forbid(deprecated_pattern)];
 
+#[cfg(stage0)]
 use T = inst::T;
+#[cfg(stage1)]
+#[cfg(stage2)]
+use T = self::inst::T;
+
 use cmp::{Eq, Ord};
 use from_str::FromStr;
 use num::from_int;
diff --git a/src/libcore/int-template/int.rs b/src/libcore/int-template/int.rs
index 87f5659e6f408..98d833adea98a 100644
--- a/src/libcore/int-template/int.rs
+++ b/src/libcore/int-template/int.rs
@@ -10,7 +10,11 @@
 
 //! Operations and constants for `int`
 
+#[cfg(stage0)]
 pub use inst::pow;
+#[cfg(stage1)]
+#[cfg(stage2)]
+pub use self::inst::pow;
 
 mod inst {
     pub type T = int;
@@ -54,4 +58,4 @@ mod inst {
         assert (min_value <= 0);
         assert (min_value + max_value + 1 == 0);
     }
-}
\ No newline at end of file
+}
diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs
index 861f55afc99f6..dfb91c49b7d57 100644
--- a/src/libcore/iter-trait.rs
+++ b/src/libcore/iter-trait.rs
@@ -16,7 +16,12 @@
 #[forbid(deprecated_pattern)];
 
 use cmp::{Eq, Ord};
+
+#[cfg(stage0)]
 use inst::{IMPL_T, EACH, SIZE_HINT};
+#[cfg(stage1)]
+#[cfg(stage2)]
+use self::inst::{IMPL_T, EACH, SIZE_HINT};
 
 impl<A> IMPL_T<A>: iter::BaseIter<A> {
     pure fn each(blk: fn(v: &A) -> bool) { EACH(&self, blk) }
diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs
index 64f63663098d8..80e3a22dcba22 100644
--- a/src/libcore/libc.rs
+++ b/src/libcore/libc.rs
@@ -59,89 +59,109 @@
 // Initial glob-exports mean that all the contents of all the modules
 // wind up exported, if you're interested in writing platform-specific code.
 
-pub use types::common::c95::*;
-pub use types::common::c99::*;
-pub use types::common::posix88::*;
-pub use types::common::posix01::*;
-pub use types::common::posix08::*;
-pub use types::common::bsd44::*;
-pub use types::os::common::posix01::*;
-pub use types::os::arch::c95::*;
-pub use types::os::arch::c99::*;
-pub use types::os::arch::posix88::*;
-pub use types::os::arch::posix01::*;
-pub use types::os::arch::posix08::*;
-pub use types::os::arch::bsd44::*;
-pub use types::os::arch::extra::*;
-
-pub use consts::os::c95::*;
-pub use consts::os::c99::*;
-pub use consts::os::posix88::*;
-pub use consts::os::posix01::*;
-pub use consts::os::posix08::*;
-pub use consts::os::bsd44::*;
-pub use consts::os::extra::*;
-
-pub use funcs::c95::ctype::*;
-pub use funcs::c95::stdio::*;
-pub use funcs::c95::stdlib::*;
-pub use funcs::c95::string::*;
-
-pub use funcs::posix88::stat_::*;
-pub use funcs::posix88::stdio::*;
-pub use funcs::posix88::fcntl::*;
-pub use funcs::posix88::dirent::*;
-pub use funcs::posix88::unistd::*;
-
-pub use funcs::posix01::stat_::*;
-pub use funcs::posix01::unistd::*;
-pub use funcs::posix08::unistd::*;
-
-pub use funcs::bsd44::*;
-pub use funcs::extra::*;
+pub use libc::types::common::c95::*;
+pub use libc::types::common::c99::*;
+pub use libc::types::common::posix88::*;
+pub use libc::types::common::posix01::*;
+pub use libc::types::common::posix08::*;
+pub use libc::types::common::bsd44::*;
+pub use libc::types::os::common::posix01::*;
+pub use libc::types::os::arch::c95::*;
+pub use libc::types::os::arch::c99::*;
+pub use libc::types::os::arch::posix88::*;
+pub use libc::types::os::arch::posix01::*;
+pub use libc::types::os::arch::posix08::*;
+pub use libc::types::os::arch::bsd44::*;
+pub use libc::types::os::arch::extra::*;
+
+pub use libc::consts::os::c95::*;
+pub use libc::consts::os::c99::*;
+pub use libc::consts::os::posix88::*;
+pub use libc::consts::os::posix01::*;
+pub use libc::consts::os::posix08::*;
+pub use libc::consts::os::bsd44::*;
+pub use libc::consts::os::extra::*;
+
+pub use libc::funcs::c95::ctype::*;
+pub use libc::funcs::c95::stdio::*;
+pub use libc::funcs::c95::stdlib::*;
+pub use libc::funcs::c95::string::*;
+
+pub use libc::funcs::posix88::stat_::*;
+pub use libc::funcs::posix88::stdio::*;
+pub use libc::funcs::posix88::fcntl::*;
+pub use libc::funcs::posix88::dirent::*;
+pub use libc::funcs::posix88::unistd::*;
+
+pub use libc::funcs::posix01::stat_::*;
+pub use libc::funcs::posix01::unistd::*;
+pub use libc::funcs::posix08::unistd::*;
+
+pub use libc::funcs::bsd44::*;
+pub use libc::funcs::extra::*;
+
+#[cfg(target_os = "win32")]
+pub use libc::funcs::extra::kernel32::*;
+#[cfg(target_os = "win32")]
+pub use libc::funcs::extra::msvcrt::*;
 
 // Explicit export lists for the intersection (provided here) mean that
 // you can write more-platform-agnostic code if you stick to just these
 // symbols.
 
-pub use size_t;
-pub use c_float, c_double, c_void, FILE, fpos_t;
-pub use DIR, dirent_t;
-pub use c_char, c_schar, c_uchar;
-pub use c_short, c_ushort, c_int, c_uint, c_long, c_ulong;
-pub use size_t, ptrdiff_t, clock_t, time_t;
-pub use c_longlong, c_ulonglong, intptr_t, uintptr_t;
-pub use off_t, dev_t, ino_t, pid_t, mode_t, ssize_t;
-
-pub use EXIT_FAILURE, EXIT_SUCCESS, RAND_MAX,
-EOF, SEEK_SET, SEEK_CUR, SEEK_END, _IOFBF, _IONBF, _IOLBF,
-BUFSIZ, FOPEN_MAX, FILENAME_MAX, L_tmpnam, TMP_MAX,
-O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_CREAT, O_EXCL, O_TRUNC,
-S_IFIFO, S_IFCHR, S_IFBLK, S_IFDIR, S_IFREG, S_IFMT, S_IEXEC,
-S_IWRITE, S_IREAD, S_IRWXU, S_IXUSR, S_IWUSR, S_IRUSR, F_OK, R_OK,
-W_OK, X_OK, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO;
-
-pub use isalnum, isalpha, iscntrl, isdigit, islower, isprint, ispunct,
-isspace, isupper, isxdigit, tolower, toupper;
-
-pub use fopen, freopen, fflush, fclose, remove, tmpfile, setvbuf, setbuf,
-fgetc, fgets, fputc, fputs, puts, ungetc, fread, fwrite, fseek, ftell,
-rewind, fgetpos, fsetpos, feof, ferror, perror;
-
-pub use abs, labs, atof, atoi, strtod, strtol, strtoul, calloc, malloc,
-realloc, free, abort, exit, system, getenv, rand, srand;
-
-pub use strcpy, strncpy, strcat, strncat, strcmp, strncmp, strcoll, strchr,
-strrchr, strspn, strcspn, strpbrk, strstr, strlen, strerror, strtok,
-strxfrm, memcpy, memmove, memcmp, memchr, memset;
-
-pub use chmod, mkdir;
-pub use popen, pclose, fdopen, fileno;
-pub use open, creat;
-pub use access, chdir, close, dup, dup2, execv, execve, execvp, getcwd,
-getpid, isatty, lseek, pipe, read, rmdir, unlink, write;
-
-pub use fstat, stat;
+pub use libc::types::common::c95::{FILE, c_void, fpos_t};
+pub use libc::types::common::posix88::{DIR, dirent_t};
+pub use libc::types::os::arch::c95::{c_char, c_double, c_float, c_int};
+pub use libc::types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong};
+pub use libc::types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t};
+pub use libc::types::os::arch::c95::{size_t, time_t};
+pub use libc::types::os::arch::c99::{c_longlong, c_ulonglong, intptr_t};
+pub use libc::types::os::arch::c99::{uintptr_t};
+pub use libc::types::os::arch::posix88::{dev_t, dirent_t, ino_t, mode_t};
+pub use libc::types::os::arch::posix88::{off_t, pid_t, ssize_t};
+
+pub use libc::consts::os::c95::{_IOFBF, _IOLBF, _IONBF, BUFSIZ, EOF};
+pub use libc::consts::os::c95::{EXIT_FAILURE, EXIT_SUCCESS};
+pub use libc::consts::os::c95::{FILENAME_MAX, FOPEN_MAX, L_tmpnam};
+pub use libc::consts::os::c95::{RAND_MAX, SEEK_CUR, SEEK_END};
+pub use libc::consts::os::c95::{SEEK_SET, TMP_MAX};
+pub use libc::consts::os::posix88::{F_OK, O_APPEND, O_CREAT, O_EXCL};
+pub use libc::consts::os::posix88::{O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
+pub use libc::consts::os::posix88::{R_OK, S_IEXEC, S_IFBLK, S_IFCHR};
+pub use libc::consts::os::posix88::{S_IFDIR, S_IFIFO, S_IFMT, S_IFREG};
+pub use libc::consts::os::posix88::{S_IREAD, S_IRUSR, S_IRWXU, S_IWUSR};
+pub use libc::consts::os::posix88::{STDERR_FILENO, STDIN_FILENO};
+pub use libc::consts::os::posix88::{STDOUT_FILENO, W_OK, X_OK};
+
+pub use libc::funcs::c95::ctype::{isalnum, isalpha, iscntrl, isdigit};
+pub use libc::funcs::c95::ctype::{islower, isprint, ispunct, isspace};
+pub use libc::funcs::c95::ctype::{isupper, isxdigit, tolower, toupper};
+
+pub use libc::funcs::c95::stdio::{fclose, feof, ferror, fflush, fgetc};
+pub use libc::funcs::c95::stdio::{fgetpos, fgets, fopen, fputc, fputs};
+pub use libc::funcs::c95::stdio::{fread, freopen, fseek, fsetpos, ftell};
+pub use libc::funcs::c95::stdio::{fwrite, perror, puts, remove, rewind};
+pub use libc::funcs::c95::stdio::{setbuf, setvbuf, tmpfile, ungetc};
+
+pub use libc::funcs::c95::stdlib::{abort, abs, atof, atoi, calloc, exit};
+pub use libc::funcs::c95::stdlib::{free, getenv, labs, malloc, rand};
+pub use libc::funcs::c95::stdlib::{realloc, srand, strtod, strtol};
+pub use libc::funcs::c95::stdlib::{strtoul, system};
+
+pub use libc::funcs::c95::string::{memchr, memcmp, memcpy, memmove};
+pub use libc::funcs::c95::string::{memset, strcat, strchr, strcmp};
+pub use libc::funcs::c95::string::{strcoll, strcpy, strcspn, strerror};
+pub use libc::funcs::c95::string::{strlen, strncat, strncmp, strncpy};
+pub use libc::funcs::c95::string::{strpbrk, strrchr, strspn, strstr};
+pub use libc::funcs::c95::string::{strtok, strxfrm};
+
+pub use libc::funcs::posix88::fcntl::{open, creat};
+pub use libc::funcs::posix88::stat_::{chmod, fstat, mkdir, stat};
+pub use libc::funcs::posix88::stdio::{fdopen, fileno, pclose, popen};
+pub use libc::funcs::posix88::unistd::{access, chdir, close, dup, dup2};
+pub use libc::funcs::posix88::unistd::{execv, execve, execvp, getcwd};
+pub use libc::funcs::posix88::unistd::{getpid, isatty, lseek, pipe, read};
+pub use libc::funcs::posix88::unistd::{rmdir, unlink, write};
 
 
 mod types {
@@ -1365,10 +1385,6 @@ pub mod funcs {
 
     #[cfg(target_os = "win32")]
     pub mod extra {
-        use types::os::arch::extra::*;
-        pub use kernel32::*;
-        pub use msvcrt::*;
-
         #[abi = "stdcall"]
         pub extern mod kernel32 {
             fn GetEnvironmentVariableW(n: LPCWSTR,
@@ -1396,7 +1412,7 @@ pub mod funcs {
         #[nolink]
         pub extern mod msvcrt {
             #[link_name = "_commit"]
-            fn commit(fd: c_int) -> c_int;
+            pub fn commit(fd: c_int) -> c_int;
         }
     }
 }
diff --git a/src/libcore/os.rs b/src/libcore/os.rs
index e793155c267a9..c3bf8df5114ed 100644
--- a/src/libcore/os.rs
+++ b/src/libcore/os.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012 The Rust Project Developers.src/libcore/os.rs
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -36,7 +36,7 @@ pub use libc::{close, fclose};
 
 use option::{Some, None};
 
-pub use consts::*;
+pub use os::consts::*;
 use task::TaskBuilder;
 
 // FIXME: move these to str perhaps? #2620
@@ -77,8 +77,8 @@ pub fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool)
 }
 
 #[cfg(windows)]
-mod win32 {
-    use libc::DWORD;
+pub mod win32 {
+    use libc::types::os::arch::extra::DWORD;
 
     pub fn fill_utf16_buf_and_decode(f: fn(*mut u16, DWORD) -> DWORD)
         -> Option<~str> {
@@ -224,7 +224,7 @@ mod global_env {
 
         #[cfg(windows)]
         pub fn getenv(n: &str) -> Option<~str> {
-            use win32::*;
+            use os::win32::*;
             do as_utf16_p(n) |u| {
                 do fill_utf16_buf_and_decode() |buf, sz| {
                     libc::GetEnvironmentVariableW(u, buf, sz)
@@ -245,7 +245,7 @@ mod global_env {
 
         #[cfg(windows)]
         pub fn setenv(n: &str, v: &str) {
-            use win32::*;
+            use os::win32::*;
             do as_utf16_p(n) |nbuf| {
                 do as_utf16_p(v) |vbuf| {
                     libc::SetEnvironmentVariableW(nbuf, vbuf);
@@ -403,7 +403,7 @@ pub fn self_exe_path() -> Option<Path> {
 
     #[cfg(windows)]
     fn load_self() -> Option<~str> {
-        use win32::*;
+        use os::win32::*;
         do fill_utf16_buf_and_decode() |buf, sz| {
             libc::GetModuleFileNameW(0u as libc::DWORD, buf, sz)
         }
@@ -566,7 +566,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
 
     #[cfg(windows)]
     fn mkdir(p: &Path, _mode: c_int) -> bool {
-        use win32::*;
+        use os::win32::*;
         // FIXME: turn mode into something useful? #2623
         do as_utf16_p(p.to_str()) |buf| {
             libc::CreateDirectoryW(buf, unsafe {
@@ -614,7 +614,7 @@ pub fn remove_dir(p: &Path) -> bool {
 
     #[cfg(windows)]
     fn rmdir(p: &Path) -> bool {
-        use win32::*;
+        use os::win32::*;
         return do as_utf16_p(p.to_str()) |buf| {
             libc::RemoveDirectoryW(buf) != (0 as libc::BOOL)
         };
@@ -633,7 +633,7 @@ pub fn change_dir(p: &Path) -> bool {
 
     #[cfg(windows)]
     fn chdir(p: &Path) -> bool {
-        use win32::*;
+        use os::win32::*;
         return do as_utf16_p(p.to_str()) |buf| {
             libc::SetCurrentDirectoryW(buf) != (0 as libc::BOOL)
         };
@@ -653,7 +653,7 @@ pub fn copy_file(from: &Path, to: &Path) -> bool {
 
     #[cfg(windows)]
     fn do_copy_file(from: &Path, to: &Path) -> bool {
-        use win32::*;
+        use os::win32::*;
         return do as_utf16_p(from.to_str()) |fromp| {
             do as_utf16_p(to.to_str()) |top| {
                 libc::CopyFileW(fromp, top, (0 as libc::BOOL)) !=
@@ -713,7 +713,7 @@ pub fn remove_file(p: &Path) -> bool {
 
     #[cfg(windows)]
     fn unlink(p: &Path) -> bool {
-        use win32::*;
+        use os::win32::*;
         return do as_utf16_p(p.to_str()) |buf| {
             libc::DeleteFileW(buf) != (0 as libc::BOOL)
         };
diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs
index 4a8fe459b3757..af6b2c163779b 100644
--- a/src/libcore/send_map.rs
+++ b/src/libcore/send_map.rs
@@ -451,7 +451,7 @@ pub mod linear {
 
 #[test]
 pub mod test {
-    use linear::LinearMap;
+    use send_map::linear::LinearMap;
 
     #[test]
     pub fn inserts() {
diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs
index cc0353a354b69..ca8cc67dc4a90 100644
--- a/src/libcore/task/local_data.rs
+++ b/src/libcore/task/local_data.rs
@@ -26,7 +26,7 @@ magic.
 
 */
 
-use local_data_priv::{
+use task::local_data_priv::{
     local_pop,
     local_get,
     local_set,
diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs
index 494801d88ea4e..a5ae3291b877e 100644
--- a/src/libcore/task/local_data_priv.rs
+++ b/src/libcore/task/local_data_priv.rs
@@ -10,8 +10,13 @@
 
 #[doc(hidden)]; // FIXME #3538
 
-use local_data::LocalDataKey;
+use task::local_data::LocalDataKey;
+
+#[cfg(notest)]
 use rt::rust_task;
+#[cfg(test)]
+#[allow(non_camel_case_types)]
+type rust_task = libc::c_void;
 
 pub trait LocalData { }
 impl<T: Owned> @T: LocalData { }
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs
index 98da3f50318d1..d9b040abf7bf4 100644
--- a/src/libcore/task/mod.rs
+++ b/src/libcore/task/mod.rs
@@ -41,12 +41,10 @@
 use cmp::Eq;
 use result::Result;
 use pipes::{stream, Chan, Port};
-use local_data_priv::{local_get, local_set};
+use task::local_data_priv::{local_get, local_set};
+use task::rt::{task_id, rust_task};
 use util::replace;
 
-use rt::task_id;
-use rt::rust_task;
-
 mod local_data_priv;
 pub mod local_data;
 pub mod rt;
diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs
index 61e358e1e30e4..e2ed853ee2932 100644
--- a/src/libcore/task/spawn.rs
+++ b/src/libcore/task/spawn.rs
@@ -73,8 +73,8 @@
 #[doc(hidden)]; // FIXME #3538
 #[warn(deprecated_mode)];
 
-use rt::rust_task;
-use rt::rust_closure;
+use task::rt::rust_task;
+use task::rt::rust_closure;
 
 macro_rules! move_it (
     { $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )
diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs
index 7f9aa28e364ca..55055470f10f1 100644
--- a/src/libcore/to_str.rs
+++ b/src/libcore/to_str.rs
@@ -18,7 +18,7 @@ The `ToStr` trait for converting to strings
 #[forbid(deprecated_mode)];
 #[forbid(deprecated_pattern)];
 
-pub trait ToStr { pure fn to_str() -> ~str; }
+pub trait ToStr { pub pure fn to_str() -> ~str; }
 
 impl int: ToStr {
     pure fn to_str() -> ~str { int::str(self) }
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index 8a03b0f94bcd8..a7d37c3ae61ab 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -12,7 +12,12 @@
 #[forbid(deprecated_mode)];
 #[forbid(deprecated_pattern)];
 
+#[cfg(stage0)]
 use T = inst::T;
+#[cfg(stage1)]
+#[cfg(stage2)]
+use T = self::inst::T;
+
 use cmp::{Eq, Ord};
 use from_str::FromStr;
 
diff --git a/src/libcore/uint-template/u8.rs b/src/libcore/uint-template/u8.rs
index 81635bf1e7f93..4d0b3f2d4b718 100644
--- a/src/libcore/uint-template/u8.rs
+++ b/src/libcore/uint-template/u8.rs
@@ -10,7 +10,11 @@
 
 //! Operations and constants for `u8`
 
+#[cfg(stage0)]
 pub use inst::is_ascii;
+#[cfg(stage1)]
+#[cfg(stage2)]
+pub use self::inst::is_ascii;
 
 mod inst {
     pub type T = u8;
diff --git a/src/libcore/uint-template/uint.rs b/src/libcore/uint-template/uint.rs
index 718d7956b316d..8451d78d8e0dc 100644
--- a/src/libcore/uint-template/uint.rs
+++ b/src/libcore/uint-template/uint.rs
@@ -10,10 +10,17 @@
 
 //! Operations and constants for `uint`
 
+#[cfg(stage0)]
 pub use inst::{
     div_ceil, div_round, div_floor, iterate,
     next_power_of_two
 };
+#[cfg(stage1)]
+#[cfg(stage2)]
+pub use self::inst::{
+    div_ceil, div_round, div_floor, iterate,
+    next_power_of_two
+};
 
 mod inst {
     pub type T = uint;
@@ -169,4 +176,4 @@ mod inst {
         assert(uint::div_ceil(3u, 4u)  == 1u);
         assert(uint::div_round(3u, 4u) == 1u);
     }
-}
\ No newline at end of file
+}
diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs
index 38594ea2c17ff..b2cb6da78ddc2 100644
--- a/src/librustc/driver/session.rs
+++ b/src/librustc/driver/session.rs
@@ -9,15 +9,16 @@
 // except according to those terms.
 
 
-use syntax::{ast, codemap};
+use back::link;
+use back::target_strs;
+use metadata::filesearch;
+use middle::lint;
+
 use syntax::ast::node_id;
-use codemap::span;
 use syntax::ast::{int_ty, uint_ty, float_ty};
+use syntax::codemap::span;
 use syntax::parse::parse_sess;
-use metadata::filesearch;
-use back::target_strs;
-use back::link;
-use middle::lint;
+use syntax::{ast, codemap};
 
 
 enum os { os_win32, os_macos, os_linux, os_freebsd, }
diff --git a/src/librustc/front/intrinsic.rs b/src/librustc/front/intrinsic.rs
index 8a65ac6894b38..8703e60474449 100644
--- a/src/librustc/front/intrinsic.rs
+++ b/src/librustc/front/intrinsic.rs
@@ -14,7 +14,7 @@
 mod intrinsic {
     #[legacy_exports];
 
-    pub use rusti::visit_tydesc;
+    pub use intrinsic::rusti::visit_tydesc;
 
     // FIXME (#3727): remove this when the interface has settled and the
     // version in sys is no longer present.
diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs
index 9c734f8e69873..bebddec94d34d 100644
--- a/src/librustc/metadata/creader.rs
+++ b/src/librustc/metadata/creader.rs
@@ -17,8 +17,8 @@ use syntax::visit;
 use syntax::codemap::span;
 use std::map::HashMap;
 use syntax::print::pprust;
-use filesearch::FileSearch;
-use common::*;
+use metadata::filesearch::FileSearch;
+use metadata::common::*;
 use dvec::DVec;
 use syntax::parse::token::ident_interner;
 
diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs
index 9dc4a01b7316d..ae56cf45dbcf2 100644
--- a/src/librustc/metadata/csearch.rs
+++ b/src/librustc/metadata/csearch.rs
@@ -10,19 +10,20 @@
 
 // Searching for information from the cstore
 
-use std::ebml;
+use metadata::common::*;
+use middle::ty;
+
+use core::dvec::DVec;
+use core::option::{Some, None};
 use reader = std::ebml::reader;
+use std::ebml;
+use std::map::HashMap;
 use syntax::ast;
-use syntax::ast_util;
 use syntax::ast_map;
-use middle::ty;
-use option::{Some, None};
-use syntax::diagnostic::span_handler;
+use syntax::ast_util::dummy_sp;
+use syntax::ast_util;
 use syntax::diagnostic::expect;
-use ast_util::dummy_sp;
-use common::*;
-use std::map::HashMap;
-use dvec::DVec;
+use syntax::diagnostic::span_handler;
 
 export struct_dtor;
 export get_symbol;
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 110b151a651ef..1e86eb78cfe3f 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -10,27 +10,28 @@
 
 // Decoding metadata from a single crate's metadata
 
+use cmd = metadata::cstore::crate_metadata;
+use dvec::DVec;
+use hash::{Hash, HashUtil};
+use io::WriterUtil;
+use metadata::common::*;
+use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
+use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data};
+use metadata::tydecode::{parse_ident};
+use middle::ty;
+use util::ppaux::ty_to_str;
+
+use reader = std::ebml::reader;
 use std::ebml;
-use std::map;
 use std::map::HashMap;
+use std::map;
 use std::serialization::deserialize;
-use reader = ebml::reader;
-use io::WriterUtil;
-use dvec::DVec;
-use syntax::{ast, ast_util};
-use syntax::attr;
-use middle::ty;
 use syntax::ast_map;
-use tydecode::{parse_ty_data, parse_def_id, parse_bounds_data,
-        parse_ident};
-use syntax::print::pprust;
-use cmd=cstore::crate_metadata;
-use util::ppaux::ty_to_str;
+use syntax::attr;
 use syntax::diagnostic::span_handler;
-use common::*;
 use syntax::parse::token::ident_interner;
-use hash::{Hash, HashUtil};
-use csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
+use syntax::print::pprust;
+use syntax::{ast, ast_util};
 
 export struct_dtor;
 export get_struct_fields;
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index e2a4b8880c91a..6000c20ba1bd0 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -15,12 +15,12 @@ use util::ppaux::ty_to_str;
 use std::{ebml, map};
 use std::map::HashMap;
 use io::WriterUtil;
-use writer = ebml::writer;
+use writer = std::ebml::writer;
 use syntax::ast::*;
 use syntax::print::pprust;
 use syntax::{ast_util, visit};
 use syntax::ast_util::*;
-use common::*;
+use metadata::common::*;
 use middle::ty;
 use middle::ty::node_id_to_type;
 use middle::resolve;
diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs
index b1a4fcc24cd54..5901e58aeb190 100644
--- a/src/librustc/metadata/loader.rs
+++ b/src/librustc/metadata/loader.rs
@@ -15,7 +15,7 @@ use syntax::{ast, attr};
 use syntax::print::pprust;
 use syntax::codemap::span;
 use lib::llvm::{False, llvm, mk_object_file, mk_section_iter};
-use filesearch::FileSearch;
+use metadata::filesearch::FileSearch;
 use io::WriterUtil;
 use syntax::parse::token::ident_interner;
 
diff --git a/src/librustc/metadata/mod.rs b/src/librustc/metadata/mod.rs
index 437900021368e..4ba6abb038310 100644
--- a/src/librustc/metadata/mod.rs
+++ b/src/librustc/metadata/mod.rs
@@ -41,35 +41,3 @@ mod loader;
 #[legacy_exports]
 mod filesearch;
 
-
-// Define the rustc API's that the metadata module has access to
-// Over time we will reduce these dependencies and, once metadata has
-// no dependencies on rustc it can move into its own crate.
-
-mod middle {
-    #[legacy_exports];
-    pub use middle_::ty;
-    pub use middle_::resolve;
-}
-
-mod front {
-    #[legacy_exports];
-}
-
-mod back {
-    #[legacy_exports];
-}
-
-mod driver {
-    #[legacy_exports];
-}
-
-mod util {
-    #[legacy_exports];
-    pub use util_::ppaux;
-}
-
-mod lib {
-    #[legacy_exports];
-    pub use lib_::llvm;
-}
diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs
index 1708027eaf9b8..9289e17eeb2db 100644
--- a/src/librustc/metadata/tydecode.rs
+++ b/src/librustc/metadata/tydecode.rs
@@ -13,13 +13,14 @@
 // tjc note: Would be great to have a `match check` macro equivalent
 // for some of these
 
+use middle::ty;
+use middle::ty::{FnTyBase, FnMeta, FnSig};
+
 use syntax::ast;
 use syntax::ast::*;
 use syntax::ast_util;
 use syntax::ast_util::respan;
-use middle::ty;
 use std::map::HashMap;
-use ty::{FnTyBase, FnMeta, FnSig};
 
 export parse_state_from_data;
 export parse_arg_data, parse_ty_data, parse_def_id, parse_ident;
diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index 781ac7809e70c..cf6b0bf332e41 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -8,46 +8,40 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use c = metadata::common;
+use cstore = metadata::cstore;
+use driver::session::Session;
+use e = metadata::encoder;
+use metadata::decoder;
+use metadata::encoder;
+use metadata::tydecode;
+use metadata::tyencode;
+use middle::freevars::freevar_entry;
+use middle::typeck::{method_origin, method_map_entry, vtable_res};
+use middle::typeck::{vtable_origin};
+use middle::{ty, typeck};
 use util::ppaux::ty_to_str;
 
+use reader = std::ebml::reader;
+use std::ebml::reader::get_doc;
+use std::ebml::writer::Serializer;
+use std::ebml;
+use std::map::HashMap;
+use std::serialization::{DeserializerHelpers, deserialize};
+use std::serialization::{Serializable, SerializerHelpers};
+use std::serialization;
 use syntax::ast;
-use syntax::fold;
-use syntax::fold::*;
-use syntax::visit;
 use syntax::ast_map;
 use syntax::ast_util;
 use syntax::codemap::span;
-use std::ebml;
-use writer = std::ebml::writer;
-use reader = std::ebml::reader;
-use reader::get_doc;
-use writer::Serializer;
-use std::map::HashMap;
-use std::serialization;
-use std::serialization::{Serializable,
-                         SerializerHelpers,
-                         DeserializerHelpers,
-                         deserialize};
-use middle::{ty, typeck};
-use middle::typeck::{method_origin, method_map_entry,
-                     vtable_res,
-                     vtable_origin};
-use driver::session::Session;
-use middle::freevars::freevar_entry;
-use c = metadata::common;
-use e = metadata::encoder;
-use cstore = metadata::cstore;
-use metadata::encoder;
-use metadata::decoder;
-use metadata::tyencode;
-use metadata::tydecode;
-
-
-// used in testing:
-use syntax::diagnostic;
 use syntax::codemap;
+use syntax::diagnostic;
+use syntax::fold::*;
+use syntax::fold;
 use syntax::parse;
 use syntax::print::pprust;
+use syntax::visit;
+use writer = std::ebml::writer;
 
 export maps;
 export encode_inlined_item;
diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs
index eafbe8b16abcf..d5809a7389e81 100644
--- a/src/librustc/middle/borrowck/gather_loans.rs
+++ b/src/librustc/middle/borrowck/gather_loans.rs
@@ -16,9 +16,9 @@
 // their associated scopes.  In phase two, checking loans, we will then make
 // sure that all of these loans are honored.
 
-use mem_categorization::{mem_categorization_ctxt, opt_deref_kind};
-use preserve::{preserve_condition, pc_ok, pc_if_pure};
-use ty::{ty_region};
+use middle::mem_categorization::{mem_categorization_ctxt, opt_deref_kind};
+use middle::borrowck::preserve::{preserve_condition, pc_ok, pc_if_pure};
+use middle::ty::{ty_region};
 
 use core::send_map::linear::LinearMap;
 
diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs
index c5a02c978f96a..90de32814470e 100644
--- a/src/librustc/middle/borrowck/mod.rs
+++ b/src/librustc/middle/borrowck/mod.rs
@@ -226,34 +226,36 @@ Borrowck results in two maps.
 
 #[legacy_exports];
 
-use syntax::ast;
+use middle::mem_categorization::*;
+use middle::ty::to_str;
+use util::common::indenter;
+use util::ppaux::{expr_repr, note_and_explain_region};
+use util::ppaux::{ty_to_str, region_to_str, explain_region};
+
+use core::dvec::DVec;
+use core::result::{Result, Ok, Err};
+use std::list::{List, Cons, Nil};
+use std::list;
+use std::map::{HashMap, Set};
 use syntax::ast::{mutability, m_mutbl, m_imm, m_const};
-use syntax::visit;
-use syntax::ast_util;
+use syntax::ast;
 use syntax::ast_map;
+use syntax::ast_util;
 use syntax::codemap::span;
-use util::ppaux::{ty_to_str, region_to_str, explain_region,
-                  expr_repr, note_and_explain_region};
-use std::map::{HashMap, Set};
-use std::list;
-use std::list::{List, Cons, Nil};
-use result::{Result, Ok, Err};
 use syntax::print::pprust;
-use util::common::indenter;
-use ty::to_str;
-use dvec::DVec;
-use mem_categorization::*;
+use syntax::visit;
 
 #[legacy_exports]
-mod check_loans;
+pub mod check_loans;
 #[legacy_exports]
-mod gather_loans;
+pub mod gather_loans;
 #[legacy_exports]
-mod loan;
+pub mod loan;
 #[legacy_exports]
-mod preserve;
+pub mod preserve;
 
 export check_crate, root_map, mutbl_map;
+export check_loans, gather_loans, loan, preserve;
 
 fn check_crate(tcx: ty::ctxt,
                method_map: typeck::method_map,
diff --git a/src/librustc/middle/check_alt.rs b/src/librustc/middle/check_alt.rs
index ff4fed8b37eed..d3448a5f3a9bc 100644
--- a/src/librustc/middle/check_alt.rs
+++ b/src/librustc/middle/check_alt.rs
@@ -8,19 +8,20 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use middle::const_eval::{compare_const_vals, lookup_const_by_id};
+use middle::const_eval::{eval_const_expr, const_val, const_int, const_bool};
+use middle::pat_util::*;
+use middle::ty::*;
+use middle::ty;
+use middle::typeck::method_map;
+use util::ppaux::ty_to_str;
+
+use std::map::HashMap;
 use syntax::ast::*;
 use syntax::ast_util::{variant_def_ids, dummy_sp, unguarded_pat, walk_pat};
-use const_eval::{eval_const_expr, const_val, const_int, const_bool,
-                 compare_const_vals, lookup_const_by_id};
 use syntax::codemap::span;
 use syntax::print::pprust::pat_to_str;
-use util::ppaux::ty_to_str;
-use pat_util::*;
 use syntax::visit;
-use middle::ty;
-use middle::ty::*;
-use middle::typeck::method_map;
-use std::map::HashMap;
 
 struct AltCheckCtxt {
     tcx: ty::ctxt,
diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs
index f483f922ed7ac..a51885b1fc7eb 100644
--- a/src/librustc/middle/const_eval.rs
+++ b/src/librustc/middle/const_eval.rs
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use syntax::{ast,ast_map,ast_util,visit};
-use ast::*;
+use syntax::{ast, ast_map, ast_util, visit};
+use syntax::ast::*;
 
 //
 // This pass classifies expressions by their constant-ness.
diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs
index f5edad9acc432..a8395013958eb 100644
--- a/src/librustc/middle/kind.rs
+++ b/src/librustc/middle/kind.rs
@@ -8,16 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use syntax::{visit, ast_util};
-use syntax::ast::*;
-use syntax::codemap::span;
-use middle::ty::{Kind, kind_copyable, kind_noncopyable, kind_const};
+use middle::freevars::freevar_entry;
+use middle::lint::{non_implicitly_copyable_typarams, implicit_copies};
 use middle::ty::{CopyValue, MoveValue, ReadValue};
-use std::map::HashMap;
+use middle::ty::{Kind, kind_copyable, kind_noncopyable, kind_const};
 use util::ppaux::{ty_to_str, tys_to_str};
+
+use std::map::HashMap;
+use syntax::ast::*;
+use syntax::codemap::span;
 use syntax::print::pprust::expr_to_str;
-use freevars::freevar_entry;
-use lint::{non_implicitly_copyable_typarams,implicit_copies};
+use syntax::{visit, ast_util};
 
 // Kind analysis pass.
 //
diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs
index e8fcbf123562c..48fff1a269bde 100644
--- a/src/librustc/middle/liveness.rs
+++ b/src/librustc/middle/liveness.rs
@@ -102,16 +102,17 @@
  *   to return explicitly.
  */
 
-use dvec::DVec;
+use middle::capture::{cap_move, cap_drop, cap_copy, cap_ref};
+use middle::ty::MoveValue;
+
+use core::dvec::DVec;
+use core::io::WriterUtil;
 use std::map::HashMap;
-use syntax::{visit, ast_util};
-use syntax::print::pprust::{expr_to_str, block_to_str};
-use visit::vt;
-use syntax::codemap::span;
 use syntax::ast::*;
-use io::WriterUtil;
-use capture::{cap_move, cap_drop, cap_copy, cap_ref};
-use middle::ty::MoveValue;
+use syntax::codemap::span;
+use syntax::print::pprust::{expr_to_str, block_to_str};
+use syntax::visit::vt;
+use syntax::{visit, ast_util};
 
 export check_crate;
 export last_use_map;
diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs
index 78c423b791d57..5819db17f58a8 100644
--- a/src/librustc/middle/privacy.rs
+++ b/src/librustc/middle/privacy.rs
@@ -11,6 +11,9 @@
 // A pass that checks to make sure private fields and methods aren't used
 // outside their scopes.
 
+use middle::ty::{ty_struct, ty_enum};
+use middle::typeck::{method_map, method_origin, method_param, method_self};
+use middle::typeck::{method_static, method_trait};
 use /*mod*/ syntax::ast;
 use /*mod*/ syntax::visit;
 use syntax::ast_map;
@@ -21,9 +24,6 @@ use syntax::ast::{provided, required};
 use syntax::ast_map::{node_item, node_method};
 use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local};
 use syntax::ast_util::{visibility_to_privacy};
-use ty::{ty_struct, ty_enum};
-use typeck::{method_map, method_origin, method_param, method_self};
-use typeck::{method_static, method_trait};
 
 use core::util::ignore;
 use dvec::DVec;
diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs
index 4d5e29678a184..f746e0236807e 100644
--- a/src/librustc/middle/region.rs
+++ b/src/librustc/middle/region.rs
@@ -18,18 +18,19 @@ region parameterized.
 */
 
 use driver::session::Session;
-use middle::ty;
-use syntax::{ast, visit};
-use syntax::codemap::span;
-use syntax::print::pprust;
-use syntax::ast_map;
-use dvec::DVec;
 use metadata::csearch;
-use ty::{region_variance, rv_covariant, rv_invariant, rv_contravariant};
+use middle::ty::{region_variance, rv_covariant, rv_invariant};
+use middle::ty::{rv_contravariant};
+use middle::ty;
 
+use core::dvec::DVec;
 use std::list;
 use std::list::list;
 use std::map::HashMap;
+use syntax::ast_map;
+use syntax::codemap::span;
+use syntax::print::pprust;
+use syntax::{ast, visit};
 
 type parent = Option<ast::node_id>;
 
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index bc987db48cd66..bc728e5319a33 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -313,6 +313,16 @@ enum XrayFlag {
     Xray        //< Private items can be accessed.
 }
 
+enum UseLexicalScopeFlag {
+    DontUseLexicalScope,
+    UseLexicalScope
+}
+
+struct ModulePrefixResult {
+    result: ResolveResult<@Module>,
+    prefix_len: uint
+}
+
 impl XrayFlag : cmp::Eq {
     pure fn eq(&self, other: &XrayFlag) -> bool {
         ((*self) as uint) == ((*other) as uint)
@@ -2108,9 +2118,10 @@ impl Resolver {
         } else {
             // First, resolve the module path for the directive, if necessary.
             match self.resolve_module_path_for_import(module_,
-                                                    module_path,
-                                                    NoXray,
-                                                    import_directive.span) {
+                                                      module_path,
+                                                      NoXray,
+                                                      DontUseLexicalScope,
+                                                      import_directive.span) {
 
                 Failed => {
                     resolution_result = Failed;
@@ -2650,8 +2661,11 @@ impl Resolver {
 
         while index < module_path_len {
             let name = (*module_path).get_elt(index);
-            match self.resolve_name_in_module(search_module, name, TypeNS,
-                                              xray) {
+            match self.resolve_name_in_module(search_module,
+                                              name,
+                                              TypeNS,
+                                              xray,
+                                              false) {
                 Failed => {
                     self.session.span_err(span, ~"unresolved name");
                     return Failed;
@@ -2702,12 +2716,13 @@ impl Resolver {
     }
 
     /**
-     * Attempts to resolve the module part of an import directive rooted at
-     * the given module.
+     * Attempts to resolve the module part of an import directive or path
+     * rooted at the given module.
      */
     fn resolve_module_path_for_import(module_: @Module,
                                       module_path: @DVec<ident>,
                                       xray: XrayFlag,
+                                      use_lexical_scope: UseLexicalScopeFlag,
                                       span: span)
                                    -> ResolveResult<@Module> {
 
@@ -2722,9 +2737,20 @@ impl Resolver {
         // The first element of the module path must be in the current scope
         // chain.
 
-        let first_element = (*module_path).get_elt(0);
+        let resolve_result = match use_lexical_scope {
+            DontUseLexicalScope => {
+                self.resolve_module_prefix(module_, module_path)
+            }
+            UseLexicalScope => {
+                let result = self.resolve_module_in_lexical_scope(
+                    module_,
+                    module_path.get_elt(0));
+                ModulePrefixResult { result: result, prefix_len: 1 }
+            }
+        };
+
         let mut search_module;
-        match self.resolve_module_in_lexical_scope(module_, first_element) {
+        match resolve_result.result {
             Failed => {
                 self.session.span_err(span, ~"unresolved name");
                 return Failed;
@@ -2740,10 +2766,10 @@ impl Resolver {
         }
 
         return self.resolve_module_path_from_root(search_module,
-                                               module_path,
-                                               1,
-                                               xray,
-                                               span);
+                                                  module_path,
+                                                  resolve_result.prefix_len,
+                                                  xray,
+                                                  span);
     }
 
     fn resolve_item_in_lexical_scope(module_: @Module,
@@ -2811,8 +2837,11 @@ impl Resolver {
             }
 
             // Resolve the name in the parent module.
-            match self.resolve_name_in_module(search_module, name, namespace,
-                                            Xray) {
+            match self.resolve_name_in_module(search_module,
+                                              name,
+                                              namespace,
+                                              Xray,
+                                              false) {
                 Failed => {
                     // Continue up the search chain.
                 }
@@ -2832,9 +2861,15 @@ impl Resolver {
         }
     }
 
+    /** Resolves a module name in the current lexical scope. */
     fn resolve_module_in_lexical_scope(module_: @Module, name: ident)
                                     -> ResolveResult<@Module> {
-        match self.resolve_item_in_lexical_scope(module_, name, TypeNS) {
+        // If this module is an anonymous module, resolve the item in the
+        // lexical scope. Otherwise, resolve the item from the crate root.
+        let resolve_result = self.resolve_item_in_lexical_scope(module_,
+                                                                name,
+                                                                TypeNS);
+        match resolve_result {
             Success(target) => {
                 match target.bindings.type_def {
                     Some(ref type_def) => {
@@ -2870,6 +2905,102 @@ impl Resolver {
         }
     }
 
+    /**
+     * Resolves a "module prefix". A module prefix is one of (a) the name of a
+     * module; (b) "self::"; (c) some chain of "super::".
+     */
+    fn resolve_module_prefix(module_: @Module,
+                             module_path: @DVec<ident>)
+                          -> ModulePrefixResult {
+        let interner = self.session.parse_sess.interner;
+
+        let mut containing_module = self.graph_root.get_module();
+        let mut i = 0;
+        loop {
+            if *interner.get(module_path.get_elt(i)) == ~"self" {
+                containing_module = module_;
+                i += 1;
+                break;
+            }
+            if *interner.get(module_path.get_elt(i)) == ~"super" {
+                match containing_module.parent_link {
+                    NoParentLink => {
+                        return ModulePrefixResult {
+                            result: Failed,
+                            prefix_len: i
+                        };
+                    }
+                    BlockParentLink(new_module, _) |
+                    ModuleParentLink(new_module, _) => {
+                        containing_module = new_module;
+                    }
+                }
+                i += 1;
+            } else {
+                break;
+            }
+        }
+
+        // Is the containing module the current module? If so, we allow
+        // globs to be unresolved.
+        let allow_globs = core::managed::ptr_eq(containing_module, module_);
+
+        let name = module_path.get_elt(i);
+        let resolve_result = self.resolve_name_in_module(containing_module,
+                                                         name,
+                                                         TypeNS,
+                                                         Xray,
+                                                         allow_globs);
+        match resolve_result {
+            Success(target) => {
+                match target.bindings.type_def {
+                    Some(ref type_def) => {
+                        match (*type_def).module_def {
+                            None => {
+                                error!("!!! (resolving crate-relative \
+                                        module) module wasn't actually a \
+                                        module!");
+                                return ModulePrefixResult {
+                                    result: Failed,
+                                    prefix_len: i + 1
+                                };
+                            }
+                            Some(module_def) => {
+                                return ModulePrefixResult {
+                                    result: Success(module_def),
+                                    prefix_len: i + 1
+                                };
+                            }
+                        }
+                    }
+                    None => {
+                        error!("!!! (resolving crate-relative module) module
+                                wasn't actually a module!");
+                        return ModulePrefixResult {
+                            result: Failed,
+                            prefix_len: i + 1
+                        };
+                    }
+                }
+            }
+            Indeterminate => {
+                debug!("(resolving crate-relative module) indeterminate; \
+                        bailing");
+                return ModulePrefixResult {
+                    result: Indeterminate,
+                    prefix_len: i + 1
+                };
+            }
+            Failed => {
+                debug!("(resolving crate-relative module) failed to resolve");
+                return ModulePrefixResult {
+                    result: Failed,
+                    prefix_len: i + 1
+                };
+            }
+        }
+    }
+
     fn name_is_exported(module_: @Module, name: ident) -> bool {
         return !module_.legacy_exports ||
             module_.exported_names.size() == 0 ||
@@ -2884,7 +3015,8 @@ impl Resolver {
     fn resolve_name_in_module(module_: @Module,
                               name: ident,
                               namespace: Namespace,
-                              xray: XrayFlag)
+                              xray: XrayFlag,
+                              allow_globs: bool)
                            -> ResolveResult<Target> {
 
         debug!("(resolving name in module) resolving `%s` in `%s`",
@@ -2910,10 +3042,10 @@ impl Resolver {
             }
         }
 
-        // Next, check the module's imports. If the module has a glob, then
-        // we bail out; we don't know its imports yet.
-
-        if module_.glob_count > 0 {
+        // Next, check the module's imports. If the module has a glob and
+        // globs were not allowed, then we bail out; we don't know its imports
+        // yet.
+        if !allow_globs && module_.glob_count > 0 {
             debug!("(resolving name in module) module has glob; bailing out");
             return Indeterminate;
         }
@@ -4627,10 +4759,10 @@ impl Resolver {
 
         let mut containing_module;
         match self.resolve_module_path_for_import(self.current_module,
-                                                module_path_idents,
-                                                xray,
-                                                path.span) {
-
+                                                  module_path_idents,
+                                                  xray,
+                                                  UseLexicalScope,
+                                                  path.span) {
             Failed => {
                 self.session.span_err(path.span,
                                       fmt!("use of undeclared module `%s`",
diff --git a/src/librustc/middle/trans/alt.rs b/src/librustc/middle/trans/alt.rs
index 5d5b578355607..7885a8ea0b601 100644
--- a/src/librustc/middle/trans/alt.rs
+++ b/src/librustc/middle/trans/alt.rs
@@ -142,26 +142,27 @@
  *
  */
 
+use back::abi;
 use lib::llvm::llvm;
 use lib::llvm::{ValueRef, BasicBlockRef};
-use pat_util::*;
-use build::*;
-use base::*;
+use middle::pat_util::*;
+use middle::resolve::DefMap;
+use middle::trans::base::*;
+use middle::trans::build::*;
+use middle::trans::common::*;
+use middle::trans::datum::*;
+use middle::trans::expr::Dest;
+use middle::ty::{CopyValue, MoveValue, ReadValue};
+use util::common::indenter;
+
+use core::dvec::DVec;
+use std::map::HashMap;
+use syntax::ast::def_id;
 use syntax::ast;
-use syntax::ast_util;
 use syntax::ast_util::{dummy_sp, path_to_ident};
-use syntax::ast::def_id;
+use syntax::ast_util;
 use syntax::codemap::span;
 use syntax::print::pprust::pat_to_str;
-use middle::resolve::DefMap;
-use middle::ty::{CopyValue, MoveValue, ReadValue};
-use back::abi;
-use std::map::HashMap;
-use dvec::DVec;
-use datum::*;
-use common::*;
-use expr::Dest;
-use util::common::indenter;
 
 fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
 
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index cf6207dee588a..a65f6668cd358 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -23,45 +23,44 @@
 //     but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
 //     int) and rec(x=int, y=int, z=int) will have the same TypeRef.
 
-use libc::{c_uint, c_ulonglong};
-use std::{map, time, list};
-use std::map::HashMap;
-use driver::session;
-use session::Session;
-use syntax::attr;
+use back::link::{mangle_exported_name};
+use back::link::{mangle_internal_name_by_path_and_seq};
+use back::link::{mangle_internal_name_by_path};
+use back::link::{mangle_internal_name_by_seq};
+use back::link::{mangle_internal_name_by_type_only};
 use back::{link, abi, upcall};
-use syntax::{ast, ast_util, codemap, ast_map};
-use ast_util::{def_id_of_def, local_def, path_to_ident};
-use syntax::visit;
-use syntax::codemap::span;
-use syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str};
-use pat_util::*;
-use visit::vt;
-use util::common::is_main_name;
-use lib::llvm::{llvm, mk_target_data, mk_type_names};
+use driver::session;
+use driver::session::Session;
 use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef};
 use lib::llvm::{True, False};
-use link::{mangle_internal_name_by_type_only,
-              mangle_internal_name_by_seq,
-              mangle_internal_name_by_path,
-              mangle_internal_name_by_path_and_seq,
-              mangle_exported_name};
-use metadata::{csearch, cstore, decoder, encoder};
+use lib::llvm::{llvm, mk_target_data, mk_type_names};
 use metadata::common::link_meta;
-use util::ppaux;
-use util::ppaux::{ty_to_str, ty_to_short_str};
-use syntax::diagnostic::expect;
+use metadata::{csearch, cstore, decoder, encoder};
+use middle::pat_util::*;
+use middle::trans::build::*;
+use middle::trans::common::*;
+use middle::trans::shape::*;
+use middle::trans::type_of::*;
 use util::common::indenter;
+use util::common::is_main_name;
+use util::ppaux::{ty_to_str, ty_to_short_str};
+use util::ppaux;
 
-use build::*;
-use shape::*;
-use type_of::*;
-use common::*;
+use core::libc::{c_uint, c_ulonglong};
+use core::option::{is_none, is_some};
+use std::map::HashMap;
+use std::smallintmap;
+use std::{map, time, list};
 use syntax::ast_map::{path, path_mod, path_name};
+use syntax::ast_util::{def_id_of_def, local_def, path_to_ident};
+use syntax::attr;
+use syntax::codemap::span;
+use syntax::diagnostic::expect;
 use syntax::parse::token::special_idents;
-
-use std::smallintmap;
-use option::{is_none, is_some};
+use syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str};
+use syntax::visit;
+use syntax::visit::vt;
+use syntax::{ast, ast_util, codemap, ast_map};
 
 struct icx_popper {
     ccx: @crate_ctxt,
@@ -1228,7 +1227,7 @@ fn with_scope_datumblock(bcx: block, opt_node_info: Option<node_info>,
                          name: ~str, f: fn(block) -> datum::DatumBlock)
     -> datum::DatumBlock
 {
-    use datum::DatumBlock;
+    use middle::trans::datum::DatumBlock;
 
     let _icx = bcx.insn_ctxt("with_scope_result");
     let scope_cx = scope_block(bcx, opt_node_info, name);
diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs
index acb7fac19f800..614a02a970052 100644
--- a/src/librustc/middle/trans/build.rs
+++ b/src/librustc/middle/trans/build.rs
@@ -8,15 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::map::HashMap;
-use libc::{c_uint, c_int};
-use lib::llvm::llvm;
-use syntax::codemap;
 use codemap::span;
+use lib::llvm::llvm;
+use lib::llvm::{CallConv, TypeKind, AtomicBinOp, AtomicOrdering};
+use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False};
 use lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef};
-use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False,
-        CallConv, TypeKind, AtomicBinOp, AtomicOrdering};
-use common::*;
+use libc::{c_uint, c_int};
+use middle::trans::common::*;
+
+use std::map::HashMap;
+use syntax::codemap;
 
 fn B(cx: block) -> BuilderRef {
     let b = cx.fcx.ccx.builder.B;
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index 50bf0cf39c889..7117ae6910cc2 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -17,15 +17,16 @@
 // closure.
 
 use lib::llvm::ValueRef;
+use middle::trans::base::{get_item_val, trans_external_path};
+use middle::trans::build::*;
+use middle::trans::common::{block, node_id_type_params};
+use middle::trans::datum::*;
+use middle::trans::datum::Datum;
+use util::common::indenter;
+
 use syntax::ast;
-use datum::Datum;
-use common::{block, node_id_type_params};
-use build::*;
-use base::{get_item_val, trans_external_path};
-use syntax::visit;
 use syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str};
-use datum::*;
-use util::common::indenter;
+use syntax::visit;
 
 // Represents a (possibly monomorphized) top-level fn item or method
 // item.  Note that this is just the fn-ptr and is not a Rust closure
diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs
index 2796cca68388f..5110bc261f7a9 100644
--- a/src/librustc/middle/trans/closure.rs
+++ b/src/librustc/middle/trans/closure.rs
@@ -8,26 +8,25 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use libc::c_uint;
-use syntax::ast;
-use syntax::ast_util;
+use back::abi;
+use back::link::{mangle_internal_name_by_path_and_seq};
+use back::link::{mangle_internal_name_by_path};
 use lib::llvm::llvm;
 use lib::llvm::{ValueRef, TypeRef};
-use common::*;
-use build::*;
-use base::*;
-use type_of::*;
-use back::abi;
-use syntax::codemap::span;
-use syntax::print::pprust::expr_to_str;
-use back::link::{
-    mangle_internal_name_by_path,
-    mangle_internal_name_by_path_and_seq};
+use middle::trans::base::*;
+use middle::trans::build::*;
+use middle::trans::common::*;
+use middle::trans::datum::{Datum, INIT, ByRef, ByValue, FromLvalue};
+use middle::trans::type_of::*;
 use util::ppaux::ty_to_str;
-use syntax::ast_map::{path, path_mod, path_name};
-use driver::session::session;
+
+use core::libc::c_uint;
 use std::map::HashMap;
-use datum::{Datum, INIT, ByRef, ByValue, FromLvalue};
+use syntax::ast;
+use syntax::ast_map::{path, path_mod, path_name};
+use syntax::ast_util;
+use syntax::codemap::span;
+use syntax::print::pprust::expr_to_str;
 
 // ___Good to know (tm)__________________________________________________
 //
diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs
index d1b5ece9b0ce6..355e78014805d 100644
--- a/src/librustc/middle/trans/consts.rs
+++ b/src/librustc/middle/trans/consts.rs
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use common::*;
+use middle::trans::base::get_insn_ctxt;
+use middle::trans::common::*;
+
 use syntax::{ast, ast_util, codemap, ast_map};
-use base::get_insn_ctxt;
 
 fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
     -> ValueRef {
diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs
index e7d3c8a207c4e..2a9cece231b73 100644
--- a/src/librustc/middle/trans/controlflow.rs
+++ b/src/librustc/middle/trans/controlflow.rs
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 use lib::llvm::ValueRef;
-use common::*;
-use datum::*;
-use base::*;
+use middle::trans::base::*;
+use middle::trans::common::*;
+use middle::trans::datum::*;
 
 fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
 
diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs
index 5fc6a9ed0ba6f..e303b3611c577 100644
--- a/src/librustc/middle/trans/datum.rs
+++ b/src/librustc/middle/trans/datum.rs
@@ -96,11 +96,11 @@
  * values. */
 
 use lib::llvm::ValueRef;
-use base::*;
-use common::*;
-use build::*;
-use util::ppaux::ty_to_str;
+use middle::trans::base::*;
+use middle::trans::build::*;
+use middle::trans::common::*;
 use util::common::indenter;
+use util::ppaux::ty_to_str;
 
 enum CopyAction {
     INIT,
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index e201493ca2b83..b255b47bab30b 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -8,21 +8,22 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::map;
-use std::map::HashMap;
-use lib::llvm::llvm;
+use driver::session;
 use lib::llvm::ValueRef;
-use trans::common::*;
-use trans::base;
-use trans::build::B;
+use lib::llvm::llvm;
+use middle::pat_util::*;
+use middle::trans::base;
+use middle::trans::build::B;
+use middle::trans::common::*;
 use middle::ty;
-use syntax::{ast, codemap, ast_util, ast_map};
-use syntax::parse::token::ident_interner;
-use codemap::{span, CharPos};
-use ast::Ty;
-use pat_util::*;
 use util::ppaux::ty_to_str;
-use driver::session::session;
+
+use std::map::HashMap;
+use std::map;
+use syntax::ast::Ty;
+use syntax::codemap::{span, CharPos};
+use syntax::parse::token::ident_interner;
+use syntax::{ast, codemap, ast_util, ast_map};
 
 export create_local_var;
 export create_function;
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs
index 59a1206bd0d02..764ddabd1434f 100644
--- a/src/librustc/middle/trans/expr.rs
+++ b/src/librustc/middle/trans/expr.rs
@@ -111,17 +111,18 @@ lvalues are *never* stored by value.
 
 */
 
-use ty::struct_mutable_fields;
 use lib::llvm::ValueRef;
-use common::*;
-use datum::*;
-use base::*;
-use syntax::print::pprust::{expr_to_str};
-use util::ppaux::ty_to_str;
-use util::common::indenter;
-use ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn};
-use callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
+use middle::trans::base::*;
+use middle::trans::callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
+use middle::trans::common::*;
+use middle::trans::datum::*;
 use middle::ty::MoveValue;
+use middle::ty::struct_mutable_fields;
+use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn};
+use util::common::indenter;
+use util::ppaux::ty_to_str;
+
+use syntax::print::pprust::{expr_to_str};
 
 // The primary two functions for translating expressions:
 export trans_to_datum, trans_into;
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index bef7d01e81947..38c3a4f7cb358 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -11,26 +11,27 @@
 // The classification code for the x86_64 ABI is taken from the clay language
 // https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
 
+use back::{link, abi};
 use driver::session::arch_x86_64;
+use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg};
+use lib::llvm::{Struct, Array, ModuleRef, CallConv, Attribute};
+use lib::llvm::{StructRetAttribute, ByValAttribute};
+use lib::llvm::{llvm, TypeRef, ValueRef, Integer, Pointer, Float, Double};
+use middle::trans::base::*;
+use middle::trans::build::*;
+use middle::trans::callee::*;
+use middle::trans::common::*;
+use middle::trans::datum::*;
+use middle::trans::expr::{Dest, Ignore};
+use middle::trans::type_of::*;
+use middle::ty::{FnTyBase, FnMeta, FnSig};
+use util::ppaux::ty_to_str;
+
+use core::libc::c_uint;
+use std::map::HashMap;
 use syntax::codemap::span;
-use libc::c_uint;
-use syntax::{attr, ast_map};
-use lib::llvm::{ llvm, TypeRef, ValueRef, Integer, Pointer, Float, Double,
-    Struct, Array, ModuleRef, CallConv, Attribute,
-    StructRetAttribute, ByValAttribute,
-    SequentiallyConsistent, Acquire, Release, Xchg };
 use syntax::{ast, ast_util};
-use back::{link, abi};
-use common::*;
-use build::*;
-use base::*;
-use type_of::*;
-use std::map::HashMap;
-use util::ppaux::ty_to_str;
-use datum::*;
-use callee::*;
-use expr::{Dest, Ignore};
-use ty::{FnTyBase, FnMeta, FnSig};
+use syntax::{attr, ast_map};
 
 export link_name, trans_foreign_mod, register_foreign_fn, trans_foreign_fn,
        trans_intrinsic;
diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs
index 647ed2275b5e1..a42dee615e4b5 100644
--- a/src/librustc/middle/trans/glue.rs
+++ b/src/librustc/middle/trans/glue.rs
@@ -13,10 +13,10 @@
 // Code relating to taking, dropping, etc as well as type descriptors.
 
 use lib::llvm::{ValueRef, TypeRef};
-use base::*;
-use common::*;
-use build::*;
-use type_of::type_of;
+use middle::trans::base::*;
+use middle::trans::common::*;
+use middle::trans::build::*;
+use middle::trans::type_of::type_of;
 
 fn trans_free(cx: block, v: ValueRef) -> block {
     let _icx = cx.insn_ctxt("trans_free");
diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs
index f65ac09227596..6f5aa792c4748 100644
--- a/src/librustc/middle/trans/inline.rs
+++ b/src/librustc/middle/trans/inline.rs
@@ -8,12 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use common::*;
+use middle::trans::base::{get_insn_ctxt};
+use middle::trans::base::{impl_owned_self, impl_self, no_self};
+use middle::trans::base::{trans_item, get_item_val, self_arg, trans_fn};
+use middle::trans::common::*;
+
 use syntax::ast;
-use syntax::ast_util::local_def;
 use syntax::ast_map::{path, path_mod, path_name};
-use base::{trans_item, get_item_val, self_arg, trans_fn, impl_owned_self,
-           impl_self, no_self, get_insn_ctxt};
+use syntax::ast_util::local_def;
 
 // `translate` will be true if this function is allowed to translate the
 // item and false otherwise. Currently, this parameter is set to false when
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index d214208560419..0488ed1e5b3da 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -8,25 +8,25 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use libc::c_uint;
-use base::*;
-use common::*;
-use type_of::*;
-use build::*;
-use driver::session::{session, expect};
-use syntax::{ast, ast_map};
-use ast_map::{path, path_mod, path_name, node_id_to_str};
-use syntax::ast_util::local_def;
-use metadata::csearch;
 use back::{link, abi};
+use lib::llvm::llvm::LLVMGetParam;
 use lib::llvm::llvm;
 use lib::llvm::{ValueRef, TypeRef};
-use lib::llvm::llvm::LLVMGetParam;
-use std::map::HashMap;
+use metadata::csearch;
+use middle::trans::base::*;
+use middle::trans::build::*;
+use middle::trans::callee::*;
+use middle::trans::common::*;
+use middle::trans::expr::{SaveIn, Ignore};
+use middle::trans::type_of::*;
 use util::ppaux::{ty_to_str, tys_to_str};
-use callee::*;
+
+use core::libc::c_uint;
+use std::map::HashMap;
+use syntax::ast_map::{path, path_mod, path_name, node_id_to_str};
+use syntax::ast_util::local_def;
 use syntax::print::pprust::expr_to_str;
-use expr::{SaveIn, Ignore};
+use syntax::{ast, ast_map};
 
 fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
 
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index c5a93ecd89d3c..9d662f875510c 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -8,19 +8,20 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use common::*;
+use back::link::mangle_exported_name;
+use middle::trans::base::{get_insn_ctxt};
+use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint};
+use middle::trans::base::{trans_enum_variant, trans_struct_dtor};
+use middle::trans::base::{trans_fn, impl_self, decl_internal_cdecl_fn};
+use middle::trans::base::{trans_item, get_item_val, no_self, self_arg};
+use middle::trans::common::*;
+use middle::trans::type_of::type_of_fn_from_ty;
+use middle::ty::{FnTyBase, FnMeta, FnSig};
+
 use syntax::ast;
-use syntax::ast_util::local_def;
 use syntax::ast_map::{path, path_mod, path_name};
-use base::{trans_item, get_item_val, no_self, self_arg, trans_fn,
-              impl_self, decl_internal_cdecl_fn,
-              set_inline_hint_if_appr, set_inline_hint,
-              trans_enum_variant, trans_struct_dtor,
-              get_insn_ctxt};
+use syntax::ast_util::local_def;
 use syntax::parse::token::special_idents;
-use type_of::type_of_fn_from_ty;
-use back::link::mangle_exported_name;
-use middle::ty::{FnTyBase, FnMeta, FnSig};
 
 fn monomorphic_fn(ccx: @crate_ctxt,
                   fn_id: ast::def_id,
diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs
index bc85a57a64bb4..d15a9c101b955 100644
--- a/src/librustc/middle/trans/reflect.rs
+++ b/src/librustc/middle/trans/reflect.rs
@@ -8,19 +8,20 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::map::HashMap;
-use lib::llvm::{TypeRef, ValueRef};
-use syntax::ast;
 use back::abi;
-use common::*;
-use build::*;
-use base::*;
-use type_of::*;
-use ast::def_id;
+use lib::llvm::{TypeRef, ValueRef};
+use middle::trans::base::*;
+use middle::trans::build::*;
+use middle::trans::callee::{ArgVals, DontAutorefArg};
+use middle::trans::common::*;
+use middle::trans::datum::*;
+use middle::trans::expr::SaveIn;
+use middle::trans::type_of::*;
 use util::ppaux::ty_to_str;
-use datum::*;
-use callee::{ArgVals, DontAutorefArg};
-use expr::SaveIn;
+
+use std::map::HashMap;
+use syntax::ast::def_id;
+use syntax::ast;
 
 enum reflector = {
     visitor_val: ValueRef,
diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs
index a95e25d625f7f..51c3cb9362f39 100644
--- a/src/librustc/middle/trans/shape.rs
+++ b/src/librustc/middle/trans/shape.rs
@@ -11,25 +11,23 @@
 // A "shape" is a compact encoding of a type that is used by interpreted glue.
 // This substitutes for the runtime tags used by e.g. MLs.
 
+use back::abi;
 use lib::llvm::llvm;
 use lib::llvm::{True, False, ModuleRef, TypeRef, ValueRef};
-use driver::session;
-use driver::session::session;
-use trans::base;
+use middle::trans::base;
 use middle::trans::common::*;
 use middle::trans::machine::*;
-use back::abi;
-use middle::ty;
 use middle::ty::field;
-use syntax::ast;
-use syntax::ast_util::dummy_sp;
-use syntax::util::interner;
+use middle::ty;
 use util::ppaux::ty_to_str;
-use syntax::codemap::span;
-use dvec::DVec;
 
+use core::dvec::DVec;
+use core::option::is_some;
 use std::map::HashMap;
-use option::is_some;
+use syntax::ast;
+use syntax::ast_util::dummy_sp;
+use syntax::codemap::span;
+use syntax::util::interner;
 
 use ty_ctxt = middle::ty::ctxt;
 
diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs
index 0504ce6d5699b..2eaf15818d89f 100644
--- a/src/librustc/middle/trans/tvec.rs
+++ b/src/librustc/middle/trans/tvec.rs
@@ -8,18 +8,19 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use syntax::ast;
-use lib::llvm::{ValueRef, TypeRef};
 use back::abi;
-use syntax::codemap::span;
-use shape::llsize_of;
-use build::*;
-use common::*;
+use lib::llvm::{ValueRef, TypeRef};
+use middle::trans::build::*;
+use middle::trans::common::*;
+use middle::trans::datum::*;
+use middle::trans::expr::{Dest, Ignore, SaveIn};
+use middle::trans::shape::llsize_of;
+use util::common::indenter;
 use util::ppaux::ty_to_str;
-use expr::{Dest, SaveIn, Ignore};
-use datum::*;
+
+use syntax::ast;
+use syntax::codemap::span;
 use syntax::print::pprust::{expr_to_str};
-use util::common::indenter;
 
 // Boxed vector types are in some sense currently a "shorthand" for a box
 // containing an unboxed vector. This expands a boxed vector type into such an
diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs
index 086407c8186b4..f146d556a9d9a 100644
--- a/src/librustc/middle/trans/type_of.rs
+++ b/src/librustc/middle/trans/type_of.rs
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use common::*;
-use lib::llvm::{TypeRef};
-use syntax::ast;
 use lib::llvm::llvm;
-use driver::session::session;
+use lib::llvm::{TypeRef};
+use middle::trans::common::*;
+
 use std::map::HashMap;
+use syntax::ast;
 
 export type_of;
 export type_of_dtor;
diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs
index 33200a2dd828a..2f9a97aa2d883 100644
--- a/src/librustc/middle/trans/type_use.rs
+++ b/src/librustc/middle/trans/type_use.rs
@@ -27,13 +27,16 @@
 // much information, but have the disadvantage of being very
 // invasive.)
 
-use std::map::HashMap;
-use std::list;
-use std::list::{List, Cons, Nil};
 use metadata::csearch;
-use syntax::ast::*, syntax::ast_util, syntax::visit;
+use middle::trans::common::*;
+
+use std::list::{List, Cons, Nil};
+use std::list;
+use std::map::HashMap;
+use syntax::ast::*;
 use syntax::ast_map;
-use common::*;
+use syntax::ast_util;
+use syntax::visit;
 
 type type_uses = uint; // Bitmask
 const use_repr: uint = 1u;   /* Dependency on size/alignment/mode and
diff --git a/src/librustc/middle/trans/uniq.rs b/src/librustc/middle/trans/uniq.rs
index 6a1fe50776dac..30d47d60e5892 100644
--- a/src/librustc/middle/trans/uniq.rs
+++ b/src/librustc/middle/trans/uniq.rs
@@ -8,12 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use syntax::ast;
 use lib::llvm::ValueRef;
-use common::*;
-use build::*;
-use base::*;
-use datum::immediate_rvalue;
+use middle::trans::base::*;
+use middle::trans::build::*;
+use middle::trans::common::*;
+use middle::trans::datum::immediate_rvalue;
+
+use syntax::ast;
 
 export make_free_glue, autoderef, duplicate;
 
diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs
index f037bffb4838e..37958f84d5962 100644
--- a/src/librustc/middle/typeck/astconv.rs
+++ b/src/librustc/middle/typeck/astconv.rs
@@ -52,12 +52,13 @@
  * an rptr (`&r.T`) use the region `r` that appears in the rptr.
  */
 
-use check::fn_ctxt;
-use rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope};
-use rscope::{in_binding_rscope, region_scope, type_rscope};
-use ty::{FnTyBase, FnMeta, FnSig};
+use middle::ty::{FnTyBase, FnMeta, FnSig};
+use middle::typeck::check::fn_ctxt;
+use middle::typeck::rscope::{anon_rscope, binding_rscope, empty_rscope};
+use middle::typeck::rscope::{in_anon_rscope, in_binding_rscope};
+use middle::typeck::rscope::{region_scope, type_rscope};
 
-trait ast_conv {
+pub trait ast_conv {
     fn tcx() -> ty::ctxt;
     fn ccx() -> @crate_ctxt;
     fn get_item_ty(id: ast::def_id) -> ty::ty_param_bounds_and_ty;
@@ -141,7 +142,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Owned>(
     {substs: substs, ty: ty::subst(tcx, &substs, decl_ty)}
 }
 
-fn ast_path_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
+pub fn ast_path_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
     self: AC,
     rscope: RS,
     did: ast::def_id,
diff --git a/src/librustc/middle/typeck/check/alt.rs b/src/librustc/middle/typeck/check/alt.rs
index ec39c659cf59c..9432ca186f94e 100644
--- a/src/librustc/middle/typeck/check/alt.rs
+++ b/src/librustc/middle/typeck/check/alt.rs
@@ -8,9 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use middle::pat_util::{pat_is_binding, pat_is_const};
+use middle::pat_util::{pat_is_variant_or_struct};
+
+use syntax::ast_util::walk_pat;
 use syntax::print::pprust;
-use syntax::ast_util::{walk_pat};
-use pat_util::{pat_is_binding, pat_is_const, pat_is_variant_or_struct};
 
 fn check_alt(fcx: @fn_ctxt,
              expr: @ast::expr,
diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs
index a7e1da6ed7df7..89726e22283d9 100644
--- a/src/librustc/middle/typeck/check/demand.rs
+++ b/src/librustc/middle/typeck/check/demand.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use check::fn_ctxt;
+use middle::typeck::check::fn_ctxt;
 
 // Requires that the two types unify, and prints an error message if they
 // don't.
@@ -18,10 +18,10 @@ fn suptype(fcx: @fn_ctxt, sp: span,
         |sp, e, a, s| { fcx.report_mismatched_types(sp, e, a, s) })
 }
 
-fn suptype_with_fn(fcx: @fn_ctxt, sp: span,
-           expected: ty::t, actual: ty::t,
+fn suptype_with_fn(fcx: @fn_ctxt,
+                   sp: span,
+                   expected: ty::t, actual: ty::t,
                    handle_err: fn(span, ty::t, ty::t, &ty::type_err)) {
-
     // n.b.: order of actual, expected is reversed
     match infer::mk_subty(fcx.infcx(), false, sp,
                           actual, expected) {
@@ -32,9 +32,7 @@ fn suptype_with_fn(fcx: @fn_ctxt, sp: span,
     }
 }
 
-fn eqtype(fcx: @fn_ctxt, sp: span,
-          expected: ty::t, actual: ty::t) {
-
+fn eqtype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) {
     match infer::mk_eqty(fcx.infcx(), false, sp, actual, expected) {
         Ok(()) => { /* ok */ }
         Err(ref err) => {
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs
index 2b1078e7dd459..8dfcb8c7bd986 100644
--- a/src/librustc/middle/typeck/check/method.rs
+++ b/src/librustc/middle/typeck/check/method.rs
@@ -79,16 +79,18 @@ obtained the type `Foo`, we would never match this method.
 
 */
 
-use coherence::get_base_type_def_id;
 use middle::resolve::{Impl, MethodInfo};
 use middle::ty::*;
-use syntax::ast::{def_id, sty_by_ref, sty_value, sty_region, sty_box,
-                  sty_uniq, sty_static, node_id, by_copy, by_ref,
-                  m_const, m_mutbl, m_imm};
+use middle::typeck::check;
+use middle::typeck::coherence::get_base_type_def_id;
+
+use core::dvec::DVec;
+use syntax::ast::{def_id, sty_by_ref, sty_value, sty_region, sty_box};
+use syntax::ast::{sty_uniq, sty_static, node_id, by_copy, by_ref};
+use syntax::ast::{m_const, m_mutbl, m_imm};
 use syntax::ast_map;
 use syntax::ast_map::node_id_to_str;
 use syntax::ast_util::dummy_sp;
-use dvec::DVec;
 
 fn lookup(
     fcx: @fn_ctxt,
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index 7611f62609f33..ace51539727ba 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -76,35 +76,51 @@ type parameter).
 
 */
 
-use astconv::{ast_conv, ast_path_to_ty, ast_ty_to_ty};
-use astconv::{ast_region_to_region};
 use middle::ty::{TyVid, vid, FnTyBase, FnMeta, FnSig, VariantInfo_};
-use regionmanip::{replace_bound_regions_in_fn_ty};
-use rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope};
-use rscope::{in_binding_rscope, region_scope, type_rscope,
-                bound_self_region};
+use middle::typeck::astconv::{ast_conv, ast_path_to_ty};
+use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty};
+use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_ty;
+use middle::typeck::check::vtable::{LocationInfo, VtableContext};
+use middle::typeck::infer::{resolve_type, force_tvar};
+use middle::typeck::rscope::{anon_rscope, binding_rscope, bound_self_region};
+use middle::typeck::rscope::{empty_rscope, in_anon_rscope};
+use middle::typeck::rscope::{in_binding_rscope, region_scope, type_rscope};
+use util::ppaux;
+
+use core::result::{Result, Ok, Err};
+use std::map::HashMap;
 use syntax::ast::ty_i;
-use typeck::infer::{resolve_type, force_tvar};
-use result::{Result, Ok, Err};
-use syntax::print::pprust;
-use syntax::parse::token::special_idents;
 use syntax::ast_util::{is_local, visibility_to_privacy, Private, Public};
-use vtable::{LocationInfo, VtableContext};
+use syntax::parse::token::special_idents;
+use syntax::print::pprust;
 
-use std::map::HashMap;
+export alt;
+export vtable;
+export writeback;
+export regionmanip;
+export regionck;
+export demand;
+export method;
+export fn_ctxt;
+export lookup_local;
+export impl_self_ty;
+export DerefArgs;
+export DontDerefArgs;
+export DoDerefArgs;
+export check_item_types;
 
 #[legacy_exports]
-mod alt;
+pub mod alt;
 #[legacy_exports]
-mod vtable;
+pub mod vtable;
 #[legacy_exports]
-mod writeback;
+pub mod writeback;
 #[legacy_exports]
-mod regionmanip;
+pub mod regionmanip;
 #[legacy_exports]
-mod regionck;
+pub mod regionck;
 #[legacy_exports]
-mod demand;
+pub mod demand;
 #[legacy_exports]
 pub mod method;
 
@@ -135,7 +151,7 @@ struct inherited {
 
 enum FnKind { ForLoop, DoBlock, Vanilla }
 
-struct fn_ctxt {
+pub struct fn_ctxt {
     // var_bindings, locals and next_var_id are shared
     // with any nested functions that capture the environment
     // (and with any functions whose environment is being captured).
@@ -252,9 +268,9 @@ fn check_fn(ccx: @crate_ctxt,
     let ret_ty = fn_ty.sig.output;
 
     debug!("check_fn(arg_tys=%?, ret_ty=%?, self_info.self_ty=%?)",
-           arg_tys.map(|a| ty_to_str(tcx, *a)),
-           ty_to_str(tcx, ret_ty),
-           option::map(&self_info, |s| ty_to_str(tcx, s.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)));
 
     // ______________________________________________________________________
     // Create the function context.  This is either derived from scratch or,
@@ -631,7 +647,7 @@ impl @fn_ctxt {
     #[inline(always)]
     fn write_ty(node_id: ast::node_id, ty: ty::t) {
         debug!("write_ty(%d, %s) in fcx %s",
-               node_id, ty_to_str(self.tcx(), ty), self.tag());
+               node_id, ppaux::ty_to_str(self.tcx(), ty), self.tag());
         self.inh.node_types.insert(node_id, ty);
     }
 
@@ -793,12 +809,13 @@ impl @fn_ctxt {
                     self.tcx().sess.span_err(sp, fmt!("A for-loop body must \
                         return (), but it returns %s here. \
                         Perhaps you meant to write a `do`-block?",
-                                            ty_to_str(self.tcx(), a))),
+                                            ppaux::ty_to_str(self.tcx(), a))),
             DoBlock if ty::type_is_bool(e) && ty::type_is_nil(a) =>
                 // If we expected bool and got ()...
                     self.tcx().sess.span_err(sp, fmt!("Do-block body must \
                         return %s, but returns () here. Perhaps you meant \
-                        to write a `for`-loop?", ty_to_str(self.tcx(), e))),
+                        to write a `for`-loop?",
+                        ppaux::ty_to_str(self.tcx(), e))),
             _ => self.infcx().report_mismatched_types(sp, e, a, err)
         }
     }
@@ -921,10 +938,11 @@ fn check_expr(fcx: @fn_ctxt, expr: @ast::expr,
 // declared on the impl declaration e.g., `impl<A,B> for ~[(A,B)]`
 // would return ($0, $1) where $0 and $1 are freshly instantiated type
 // variables.
-fn impl_self_ty(vcx: &VtableContext,
-                location_info: &LocationInfo, // (potential) receiver for
-                                              // this impl
-                did: ast::def_id) -> ty_param_substs_and_ty {
+pub fn impl_self_ty(vcx: &VtableContext,
+                    location_info: &LocationInfo, // (potential) receiver for
+                                                  // this impl
+                    did: ast::def_id)
+                 -> ty_param_substs_and_ty {
     let tcx = vcx.tcx();
 
     let {n_tps, region_param, raw_ty} = if did.crate == ast::local_crate {
@@ -1540,7 +1558,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
 
                 // (1) verify that the class id actually has a field called
                 // field
-                debug!("class named %s", ty_to_str(tcx, base_t));
+                debug!("class named %s", ppaux::ty_to_str(tcx, base_t));
                 let cls_items = ty::lookup_struct_fields(tcx, base_id);
                 match lookup_field_ty(tcx, base_id, cls_items,
                                       field, &(*substs)) {
@@ -2400,9 +2418,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
 
     debug!("type of expr %s is %s, expected is %s",
            syntax::print::pprust::expr_to_str(expr, tcx.sess.intr()),
-           ty_to_str(tcx, fcx.expr_ty(expr)),
+           ppaux::ty_to_str(tcx, fcx.expr_ty(expr)),
            match expected {
-               Some(t) => ty_to_str(tcx, t),
+               Some(t) => ppaux::ty_to_str(tcx, t),
                _ => ~"empty"
            });
 
@@ -2565,7 +2583,7 @@ fn check_instantiable(tcx: ty::ctxt,
         tcx.sess.span_err(sp, fmt!("this type cannot be instantiated \
                   without an instance of itself; \
                   consider using `option<%s>`",
-                                   ty_to_str(tcx, item_ty)));
+                                   ppaux::ty_to_str(tcx, item_ty)));
     }
 }
 
@@ -2678,7 +2696,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
     check_instantiable(ccx.tcx, sp, id);
 }
 
-fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> TyVid {
+pub fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> TyVid {
     match fcx.inh.locals.find(id) {
         Some(x) => x,
         _ => {
@@ -2893,7 +2911,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
                          tps: ~[ast::ty_param],
                          ty: ty::t) {
     debug!("check_bounds_are_used(n_tps=%u, ty=%s)",
-           tps.len(), ty_to_str(ccx.tcx, ty));
+           tps.len(), ppaux::ty_to_str(ccx.tcx, ty));
 
     // make a vector of booleans initially false, set to true when used
     if tps.len() == 0u { return; }
@@ -3158,6 +3176,6 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
             tcx, None, false, it.span, i_ty.ty, fty,
             || fmt!("intrinsic has wrong type: \
                       expected `%s`",
-                     ty_to_str(ccx.tcx, fty)));
+                     ppaux::ty_to_str(ccx.tcx, fty)));
     }
 }
diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs
index 0f4511218ec82..e58add83c0944 100644
--- a/src/librustc/middle/typeck/check/regionck.rs
+++ b/src/librustc/middle/typeck/check/regionck.rs
@@ -27,18 +27,18 @@ this point a bit better.
 
 */
 
-use util::ppaux;
-use ppaux::{note_and_explain_region, ty_to_str};
-use syntax::print::pprust;
-use infer::{resolve_and_force_all_but_regions, fres};
-use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar};
-use syntax::ast::{ProtoBare, ProtoBox, ProtoUniq, ProtoBorrowed};
 use middle::freevars::get_freevars;
 use middle::kind::check_owned;
 use middle::pat_util::pat_bindings;
 use middle::ty::{encl_region, re_scope};
 use middle::ty::{ty_fn_proto, vstore_box, vstore_fixed, vstore_slice};
 use middle::ty::{vstore_uniq};
+use middle::typeck::infer::{resolve_and_force_all_but_regions, fres};
+use util::ppaux::{note_and_explain_region, ty_to_str};
+
+use syntax::ast::{ProtoBare, ProtoBox, ProtoUniq, ProtoBorrowed};
+use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar};
+use syntax::print::pprust;
 
 enum rcx { rcx_({fcx: @fn_ctxt, mut errors_reported: uint}) }
 type rvt = visit::vt<@rcx>;
diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs
index 8431c175eff53..0bcb032d8259c 100644
--- a/src/librustc/middle/typeck/check/regionmanip.rs
+++ b/src/librustc/middle/typeck/check/regionmanip.rs
@@ -11,6 +11,8 @@
 // #[warn(deprecated_mode)];
 // #[warn(deprecated_pattern)];
 
+use util::ppaux;
+
 use syntax::print::pprust::{expr_to_str};
 
 // Helper functions related to manipulating region types.
@@ -47,9 +49,9 @@ fn replace_bound_regions_in_fn_ty(
 
     debug!("replace_bound_regions_in_fn_ty(self_info.self_ty=%?, fn_ty=%s, \
                 all_tys=%?)",
-           self_ty.map(|t| ty_to_str(tcx, *t)),
-           ty_to_str(tcx, ty::mk_fn(tcx, *fn_ty)),
-           all_tys.map(|t| ty_to_str(tcx, *t)));
+           self_ty.map(|t| ppaux::ty_to_str(tcx, *t)),
+           ppaux::ty_to_str(tcx, ty::mk_fn(tcx, *fn_ty)),
+           all_tys.map(|t| ppaux::ty_to_str(tcx, *t)));
     let _i = indenter();
 
     let isr = do create_bound_region_mapping(tcx, isr, all_tys) |br| {
@@ -64,8 +66,8 @@ fn replace_bound_regions_in_fn_ty(
 
     debug!("result of replace_bound_regions_in_fn_ty: self_info.self_ty=%?, \
                 fn_ty=%s",
-           t_self.map(|t| ty_to_str(tcx, *t)),
-           ty_to_str(tcx, t_fn));
+           t_self.map(|t| ppaux::ty_to_str(tcx, *t)),
+           ppaux::ty_to_str(tcx, t_fn));
 
 
     // Glue updated self_ty back together with its original def_id.
diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs
index 0494f1563cf99..5751a46276064 100644
--- a/src/librustc/middle/typeck/check/vtable.rs
+++ b/src/librustc/middle/typeck/check/vtable.rs
@@ -8,13 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use check::{fn_ctxt, impl_self_ty};
-use infer::{infer_ctxt, resolve_type, resolve_and_force_all_but_regions,
-               fixup_err_to_str};
+use middle::typeck::check::{fn_ctxt, impl_self_ty};
+use middle::typeck::infer::{fixup_err_to_str, infer_ctxt};
+use middle::typeck::infer::{resolve_and_force_all_but_regions, resolve_type};
+use util::common::indenter;
+use util::ppaux;
+
+use result::{Result, Ok, Err};
 use syntax::codemap::span;
 use syntax::print::pprust;
-use result::{Result, Ok, Err};
-use util::common::indenter;
 
 // vtable resolution looks for places where trait bounds are
 // subsituted in and figures out which vtable is used. There is some
@@ -81,14 +83,14 @@ fn lookup_vtables(vcx: &VtableContext,
             tcx, bounds[i]) |trait_ty| {
 
             debug!("about to subst: %?, %?",
-                   ty_to_str(tcx, trait_ty),
+                   ppaux::ty_to_str(tcx, trait_ty),
                    ty::substs_to_str(tcx, substs));
 
             let new_substs = {self_ty: Some(*ty), ..*substs};
             let trait_ty = ty::subst(tcx, &new_substs, trait_ty);
 
             debug!("after subst: %?",
-                   ty_to_str(tcx, trait_ty));
+                   ppaux::ty_to_str(tcx, trait_ty));
 
             match lookup_vtable(vcx, location_info, *ty, trait_ty,
                                 allow_unsafe, is_early) {
@@ -98,8 +100,8 @@ fn lookup_vtables(vcx: &VtableContext,
                         location_info.span,
                         fmt!("failed to find an implementation of \
                               trait %s for %s",
-                             ty_to_str(vcx.tcx(), trait_ty),
-                             ty_to_str(vcx.tcx(), *ty)));
+                             ppaux::ty_to_str(vcx.tcx(), trait_ty),
+                             ppaux::ty_to_str(vcx.tcx(), *ty)));
                 }
             }
         }
@@ -664,8 +666,8 @@ fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
                             ex.span,
                             fmt!("failed to find an implementation of trait \
                                   %s for %s",
-                                 ty_to_str(fcx.tcx(), target_ty),
-                                 ty_to_str(fcx.tcx(), ty)));
+                                 ppaux::ty_to_str(fcx.tcx(), target_ty),
+                                 ppaux::ty_to_str(fcx.tcx(), ty)));
                     }
                 }
                 Some(vtable) => {
diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs
index 12d8f06a3f610..dd3f240f34343 100644
--- a/src/librustc/middle/typeck/check/writeback.rs
+++ b/src/librustc/middle/typeck/check/writeback.rs
@@ -12,11 +12,15 @@
 // unresolved type variables and replaces "ty_var" types with their
 // substitutions.
 
-use check::{fn_ctxt, lookup_local};
-use infer::{resolve_type, resolve_region, resolve_all, force_all};
+use middle::typeck::check::{fn_ctxt, lookup_local};
+use middle::typeck::infer::{force_all, resolve_all, resolve_region};
+use middle::typeck::infer::{resolve_type};
+use util::ppaux;
+
+use result::{Result, Ok, Err};
+
 export resolve_type_vars_in_fn;
 export resolve_type_vars_in_expr;
-use result::{Result, Ok, Err};
 
 fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t)
     -> Option<ty::t>
@@ -97,7 +101,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id)
 
       Some(t) => {
         debug!("resolve_type_vars_for_node(id=%d, n_ty=%s, t=%s)",
-               id, ty_to_str(tcx, n_ty), ty_to_str(tcx, t));
+               id, ppaux::ty_to_str(tcx, n_ty), ppaux::ty_to_str(tcx, t));
         write_ty_to_tcx(tcx, id, t);
         match fcx.opt_node_ty_substs(id) {
           Some(ref substs) => {
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index 3e5986f5236e6..3ab3ac387f9ce 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -43,11 +43,11 @@ use syntax::visit::{mk_simple_visitor, mk_vt, visit_crate, visit_item};
 use syntax::visit::{visit_mod};
 use util::ppaux::ty_to_str;
 
-use dvec::DVec;
-use result::Ok;
+use core::dvec::DVec;
+use core::result::Ok;
 use std::map::HashMap;
-use uint::range;
-use vec::{len, push};
+use core::uint::range;
+use core::vec::{len, push};
 
 fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t)
               -> Option<t> {
diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs
index 5614c3aac8019..8e8d7380f8f39 100644
--- a/src/librustc/middle/typeck/collect.rs
+++ b/src/librustc/middle/typeck/collect.rs
@@ -30,14 +30,16 @@ are represented as `ty_param()` instances.
 
 */
 
-use astconv::{ast_conv, ty_of_fn_decl, ty_of_arg, ast_ty_to_ty};
-use ast_util::trait_method_to_ty_method;
-use middle::ty::{FnMeta, FnSig, FnTyBase};
-use rscope::*;
-use ty::{FnTyBase, FnMeta, FnSig, InstantiatedTraitRef};
+use middle::ty::{FnMeta, FnSig, FnTyBase, InstantiatedTraitRef};
+use middle::typeck::astconv::{ast_conv, ty_of_fn_decl, ty_of_arg};
+use middle::typeck::astconv::{ast_ty_to_ty};
+use middle::typeck::rscope::*;
 use util::common::pluralize;
+use util::ppaux;
 use util::ppaux::bound_to_str;
 
+use syntax::ast_util::trait_method_to_ty_method;
+
 fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
 
     // FIXME (#2592): hooking into the "intrinsic" root module is crude.
@@ -403,10 +405,10 @@ fn compare_impl_method(tcx: ty::ctxt,
     // - replace self region with a fresh, dummy region
     let impl_fty = {
         let impl_fty = ty::mk_fn(tcx, impl_m.fty);
-        debug!("impl_fty (pre-subst): %s", ty_to_str(tcx, impl_fty));
+        debug!("impl_fty (pre-subst): %s", ppaux::ty_to_str(tcx, impl_fty));
         replace_bound_self(tcx, impl_fty, dummy_self_r)
     };
-    debug!("impl_fty: %s", ty_to_str(tcx, impl_fty));
+    debug!("impl_fty: %s", ppaux::ty_to_str(tcx, impl_fty));
     let trait_fty = {
         let dummy_tps = do vec::from_fn((*trait_m.tps).len()) |i| {
             // hack: we don't know the def id of the impl tp, but it
@@ -421,7 +423,7 @@ fn compare_impl_method(tcx: ty::ctxt,
             tps: vec::append(trait_tps, dummy_tps)
         };
         let trait_fty = ty::mk_fn(tcx, trait_m.fty);
-        debug!("trait_fty (pre-subst): %s", ty_to_str(tcx, trait_fty));
+        debug!("trait_fty (pre-subst): %s", ppaux::ty_to_str(tcx, trait_fty));
         ty::subst(tcx, &substs, trait_fty)
     };
 
@@ -574,7 +576,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
       ast::item_trait(tps, supertraits, ref trait_methods) => {
         let tpt = ty_of_item(ccx, it);
         debug!("item_trait(it.id=%d, tpt.ty=%s)",
-               it.id, ty_to_str(tcx, tpt.ty));
+               it.id, ppaux::ty_to_str(tcx, tpt.ty));
         write_ty_to_tcx(tcx, it.id, tpt.ty);
         ensure_trait_methods(ccx, it.id, tpt.ty);
         ensure_supertraits(ccx, it.id, it.span, rp, supertraits);
@@ -774,7 +776,9 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
                    region_param: None,
                    ty: ty::mk_fn(ccx.tcx, tofd)};
         debug!("type of %s (id %d) is %s",
-               tcx.sess.str_of(it.ident), it.id, ty_to_str(tcx, tpt.ty));
+               tcx.sess.str_of(it.ident),
+               it.id,
+               ppaux::ty_to_str(tcx, tpt.ty));
         ccx.tcx.tcache.insert(local_def(it.id), tpt);
         return tpt;
       }
diff --git a/src/librustc/middle/typeck/infer/assignment.rs b/src/librustc/middle/typeck/infer/assignment.rs
index 2ceff545eb73a..1abe2156a1ebb 100644
--- a/src/librustc/middle/typeck/infer/assignment.rs
+++ b/src/librustc/middle/typeck/infer/assignment.rs
@@ -58,8 +58,8 @@
 // A.  But this upper-bound might be stricter than what is truly
 // needed.
 
-use to_str::ToStr;
-use combine::combine_fields;
+use middle::typeck::infer::combine::combine_fields;
+use middle::typeck::infer::to_str::ToStr;
 
 fn to_ares(+c: cres<ty::t>) -> ares {
     match c {
diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs
index 1972be22b02ff..da66ecd922b68 100644
--- a/src/librustc/middle/typeck/infer/combine.rs
+++ b/src/librustc/middle/typeck/infer/combine.rs
@@ -54,8 +54,9 @@
 // terms of error reporting, although we do not do that properly right
 // now.
 
-use to_str::ToStr;
-use ty::{FnTyBase, FnMeta, FnSig};
+use middle::ty::{FnTyBase, FnMeta, FnSig};
+use middle::typeck::infer::to_str::ToStr;
+
 use syntax::ast::Onceness;
 
 fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
@@ -92,7 +93,7 @@ trait combine {
                a: ty::vstore, b: ty::vstore) -> cres<ty::vstore>;
 }
 
-struct combine_fields {
+pub struct combine_fields {
     infcx: infer_ctxt,
     a_is_expected: bool,
     span: span,
@@ -108,7 +109,7 @@ fn expected_found<C: combine,T>(
     }
 }
 
-fn eq_tys<C: combine>(self: &C, a: ty::t, b: ty::t) -> ures {
+pub fn eq_tys<C: combine>(self: &C, a: ty::t, b: ty::t) -> ures {
     let suber = self.sub();
     do self.infcx().try {
         do suber.tys(a, b).chain |_ok| {
diff --git a/src/librustc/middle/typeck/infer/floating.rs b/src/librustc/middle/typeck/infer/floating.rs
index 48b49c9c59c77..9537325c097f8 100644
--- a/src/librustc/middle/typeck/infer/floating.rs
+++ b/src/librustc/middle/typeck/infer/floating.rs
@@ -14,8 +14,8 @@ Code related to floating-point type inference.
 
 */
 
-use to_str::ToStr;
 use middle::ty::ty_float;
+use middle::typeck::infer::to_str::ToStr;
 
 // Bitvector to represent sets of floating-point types.
 pub enum float_ty_set = uint;
diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs
index 4d00b5f7d3c1d..b6e179d27a91b 100644
--- a/src/librustc/middle/typeck/infer/glb.rs
+++ b/src/librustc/middle/typeck/infer/glb.rs
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use combine::*;
-use lattice::*;
-use to_str::ToStr;
+use middle::typeck::infer::combine::*;
+use middle::typeck::infer::lattice::*;
+use middle::typeck::infer::to_str::ToStr;
+
 use syntax::ast::{Many, Once};
 
 enum Glb = combine_fields;  // "greatest lower bound" (common subtype)
diff --git a/src/librustc/middle/typeck/infer/integral.rs b/src/librustc/middle/typeck/infer/integral.rs
index 40f0bb1ac3e67..f3e5e1ac73e62 100644
--- a/src/librustc/middle/typeck/infer/integral.rs
+++ b/src/librustc/middle/typeck/infer/integral.rs
@@ -14,7 +14,7 @@ Code related to integral type inference.
 
 */
 
-use to_str::ToStr;
+use middle::typeck::infer::to_str::ToStr;
 
 // Bitvector to represent sets of integral types
 enum int_ty_set = uint;
diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs
index fba0c5650040e..b47dd2064522e 100644
--- a/src/librustc/middle/typeck/infer/lattice.rs
+++ b/src/librustc/middle/typeck/infer/lattice.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use combine::*;
-use unify::*;
-use to_str::ToStr;
+use middle::typeck::infer::combine::*;
+use middle::typeck::infer::unify::*;
+use middle::typeck::infer::to_str::ToStr;
 
 // ______________________________________________________________________
 // Lattice operations on variables
diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs
index 563435d4600ee..cfb93e93a65ba 100644
--- a/src/librustc/middle/typeck/infer/lub.rs
+++ b/src/librustc/middle/typeck/infer/lub.rs
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use combine::*;
-use lattice::*;
-use to_str::ToStr;
+use middle::typeck::infer::combine::*;
+use middle::typeck::infer::lattice::*;
+use middle::typeck::infer::to_str::ToStr;
+
 use syntax::ast::{Many, Once};
 
 fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs
index 0d0a1d761cc14..fb8ca5632910e 100644
--- a/src/librustc/middle/typeck/infer/mod.rs
+++ b/src/librustc/middle/typeck/infer/mod.rs
@@ -259,40 +259,40 @@ section on "Type Combining" below for details.
 #[warn(deprecated_mode)];
 #[warn(deprecated_pattern)];
 
-use std::smallintmap;
-use std::smallintmap::smallintmap;
-use std::map::HashMap;
+use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, vid};
+use middle::ty::{mk_fn, type_is_bot};
+use middle::ty::{ty_int, ty_uint, get, terr_fn, TyVar, IntVar, FloatVar};
 use middle::ty;
-use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, vid,
-                 ty_int, ty_uint, get, terr_fn, TyVar, IntVar, FloatVar};
-use syntax::{ast, ast_util};
-use syntax::ast::{ret_style, purity};
-use util::ppaux::{ty_to_str, mt_to_str};
-use result::{Result, Ok, Err, map_vec, map_vec2, iter_vec2};
-use ty::{mk_fn, type_is_bot};
-use check::regionmanip::{replace_bound_regions_in_fn_ty};
+use middle::typeck::check::regionmanip::{replace_bound_regions_in_fn_ty};
+use middle::typeck::infer::assignment::Assign;
+use middle::typeck::infer::combine::{combine_fields, eq_tys};
+use middle::typeck::infer::floating::{float_ty_set, float_ty_set_all};
+use middle::typeck::infer::glb::Glb;
+use middle::typeck::infer::integral::{int_ty_set, int_ty_set_all};
+use middle::typeck::infer::lub::Lub;
+use middle::typeck::infer::region_inference::{RegionVarBindings};
+use middle::typeck::infer::resolve::{force_all, not_regions};
+use middle::typeck::infer::resolve::{force_tvar, force_rvar, force_ivar};
+use middle::typeck::infer::resolve::{resolve_and_force_all_but_regions};
+use middle::typeck::infer::resolve::{resolve_ivar, resolve_all};
+use middle::typeck::infer::resolve::{resolve_nested_tvar, resolve_rvar};
+use middle::typeck::infer::resolve::{resolver};
+use middle::typeck::infer::sub::Sub;
+use middle::typeck::infer::to_str::ToStr;
+use middle::typeck::infer::unify::{vals_and_bindings, root};
 use util::common::{indent, indenter};
-use ast::{unsafe_fn, impure_fn, pure_fn, extern_fn};
-use ast::{m_const, m_imm, m_mutbl};
-use dvec::DVec;
-use region_inference::{RegionVarBindings};
-use ast_util::dummy_sp;
-use cmp::Eq;
-
-// From submodules:
-use resolve::{resolve_nested_tvar, resolve_rvar, resolve_ivar, resolve_all,
-                 force_tvar, force_rvar, force_ivar, force_all, not_regions,
-                 resolve_and_force_all_but_regions, resolver};
-use unify::{vals_and_bindings, root};
-use integral::{int_ty_set, int_ty_set_all};
-use floating::{float_ty_set, float_ty_set_all};
-use combine::{combine_fields, eq_tys};
-use assignment::Assign;
-use to_str::ToStr;
-
-use sub::Sub;
-use lub::Lub;
-use glb::Glb;
+use util::ppaux::{ty_to_str, mt_to_str};
+
+use core::cmp::Eq;
+use core::dvec::DVec;
+use core::result::{Result, Ok, Err, map_vec, map_vec2, iter_vec2};
+use std::map::HashMap;
+use std::smallintmap;
+use syntax::ast::{ret_style, purity};
+use syntax::ast::{m_const, m_imm, m_mutbl};
+use syntax::ast::{unsafe_fn, impure_fn, pure_fn, extern_fn};
+use syntax::ast_util::dummy_sp;
+use syntax::{ast, ast_util};
 
 export infer_ctxt;
 export new_infer_ctxt;
@@ -311,6 +311,18 @@ export cres, fres, fixup_err, fixup_err_to_str;
 export assignment;
 export root, to_str;
 export int_ty_set_all;
+export assignment;
+export combine;
+export floating;
+export glb;
+export integral;
+export lattice;
+export lub;
+export region_inference;
+export resolve;
+export sub;
+export to_str;
+export unify;
 
 #[legacy_exports]
 mod assignment;
diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs
index f49d174001869..99d636559dbc2 100644
--- a/src/librustc/middle/typeck/infer/region_inference.rs
+++ b/src/librustc/middle/typeck/infer/region_inference.rs
@@ -453,20 +453,20 @@ write it)
 #[warn(deprecated_mode)];
 #[warn(deprecated_pattern)];
 
-use dvec::DVec;
+use middle::region::is_subregion_of;
+use middle::ty::{Region, RegionVid, re_static, re_infer, re_free, re_bound};
+use middle::ty::{re_scope, ReVar, ReSkolemized};
+use middle::typeck::infer::to_str::ToStr;
+use syntax::codemap;
+use util::ppaux::note_and_explain_region;
+
+use core::dvec::DVec;
 use result::Result;
 use result::{Ok, Err};
 use std::map::HashMap;
 use std::cell::{Cell, empty_cell};
 use std::list::{List, Nil, Cons};
 
-use region::is_subregion_of;
-use ty::{Region, RegionVid, re_static, re_infer, re_free, re_bound,
-         re_scope, ReVar, ReSkolemized};
-use syntax::codemap;
-use to_str::ToStr;
-use util::ppaux::note_and_explain_region;
-
 export RegionVarBindings;
 export make_subregion;
 export lub_regions;
diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs
index 437d5ade6bd21..91689ff06ddc9 100644
--- a/src/librustc/middle/typeck/infer/resolve.rs
+++ b/src/librustc/middle/typeck/infer/resolve.rs
@@ -46,9 +46,9 @@
 // future).  If you want to resolve everything but one type, you are
 // probably better off writing `resolve_all - resolve_ivar`.
 
-use integral::*;
-use floating::*;
-use to_str::ToStr;
+use middle::typeck::infer::floating::*;
+use middle::typeck::infer::integral::*;
+use middle::typeck::infer::to_str::ToStr;
 
 const resolve_nested_tvar: uint = 0b00000001;
 const resolve_rvar: uint        = 0b00000010;
diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs
index b7769ac876d1b..1cec971f15629 100644
--- a/src/librustc/middle/typeck/infer/sub.rs
+++ b/src/librustc/middle/typeck/infer/sub.rs
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use combine::*;
-use unify::*;
-use to_str::ToStr;
+use middle::typeck::infer::combine::*;
+use middle::typeck::infer::to_str::ToStr;
+use middle::typeck::infer::unify::*;
+
 use std::list;
 
 fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
diff --git a/src/librustc/middle/typeck/infer/to_str.rs b/src/librustc/middle/typeck/infer/to_str.rs
index a882f20c04b42..166907ba7a862 100644
--- a/src/librustc/middle/typeck/infer/to_str.rs
+++ b/src/librustc/middle/typeck/infer/to_str.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use integral::{int_ty_set};
-use floating::{float_ty_set};
-use unify::{var_value, redirect, root};
+use middle::typeck::infer::integral::int_ty_set;
+use middle::typeck::infer::floating::float_ty_set;
+use middle::typeck::infer::unify::{redirect, root, var_value};
 
 trait ToStr {
     fn to_str(cx: infer_ctxt) -> ~str;
diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs
index 452e950dba600..2ec356a6dc845 100644
--- a/src/librustc/middle/typeck/infer/unify.rs
+++ b/src/librustc/middle/typeck/infer/unify.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use combine::combine;
-use integral::*;
-use floating::*;
-use to_str::ToStr;
+use middle::typeck::infer::combine::combine;
+use middle::typeck::infer::floating::*;
+use middle::typeck::infer::integral::*;
+use middle::typeck::infer::to_str::ToStr;
+
 use std::smallintmap::SmallIntMap;
 
 enum var_value<V:Copy, T:Copy> {
diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs
index e128f6a03fb59..aaf53e017388a 100644
--- a/src/librustc/middle/typeck/mod.rs
+++ b/src/librustc/middle/typeck/mod.rs
@@ -50,31 +50,31 @@ independently:
 
 #[legacy_exports];
 
-use result::Result;
-use syntax::{ast, ast_util, ast_map};
-use ast::spanned;
-use ast::{required, provided};
-use syntax::ast_map::node_id_to_str;
-use syntax::ast_util::{local_def, respan, split_trait_methods,
-                       has_legacy_export_attr};
-use syntax::visit;
 use metadata::csearch;
-use util::common::{block_query, loop_query};
-use syntax::codemap::span;
-use pat_util::{pat_id_map, PatIdMap};
-use middle::ty;
+use middle::pat_util::{pat_id_map, PatIdMap};
 use middle::ty::{arg, field, node_type_table, mk_nil, ty_param_bounds_and_ty};
 use middle::ty::{ty_param_substs_and_ty, vstore_uniq};
-use std::smallintmap;
-use std::map;
+use middle::ty;
+use util::common::{block_query, indent, indenter, loop_query};
+use util::ppaux::{bound_region_to_str, vstore_to_str, expr_repr};
+use util::ppaux::{ty_to_str, tys_to_str, region_to_str};
+use util::ppaux;
+
+use core::dvec::DVec;
+use core::result::Result;
+use std::list::{List, Nil, Cons};
+use std::list;
 use std::map::HashMap;
+use std::map;
+use std::smallintmap;
+use syntax::ast::{provided, required, spanned};
+use syntax::ast_map::node_id_to_str;
+use syntax::ast_util::{has_legacy_export_attr};
+use syntax::ast_util::{local_def, respan, split_trait_methods};
+use syntax::codemap::span;
 use syntax::print::pprust::*;
-use util::ppaux::{ty_to_str, tys_to_str, region_to_str,
-                  bound_region_to_str, vstore_to_str, expr_repr};
-use util::common::{indent, indenter};
-use std::list;
-use list::{List, Nil, Cons};
-use dvec::DVec;
+use syntax::visit;
+use syntax::{ast, ast_util, ast_map};
 
 export check;
 export check_crate;
@@ -89,24 +89,31 @@ export method_static, method_param, method_trait, method_self;
 export vtable_static, vtable_param, vtable_trait;
 export provided_methods_map;
 export coherence;
+export check;
+export rscope;
+export astconv;
+export infer;
+export collect;
+export coherence;
+export deriving;
 
 #[legacy_exports]
 #[path = "check/mod.rs"]
 pub mod check;
 #[legacy_exports]
-mod rscope;
+pub mod rscope;
 #[legacy_exports]
-mod astconv;
+pub mod astconv;
 #[path = "infer/mod.rs"]
-mod infer;
+pub mod infer;
 #[legacy_exports]
-mod collect;
+pub mod collect;
 #[legacy_exports]
-mod coherence;
+pub mod coherence;
 
 #[auto_serialize]
 #[auto_deserialize]
-enum method_origin {
+pub enum method_origin {
     // fully statically resolved method
     method_static(ast::def_id),
 
@@ -139,7 +146,7 @@ type method_param = {
     bound_num: uint
 };
 
-type method_map_entry = {
+pub type method_map_entry = {
     // the type and mode of the self parameter, which is not reflected
     // in the fn type (FIXME #3446)
     self_arg: ty::arg,
@@ -153,12 +160,12 @@ type method_map_entry = {
 
 // maps from an expression id that corresponds to a method call to the details
 // of the method to be invoked
-type method_map = HashMap<ast::node_id, method_map_entry>;
+pub type method_map = HashMap<ast::node_id, method_map_entry>;
 
 // Resolutions for bounds of all parameters, left to right, for a given path.
-type vtable_res = @~[vtable_origin];
+pub type vtable_res = @~[vtable_origin];
 
-enum vtable_origin {
+pub enum vtable_origin {
     /*
       Statically known vtable. def_id gives the class or impl item
       from whence comes the vtable, and tys are the type substs.
@@ -198,7 +205,7 @@ impl vtable_origin {
             vtable_trait(def_id, ref tys) => {
                 fmt!("vtable_trait(%?:%s, %?)",
                      def_id, ty::item_path_str(tcx, def_id),
-                     tys.map(|t| ty_to_str(tcx, *t)))
+                     tys.map(|t| ppaux::ty_to_str(tcx, *t)))
             }
         }
     }
@@ -220,7 +227,7 @@ enum crate_ctxt {
 
 // Functions that write types into the node type table
 fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, ty: ty::t) {
-    debug!("write_ty_to_tcx(%d, %s)", node_id, ty_to_str(tcx, ty));
+    debug!("write_ty_to_tcx(%d, %s)", node_id, ppaux::ty_to_str(tcx, ty));
     smallintmap::insert(*tcx.node_types, node_id as uint, ty);
 }
 fn write_substs_to_tcx(tcx: ty::ctxt,
@@ -228,7 +235,7 @@ fn write_substs_to_tcx(tcx: ty::ctxt,
                        +substs: ~[ty::t]) {
     if substs.len() > 0u {
         debug!("write_substs_to_tcx(%d, %?)", node_id,
-               substs.map(|t| ty_to_str(tcx, *t)));
+               substs.map(|t| ppaux::ty_to_str(tcx, *t)));
         tcx.node_type_substs.insert(node_id, substs);
     }
 }
@@ -356,13 +363,13 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
                     main_span,
                     fmt!("Wrong type in main function: found `%s`, \
                           expected `fn() -> ()`",
-                         ty_to_str(tcx, main_t)));
+                         ppaux::ty_to_str(tcx, main_t)));
             }
         }
         _ => {
             tcx.sess.span_bug(main_span,
                               ~"main has a non-function type: found `" +
-                              ty_to_str(tcx, main_t) + ~"`");
+                              ppaux::ty_to_str(tcx, main_t) + ~"`");
         }
     }
 }
diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs
index 5ae52252dc223..cbbb417eae6a5 100644
--- a/src/librustc/middle/typeck/rscope.rs
+++ b/src/librustc/middle/typeck/rscope.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use result::Result;
+use core::result::Result;
 use syntax::parse::token::special_idents;
 
 trait region_scope {
diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc
index 584f165b75daf..45aa78be02606 100644
--- a/src/librustc/rustc.rc
+++ b/src/librustc/rustc.rc
@@ -145,7 +145,7 @@ mod middle {
     #[path = "middle/lint.rs"]
     mod lint;
     #[path = "middle/borrowck/mod.rs"]
-    mod borrowck;
+    pub mod borrowck;
     #[legacy_exports]
     #[path = "middle/mem_categorization.rs"]
     mod mem_categorization;
diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs
index a11943fbf4bca..a0685c4b3ac99 100644
--- a/src/librustdoc/astsrv.rs
+++ b/src/librustdoc/astsrv.rs
@@ -17,19 +17,19 @@ query AST-related information, shielding the rest of Rustdoc from its
 non-sendableness.
 */
 
-use std::map::HashMap;
-use rustc::driver::session;
-use session::{basic_options, options};
-use session::Session;
+use rustc::back::link;
 use rustc::driver::driver;
-use syntax::diagnostic;
-use syntax::diagnostic::handler;
+use rustc::driver::session::Session;
+use rustc::driver::session::{basic_options, options};
+use rustc::driver::session;
+use rustc::front;
+use rustc::metadata::filesearch;
+use std::map::HashMap;
 use syntax::ast;
-use syntax::codemap;
 use syntax::ast_map;
-use rustc::back::link;
-use rustc::metadata::filesearch;
-use rustc::front;
+use syntax::codemap;
+use syntax::diagnostic::handler;
+use syntax::diagnostic;
 
 pub type Ctxt = {
     ast: @ast::crate,
diff --git a/src/librustdoc/parse.rs b/src/librustdoc/parse.rs
index 7351f2f7b30b9..db97f34f20168 100644
--- a/src/librustdoc/parse.rs
+++ b/src/librustdoc/parse.rs
@@ -10,12 +10,12 @@
 
 //! AST-parsing helpers
 
+use rustc::driver::driver::{file_input, str_input};
 use rustc::driver::driver;
-use driver::{file_input, str_input};
 use rustc::driver::session;
-use syntax::diagnostic;
 use syntax::ast;
 use syntax::codemap;
+use syntax::diagnostic;
 use syntax::parse;
 
 pub fn from_file(file: &Path) -> @ast::crate {
diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc
index 9393168905a4e..a2e1167eaa816 100644
--- a/src/librusti/rusti.rc
+++ b/src/librusti/rusti.rc
@@ -28,7 +28,7 @@ extern mod rustc(vers = "0.5");
 extern mod syntax(vers = "0.5");
 
 use core::*;
-use io::{ReaderUtil, WriterUtil};
+use core::io::{ReaderUtil, WriterUtil};
 use rustc::back;
 use rustc::driver::{driver, session};
 use rustc::front;
@@ -38,8 +38,8 @@ use rustc::middle::{freevars, kind, lint, trans, ty, typeck};
 use rustc::middle;
 use syntax::{ast, ast_util, codemap, diagnostic, fold, parse, print, visit};
 use syntax::ast_util::*;
-use parse::token;
-use print::{pp, pprust};
+use syntax::parse::token;
+use syntax::print::{pp, pprust};
 use std::rl;
 
 /**
diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs
index d41aa1227ce9c..8a3e6213325a7 100644
--- a/src/libstd/serialization.rs
+++ b/src/libstd/serialization.rs
@@ -582,4 +582,4 @@ pub impl<D: Deserializer> D: DeserializerHelpers {
 }
 }
 
-pub use traits::*;
+pub use serialization::traits::*;
diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs
index a53c03d6d2ce6..c9754ad99801c 100644
--- a/src/libstd/timer.rs
+++ b/src/libstd/timer.rs
@@ -12,9 +12,8 @@
 
 #[forbid(deprecated_mode)];
 
-use uv = uv;
 use uv::iotask;
-use iotask::IoTask;
+use uv::iotask::IoTask;
 use comm = core::comm;
 
 /**
diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs
index be503216edbbb..58b9a8d3d9445 100644
--- a/src/libstd/uv_global_loop.rs
+++ b/src/libstd/uv_global_loop.rs
@@ -15,10 +15,10 @@
 use ll = uv_ll;
 use iotask = uv_iotask;
 use get_gl = get;
-use iotask::{IoTask, spawn_iotask};
+use uv_iotask::{IoTask, spawn_iotask};
 use private::{chan_from_global_ptr, weaken_task};
 use comm = core::comm;
-use comm::{Port, Chan, select2, listen};
+use core::comm::{Port, Chan, select2, listen};
 use task::TaskBuilder;
 use either::{Left, Right};
 
diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs
index b718c84b65ed2..19f5997a57d73 100644
--- a/src/libstd/uv_iotask.rs
+++ b/src/libstd/uv_iotask.rs
@@ -19,7 +19,7 @@
 use libc::c_void;
 use ptr::addr_of;
 use comm = core::comm;
-use comm::{Port, Chan, listen};
+use core::comm::{Port, Chan, listen};
 use task::TaskBuilder;
 use ll = uv_ll;
 
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs
index 9830a5b1434fb..359414cff42bc 100644
--- a/src/libsyntax/ext/auto_serialize.rs
+++ b/src/libsyntax/ext/auto_serialize.rs
@@ -88,7 +88,7 @@ node twice.
 
 */
 
-use base::*;
+use ext::base::*;
 use codemap::span;
 use std::map;
 use std::map::HashMap;
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 04a59d1fe4162..0d40ede4dbcdb 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use codemap::span;
-use base::ext_ctxt;
+use ext::base::ext_ctxt;
 
 fn mk_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) ->
     @ast::expr {
diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs
index a47b64bea3af1..d84d79082a4f8 100644
--- a/src/libsyntax/ext/concat_idents.rs
+++ b/src/libsyntax/ext/concat_idents.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use base::*;
+use ext::base::*;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
     -> base::mac_result {
diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index 434c00e7487eb..f0eaf2115b896 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -18,7 +18,7 @@ use ast::{pat_ident, pat_wild, public, pure_fn, re_anon, stmt, struct_def};
 use ast::{struct_variant_kind, sty_by_ref, sty_region, tuple_variant_kind};
 use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_rptr, unnamed_field};
 use ast::{variant};
-use base::ext_ctxt;
+use ext::base::ext_ctxt;
 use codemap::span;
 use parse::token::special_idents::clownshoes_extensions;
 
diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs
index 68db1b41781e4..b5c55437d70b3 100644
--- a/src/libsyntax/ext/env.rs
+++ b/src/libsyntax/ext/env.rs
@@ -14,8 +14,8 @@
  * should all get sucked into either the compiler syntax extension plugin
  * interface.
  */
-use base::*;
-use build::mk_uniq_str;
+use ext::base::*;
+use ext::build::mk_uniq_str;
 export expand_syntax_ext;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs
index 46003624a76e5..2b5f95c4066da 100644
--- a/src/libsyntax/ext/fmt.rs
+++ b/src/libsyntax/ext/fmt.rs
@@ -16,7 +16,7 @@
  * compiler syntax extension plugin interface.
  */
 use extfmt::ct::*;
-use base::*;
+use ext::base::*;
 use codemap::span;
 use ext::build::*;
 export expand_syntax_ext;
diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs
index 00462207b4bdd..47096182fe848 100644
--- a/src/libsyntax/ext/log_syntax.rs
+++ b/src/libsyntax/ext/log_syntax.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use base::*;
+use ext::base::*;
 use io::WriterUtil;
 
 fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, tt: ~[ast::token_tree])
diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs
index 2a7b09795ced6..56f426e3853bf 100644
--- a/src/libsyntax/ext/pipes/ast_builder.rs
+++ b/src/libsyntax/ext/pipes/ast_builder.rs
@@ -17,7 +17,7 @@ use ast::{ident, node_id};
 use ast_util::{ident_to_path, respan, dummy_sp};
 use codemap::span;
 use ext::base::mk_ctxt;
-use quote::rt::*;
+use ext::quote::rt::*;
 
 // Transitional reexports so qquote can find the paths it is looking for
 mod syntax {
diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs
index cd76655fef66f..7193a00950e28 100644
--- a/src/libsyntax/ext/pipes/check.rs
+++ b/src/libsyntax/ext/pipes/check.rs
@@ -31,7 +31,7 @@ that.
 
 use ext::base::ext_ctxt;
 
-use proto::{state, protocol, next_state};
+use ext::pipes::proto::{state, protocol, next_state};
 
 impl ext_ctxt: proto::visitor<(), (), ()>  {
     fn visit_proto(_proto: protocol,
diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs
index 7085ca40ed39e..0a02bca88ca99 100644
--- a/src/libsyntax/ext/pipes/mod.rs
+++ b/src/libsyntax/ext/pipes/mod.rs
@@ -49,9 +49,8 @@ use ast::tt_delim;
 use parse::lexer::{new_tt_reader, reader};
 use parse::parser::Parser;
 
-use pipes::parse_proto::proto_parser;
-
-use pipes::proto::{visit, protocol};
+use ext::pipes::parse_proto::proto_parser;
+use ext::pipes::proto::{visit, protocol};
 
 #[legacy_exports]
 mod ast_builder;
diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs
index ffc063d2b77e4..0f6b9dbda2843 100644
--- a/src/libsyntax/ext/pipes/parse_proto.rs
+++ b/src/libsyntax/ext/pipes/parse_proto.rs
@@ -13,7 +13,7 @@
 use parse::parser;
 use parse::token;
 
-use pipec::*;
+use ext::pipes::pipec::*;
 
 trait proto_parser {
     fn parse_proto(id: ~str) -> protocol;
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 5ce3898b3e859..c07170e5c3640 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -19,16 +19,9 @@ use ast_util::dummy_sp;
 use util::interner;
 use ext::base::ext_ctxt;
 use parse::*;
-use proto::*;
-use quote::rt::*;
-use ast_builder::{append_types, path};
-
-// Transitional reexports so qquote can find the paths it is looking for
-mod syntax {
-    #[legacy_exports];
-    pub use ext;
-    pub use parse;
-}
+use ext::pipes::proto::*;
+use ext::quote::rt::*;
+use ext::pipes::ast_builder::{append_types, path};
 
 trait gen_send {
     fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item;
diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs
index af75c9e71dcf0..76757d027a5c8 100644
--- a/src/libsyntax/ext/pipes/proto.rs
+++ b/src/libsyntax/ext/pipes/proto.rs
@@ -11,7 +11,7 @@
 use to_str::ToStr;
 use dvec::DVec;
 
-use ast_builder::{path, append_types};
+use ext::pipes::ast_builder::{path, append_types};
 
 enum direction { send, recv }
 
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index 1e5d4ea8d16f8..c498c3407c28a 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -13,7 +13,7 @@ use mod parse::token;
 
 use codemap::{span, BytePos};
 use ext::base::ext_ctxt;
-use token::*;
+use parse::token::*;
 
 /**
 *
@@ -34,7 +34,7 @@ pub mod rt {
     pub use codemap::span;
 
     use print::pprust;
-    use pprust::{item_to_str, ty_to_str};
+    use print::pprust::{item_to_str, ty_to_str};
 
     trait ToTokens {
         pub fn to_tokens(_cx: ext_ctxt) -> ~[token_tree];
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index 8d2b9163f152f..099764a3278b4 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use base::*;
+use ext::base::*;
 use codemap::{span, Loc, FileMap};
 use print::pprust;
-use build::{mk_base_vec_e,mk_uint,mk_u8,mk_uniq_str};
+use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_uniq_str};
 
 export expand_line;
 export expand_col;
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index f33c8b802040c..e93f3d6e38b24 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -8,15 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use base::{ext_ctxt, mac_result, mr_any, mr_def, normal_tt};
+use ext::base::{ext_ctxt, mac_result, mr_any, mr_def, normal_tt};
 use codemap::span;
 use ast::{ident, matcher_, matcher, match_tok,
              match_nonterminal, match_seq, tt_delim};
 use parse::lexer::{new_tt_reader, reader};
 use parse::token::{FAT_ARROW, SEMI, LBRACE, RBRACE, nt_matchers, nt_tt};
 use parse::parser::Parser;
-use macro_parser::{parse, parse_or_else, success, failure, named_match,
-                      matched_seq, matched_nonterminal, error};
+use ext::tt::macro_parser::{parse, parse_or_else, success, failure,
+                            named_match, matched_seq, matched_nonterminal,
+                            error};
 use std::map::HashMap;
 use parse::token::special_idents;
 use ast_util::dummy_sp;
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index 19b5975c14725..a68482ea46b36 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -10,7 +10,7 @@
 
 use diagnostic::span_handler;
 use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,ident};
-use macro_parser::{named_match, matched_seq, matched_nonterminal};
+use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
 use codemap::span;
 use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident, ident_interner};
 use std::map::HashMap;
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index 7248a0e224476..a4bef47fdf290 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -10,7 +10,7 @@
 
 use either::{Either, Left, Right};
 use ast_util::spanned;
-use common::*; //resolve bug?
+use parse::common::*; //resolve bug?
 
 export parser_attr;
 
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index e5a5262862790..22b40736748b5 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -8,11 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use io::println;//XXXXXXXXxxx
 use io::ReaderUtil;
 use util::interner;
-use lexer::{string_reader, bump, is_eof, nextch,
-               is_whitespace, get_str_from, reader};
+use parse::lexer::{string_reader, bump, is_eof, nextch,
+                   is_whitespace, get_str_from, reader};
 use codemap::{FileMap, CharPos};
 
 export cmnt;
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index a48e33c94059c..246a8fa9c7c55 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -10,8 +10,8 @@
 
 use std::map::{HashMap};
 use ast_util::spanned;
-use parser::Parser;
-use lexer::reader;
+use parse::parser::Parser;
+use parse::lexer::reader;
 
 type seq_sep = {
     sep: Option<token::Token>,
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 5a7b62f1ff6ce..803135f7599e2 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -20,6 +20,7 @@ export comments;
 export prec;
 export classify;
 export attr;
+export obsolete;
 
 export parse_sess;
 export new_parse_sess, new_parse_sess_special_handler;
@@ -35,14 +36,14 @@ export parse_stmt_from_source_str;
 export parse_tts_from_source_str;
 export parse_from_source_str;
 
-use parser::Parser;
-use attr::parser_attr;
 use ast::node_id;
-use util::interner;
+use codemap::{span, CodeMap, FileMap, CharPos, BytePos};
 use diagnostic::{span_handler, mk_span_handler, mk_handler, emitter};
-use lexer::{reader, string_reader};
+use parse::attr::parser_attr;
+use parse::lexer::{reader, string_reader};
+use parse::parser::Parser;
 use parse::token::{ident_interner, mk_ident_interner};
-use codemap::{span, CodeMap, FileMap, CharPos, BytePos};
+use util::interner;
 
 
 #[legacy_exports]
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index aa52575ef45b4..3db635f3b431d 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -20,7 +20,7 @@ removed.
 use codemap::span;
 use ast::{expr, expr_lit, lit_nil};
 use ast_util::{respan};
-use token::Token;
+use parse::token::Token;
 
 /// The specific types of unsupported syntax
 pub enum ObsoleteSyntax {
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 0f1c346762521..47f65ed2f8d37 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -13,19 +13,19 @@ use print::pprust::expr_to_str;
 use result::Result;
 use either::{Either, Left, Right};
 use std::map::HashMap;
-use token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident,
-            INTERPOLATED, special_idents};
+use parse::token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident,
+                   INTERPOLATED, special_idents};
 use codemap::{span,FssNone, BytePos};
 use util::interner::Interner;
 use ast_util::{spanned, respan, mk_sp, ident_to_path, operator_prec};
-use lexer::reader;
-use prec::{as_prec, token_to_binop};
-use attr::parser_attr;
-use common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed,
-                seq_sep_none, token_to_str};
+use parse::lexer::reader;
+use parse::prec::{as_prec, token_to_binop};
+use parse::attr::parser_attr;
+use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed,
+                    seq_sep_none, token_to_str};
 use dvec::DVec;
 use vec::{push};
-use obsolete::{
+use parse::obsolete::{
     ObsoleteSyntax,
     ObsoleteLowerCaseKindBounds, ObsoleteLet,
     ObsoleteFieldTerminator, ObsoleteStructCtor,
diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs
index 8dada97e35ddb..4663b875bb5d7 100644
--- a/src/libsyntax/parse/prec.rs
+++ b/src/libsyntax/parse/prec.rs
@@ -12,8 +12,8 @@ export as_prec;
 export unop_prec;
 export token_to_binop;
 
-use token::*;
-use token::Token;
+use parse::token::*;
+use parse::token::Token;
 use ast::*;
 
 /// Unary operators have higher precedence than binary
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index fa384341fb973..e977327e919b4 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -10,8 +10,8 @@
 
 use parse::{comments, lexer, token};
 use codemap::{CodeMap, BytePos};
-use pp::{break_offset, word, printer, space, zerobreak, hardbreak, breaks};
-use pp::{consistent, inconsistent, eof};
+use print::pp::{break_offset, word, printer, space, zerobreak, hardbreak};
+use print::pp::{breaks, consistent, inconsistent, eof};
 use ast::{required, provided};
 use ast_util::{operator_prec};
 use dvec::DVec;
diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc
index fbc5f10fcd6f9..119e1e25fb7c1 100644
--- a/src/libsyntax/syntax.rc
+++ b/src/libsyntax/syntax.rc
@@ -31,6 +31,11 @@ extern mod std(vers = "0.5");
 
 use core::*;
 
+pub mod syntax {
+    pub use ext;
+    pub use parse;
+}
+
 #[legacy_exports]
 mod attr;
 #[legacy_exports]
diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs
index 8c885f1b79748..5e7424cf41e64 100644
--- a/src/test/auxiliary/cci_capture_clause.rs
+++ b/src/test/auxiliary/cci_capture_clause.rs
@@ -12,7 +12,7 @@
 
 export foo;
 
-use comm::*;
+use core::comm::*;
 
 fn foo<T: Send Copy>(x: T) -> Port<T> {
     let p = Port();
diff --git a/src/test/auxiliary/pub_use_mods_xcrate.rs b/src/test/auxiliary/pub_use_mods_xcrate.rs
index efd42fb588c71..162f7de4b1b43 100644
--- a/src/test/auxiliary/pub_use_mods_xcrate.rs
+++ b/src/test/auxiliary/pub_use_mods_xcrate.rs
@@ -16,6 +16,6 @@ pub mod a {
         }
     }
 
-    pub use b::c;
+    pub use a::b::c;
 }
 
diff --git a/src/test/compile-fail/super-at-top-level.rs b/src/test/compile-fail/super-at-top-level.rs
new file mode 100644
index 0000000000000..21b9e5292b19e
--- /dev/null
+++ b/src/test/compile-fail/super-at-top-level.rs
@@ -0,0 +1,7 @@
+use super::f;   //~ ERROR unresolved name
+//~^ ERROR failed to resolve import
+
+fn main() {
+    
+}
+
diff --git a/src/test/run-pass/alias-uninit-value.rs b/src/test/run-pass/alias-uninit-value.rs
index 7dbaee44135e2..beb1a5fc6c237 100644
--- a/src/test/run-pass/alias-uninit-value.rs
+++ b/src/test/run-pass/alias-uninit-value.rs
@@ -11,8 +11,6 @@
 
 
 // Regression test for issue #374
-extern mod std;
-use option::None;
 
 enum sty { ty_nil, }
 
diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs
index edc5c6bb9779e..c90bec114ed26 100644
--- a/src/test/run-pass/alt-pattern-drop.rs
+++ b/src/test/run-pass/alt-pattern-drop.rs
@@ -11,12 +11,10 @@
 
 
 // -*- rust -*-
-use core::sys;
-
 enum t { make_t(@int), clam, }
 
 fn foo(s: @int) {
-    let count = sys::refcount(s);
+    let count = core::sys::refcount(s);
     let x: t = make_t(s); // ref up
 
     match x {
@@ -26,20 +24,20 @@ fn foo(s: @int) {
       }
       _ => { debug!("?"); fail; }
     }
-    log(debug, sys::refcount(s));
-    assert (sys::refcount(s) == count + 1u);
-    let _ = sys::refcount(s); // don't get bitten by last-use.
+    log(debug, core::sys::refcount(s));
+    assert (core::sys::refcount(s) == count + 1u);
+    let _ = core::sys::refcount(s); // don't get bitten by last-use.
 }
 
 fn main() {
     let s: @int = @0; // ref up
 
-    let count = sys::refcount(s);
+    let count = core::sys::refcount(s);
 
     foo(s); // ref up then down
 
-    log(debug, sys::refcount(s));
-    let count2 = sys::refcount(s);
-    let _ = sys::refcount(s); // don't get bitten by last-use.
+    log(debug, core::sys::refcount(s));
+    let count2 = core::sys::refcount(s);
+    let _ = core::sys::refcount(s); // don't get bitten by last-use.
     assert count == count2;
 }
diff --git a/src/test/run-pass/auto-ref-bounded-ty-param.rs b/src/test/run-pass/auto-ref-bounded-ty-param.rs
index 943896943fe46..bd0e91f153e22 100644
--- a/src/test/run-pass/auto-ref-bounded-ty-param.rs
+++ b/src/test/run-pass/auto-ref-bounded-ty-param.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use to_str::ToStr;
-
 trait Foo {
     fn f(&self);
 }
@@ -37,4 +35,4 @@ impl Bar : Baz {
 fn main() {
     let y = Bar { x: 42 };
     y.f();
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto_serialize.rs
index fd9b30935cc9e..5472903f32b30 100644
--- a/src/test/run-pass/auto_serialize.rs
+++ b/src/test/run-pass/auto_serialize.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/basic-1.rs b/src/test/run-pass/basic-1.rs
index 31ca6b7e1d130..834040e0e57f9 100644
--- a/src/test/run-pass/basic-1.rs
+++ b/src/test/run-pass/basic-1.rs
@@ -10,31 +10,25 @@
 // except according to those terms.
 
 
-extern mod std;
-use comm::Chan;
-use comm::Port;
-use comm::send;
-use comm::recv;
-
-fn a(c: Chan<int>) { send(c, 10); }
+fn a(c: core::comm::Chan<int>) { core::comm::send(c, 10); }
 
 fn main() {
-    let p = Port();
-    let ch = Chan(&p);
+    let p = core::comm::Port();
+    let ch = core::comm::Chan(&p);
     task::spawn(|| a(ch) );
     task::spawn(|| a(ch) );
     let mut n: int = 0;
-    n = recv(p);
-    n = recv(p);
+    n = core::comm::recv(p);
+    n = core::comm::recv(p);
     //    debug!("Finished.");
 }
 
-fn b(c: Chan<int>) {
+fn b(c: core::comm::Chan<int>) {
     //    debug!("task b0");
     //    debug!("task b1");
     //    debug!("task b2");
     //    debug!("task b3");
     //    debug!("task b4");
     //    debug!("task b5");
-    send(c, 10);
+    core::comm::send(c, 10);
 }
diff --git a/src/test/run-pass/basic-2.rs b/src/test/run-pass/basic-2.rs
index 6d2e096b8dab3..df8eb39da3043 100644
--- a/src/test/run-pass/basic-2.rs
+++ b/src/test/run-pass/basic-2.rs
@@ -10,30 +10,28 @@
 // except according to those terms.
 
 
-extern mod std;
-use comm::Port;
-use comm::send;
-use comm::Chan;
-use comm::recv;
-
-fn a(c: Chan<int>) { debug!("task a0"); debug!("task a1"); send(c, 10); }
+fn a(c: core::comm::Chan<int>) {
+    debug!("task a0");
+    debug!("task a1");
+    core::comm::send(c, 10);
+}
 
 fn main() {
-    let p = Port();
-    let ch = Chan(&p);
+    let p = core::comm::Port();
+    let ch = core::comm::Chan(&p);
     task::spawn(|| a(ch) );
     task::spawn(|| b(ch) );
     let mut n: int = 0;
-    n = recv(p);
-    n = recv(p);
+    n = core::comm::recv(p);
+    n = core::comm::recv(p);
     debug!("Finished.");
 }
 
-fn b(c: Chan<int>) {
+fn b(c: core::comm::Chan<int>) {
     debug!("task b0");
     debug!("task b1");
     debug!("task b2");
     debug!("task b2");
     debug!("task b3");
-    send(c, 10);
+    core::comm::send(c, 10);
 }
diff --git a/src/test/run-pass/basic.rs b/src/test/run-pass/basic.rs
index d58791f4bf118..bc7b194d7b4e3 100644
--- a/src/test/run-pass/basic.rs
+++ b/src/test/run-pass/basic.rs
@@ -10,12 +10,7 @@
 // except according to those terms.
 
 
-extern mod std;
-use comm::send;
-use comm::Chan;
-use comm::recv;
-
-fn a(c: Chan<int>) {
+fn a(c: core::comm::Chan<int>) {
     if true {
         debug!("task a");
         debug!("task a");
@@ -23,7 +18,7 @@ fn a(c: Chan<int>) {
         debug!("task a");
         debug!("task a");
     }
-    send(c, 10);
+    core::comm::send(c, 10);
 }
 
 fn k(x: int) -> int { return 15; }
@@ -39,18 +34,18 @@ fn main() {
     let mut n: int = 2 + 3 * 7;
     let s: ~str = ~"hello there";
     let p = comm::Port();
-    let ch = comm::Chan(&p);
+    let ch = core::comm::Chan(&p);
     task::spawn(|| a(ch) );
     task::spawn(|| b(ch) );
     let mut x: int = 10;
     x = g(n, s);
     log(debug, x);
-    n = recv(p);
-    n = recv(p);
+    n = core::comm::recv(p);
+    n = core::comm::recv(p);
     debug!("children finished, root finishing");
 }
 
-fn b(c: Chan<int>) {
+fn b(c: core::comm::Chan<int>) {
     if true {
         debug!("task b");
         debug!("task b");
@@ -59,5 +54,5 @@ fn b(c: Chan<int>) {
         debug!("task b");
         debug!("task b");
     }
-    send(c, 10);
+    core::comm::send(c, 10);
 }
diff --git a/src/test/run-pass/bind-by-move.rs b/src/test/run-pass/bind-by-move.rs
index 768551dddfcc3..9c2a16e3e37e6 100644
--- a/src/test/run-pass/bind-by-move.rs
+++ b/src/test/run-pass/bind-by-move.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // xfail-test
+// xfail-fast
 extern mod std;
 use std::arc;
 fn dispose(+_x: arc::ARC<bool>) unsafe { }
diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs
index a1cd6c0544eb5..72299e2b329c1 100644
--- a/src/test/run-pass/binops.rs
+++ b/src/test/run-pass/binops.rs
@@ -10,9 +10,6 @@
 
 // Binop corner cases
 
-extern mod std;
-use cast::reinterpret_cast;
-
 fn test_nil() {
     assert (() == ());
     assert (!(() != ()));
@@ -66,9 +63,9 @@ fn test_box() {
 }
 
 fn test_ptr() unsafe {
-    let p1: *u8 = cast::reinterpret_cast(&0);
-    let p2: *u8 = cast::reinterpret_cast(&0);
-    let p3: *u8 = cast::reinterpret_cast(&1);
+    let p1: *u8 = core::cast::reinterpret_cast(&0);
+    let p2: *u8 = core::cast::reinterpret_cast(&0);
+    let p3: *u8 = core::cast::reinterpret_cast(&1);
 
     assert p1 == p2;
     assert p1 != p3;
@@ -113,8 +110,8 @@ fn test_class() {
   
   unsafe {
   error!("q = %x, r = %x",
-         (cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
-         (cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
+         (core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
+         (core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
   }
   assert(q == r);
   r.y = 17;
diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs
index 0017d760402ee..ff0de7a469660 100644
--- a/src/test/run-pass/bitv-perf-test.rs
+++ b/src/test/run-pass/bitv-perf-test.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs
index ef82884e690a9..93ab2ba2c4134 100644
--- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs
+++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ptr::to_uint;
-
 fn borrow(x: &int, f: fn(x: &int)) {
     f(x)
 }
@@ -18,11 +16,11 @@ fn test1(x: @~int) {
     // Right now, at least, this induces a copy of the unique pointer:
     do borrow({*x}) |p| {
         let x_a = ptr::addr_of(&(**x));
-        assert (x_a as uint) != to_uint(p);
+        assert (x_a as uint) != ptr::to_uint(p);
         assert unsafe{*x_a} == *p;
     }
 }
 
 fn main() {
     test1(@~22);
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/call-closure-from-overloaded-op.rs b/src/test/run-pass/call-closure-from-overloaded-op.rs
index 7bd1787260290..3eaf273a5785e 100644
--- a/src/test/run-pass/call-closure-from-overloaded-op.rs
+++ b/src/test/run-pass/call-closure-from-overloaded-op.rs
@@ -8,12 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use dvec::DVec;
-
 fn foo() -> int { 22 }
 
 fn main() {
-    let x = DVec::<@fn() -> int>();
+    let x = dvec::DVec::<@fn() -> int>();
     x.push(foo);
     assert (x[0])() == 22;
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/capture_nil.rs b/src/test/run-pass/capture_nil.rs
index 565c04309021e..c82fc0bcd6860 100644
--- a/src/test/run-pass/capture_nil.rs
+++ b/src/test/run-pass/capture_nil.rs
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 // compile-flags:-Z no-opt
-use comm::*;
 
 // This test has to be setup just so to trigger
 // the condition which was causing us a crash.
@@ -25,9 +24,9 @@ use comm::*;
 // course preferable, as the value itself is
 // irrelevant).
 
-fn foo(&&x: ()) -> Port<()> {
-    let p = Port();
-    let c = Chan(&p);
+fn foo(&&x: ()) -> core::comm::Port<()> {
+    let p = core::comm::Port();
+    let c = core::comm::Chan(&p);
     do task::spawn() |copy c, copy x| {
         c.send(x);
     }
diff --git a/src/test/run-pass/chan-leak.rs b/src/test/run-pass/chan-leak.rs
index c0cdc8ebfe044..b88799c4475d3 100644
--- a/src/test/run-pass/chan-leak.rs
+++ b/src/test/run-pass/chan-leak.rs
@@ -10,38 +10,32 @@
 
 // Issue #763
 
-extern mod std;
-use comm::Chan;
-use comm::send;
-use comm::Port;
-use comm::recv;
+enum request { quit, close(core::comm::Chan<bool>), }
 
-enum request { quit, close(Chan<bool>), }
+type ctx = core::comm::Chan<request>;
 
-type ctx = Chan<request>;
-
-fn request_task(c: Chan<ctx>) {
-    let p = Port();
-    send(c, Chan(&p));
+fn request_task(c: core::comm::Chan<ctx>) {
+    let p = core::comm::Port();
+    core::comm::send(c, core::comm::Chan(&p));
     let mut req: request;
-    req = recv(p);
+    req = core::comm::recv(p);
     // Need to drop req before receiving it again
-    req = recv(p);
+    req = core::comm::recv(p);
 }
 
 fn new_cx() -> ctx {
-    let p = Port();
-    let ch = Chan(&p);
+    let p = core::comm::Port();
+    let ch = core::comm::Chan(&p);
     let t = task::spawn(|| request_task(ch) );
     let mut cx: ctx;
-    cx = recv(p);
+    cx = core::comm::recv(p);
     return cx;
 }
 
 fn main() {
     let cx = new_cx();
 
-    let p = Port::<bool>();
-    send(cx, close(Chan(&p)));
-    send(cx, quit);
+    let p = core::comm::Port::<bool>();
+    core::comm::send(cx, close(core::comm::Chan(&p)));
+    core::comm::send(cx, quit);
 }
diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs
index 72e10bd22f2c9..b3e85c518956e 100644
--- a/src/test/run-pass/class-exports.rs
+++ b/src/test/run-pass/class-exports.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs
index 7b0cf49ee22ba..cae462c4d5d93 100644
--- a/src/test/run-pass/comm.rs
+++ b/src/test/run-pass/comm.rs
@@ -10,23 +10,18 @@
 // except according to those terms.
 
 
-extern mod std;
-use comm::Chan;
-use comm::send;
-use comm::recv;
-
 fn main() {
     let p = comm::Port();
-    let ch = comm::Chan(&p);
+    let ch = core::comm::Chan(&p);
     let t = task::spawn(|| child(ch) );
-    let y = recv(p);
+    let y = core::comm::recv(p);
     error!("received");
     log(error, y);
     assert (y == 10);
 }
 
-fn child(c: Chan<int>) {
+fn child(c: core::comm::Chan<int>) {
     error!("sending");
-    send(c, 10);
+    core::comm::send(c, 10);
     error!("value sent");
 }
diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs
index c41644585ef23..5ddea60558704 100644
--- a/src/test/run-pass/conditional-compile.rs
+++ b/src/test/run-pass/conditional-compile.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/core-export-f64-sqrt.rs b/src/test/run-pass/core-export-f64-sqrt.rs
index 9200610c4cf90..a78ca37172b28 100644
--- a/src/test/run-pass/core-export-f64-sqrt.rs
+++ b/src/test/run-pass/core-export-f64-sqrt.rs
@@ -10,11 +10,9 @@
 
 // Regression test that f64 exports things properly
 
-use io::println;
-
 fn main() {
 
     let digits: uint = 10 as uint;
 
-    println(float::to_str(f64::sqrt(42.0f64) as float, digits));
-}
\ No newline at end of file
+    core::io::println(float::to_str(f64::sqrt(42.0f64) as float, digits));
+}
diff --git a/src/test/run-pass/decl-with-recv.rs b/src/test/run-pass/decl-with-recv.rs
index cd745241450c8..4d1ad84225d4e 100644
--- a/src/test/run-pass/decl-with-recv.rs
+++ b/src/test/run-pass/decl-with-recv.rs
@@ -10,19 +10,13 @@
 // except according to those terms.
 
 
-extern mod std;
-use comm::Port;
-use comm::Chan;
-use comm::send;
-use comm::recv;
-
 fn main() {
-    let po = Port();
-    let ch = Chan(&po);
-    send(ch, 10);
-    let i = recv(po);
+    let po = core::comm::Port();
+    let ch = core::comm::Chan(&po);
+    core::comm::send(ch, 10);
+    let i = core::comm::recv(po);
     assert (i == 10);
-    send(ch, 11);
-    let j = recv(po);
+    core::comm::send(ch, 11);
+    let j = core::comm::recv(po);
     assert (j == 11);
 }
diff --git a/src/test/run-pass/dvec-test.rs b/src/test/run-pass/dvec-test.rs
index c3c54312bfce8..f569e9116e39a 100644
--- a/src/test/run-pass/dvec-test.rs
+++ b/src/test/run-pass/dvec-test.rs
@@ -8,10 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use dvec::DVec;
-
 fn main() {
-    let d = DVec();
+    let d = dvec::DVec();
     d.push(3);
     d.push(4);
     assert d.get() == ~[3, 4];
diff --git a/src/test/run-pass/export-glob-imports-target.rs b/src/test/run-pass/export-glob-imports-target.rs
index 5c7c6636f674a..5f547e09c8951 100644
--- a/src/test/run-pass/export-glob-imports-target.rs
+++ b/src/test/run-pass/export-glob-imports-target.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -15,7 +17,7 @@
 
 mod foo {
     #[legacy_exports];
-    use bar::*;
+    use foo::bar::*;
     mod bar {
         #[legacy_exports];
         const a : int = 10;
diff --git a/src/test/run-pass/export-glob.rs b/src/test/run-pass/export-glob.rs
index 3d647072b5c6b..4c0287843fc05 100644
--- a/src/test/run-pass/export-glob.rs
+++ b/src/test/run-pass/export-glob.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -15,8 +17,9 @@
 
 mod foo {
     #[legacy_exports];
-    use bar::*;
+    use foo::bar::*;
     export a;
+    export bar;
     mod bar {
         #[legacy_exports];
         const a : int = 10;
diff --git a/src/test/run-pass/export-multi.rs b/src/test/run-pass/export-multi.rs
index bd2d6d2fcab23..c9d7fe4d6b9df 100644
--- a/src/test/run-pass/export-multi.rs
+++ b/src/test/run-pass/export-multi.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass/extern-mod-syntax.rs
index 2abc0881370c7..badff7bdfd69a 100644
--- a/src/test/run-pass/extern-mod-syntax.rs
+++ b/src/test/run-pass/extern-mod-syntax.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs
index 8e59058f818ba..166625ce1a819 100644
--- a/src/test/run-pass/getopts_ref.rs
+++ b/src/test/run-pass/getopts_ref.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/guards-not-exhaustive.rs b/src/test/run-pass/guards-not-exhaustive.rs
index ab1aca4d76153..66e48d1e7a95c 100644
--- a/src/test/run-pass/guards-not-exhaustive.rs
+++ b/src/test/run-pass/guards-not-exhaustive.rs
@@ -1,5 +1,3 @@
-use option::*;
-
 enum Q { R(Option<uint>) }
 
 fn xyzzy(q: Q) -> uint {
@@ -12,4 +10,4 @@ fn xyzzy(q: Q) -> uint {
 
 fn main() {
     assert xyzzy(R(Some(5))) == 0;
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs
index fb4a474f0c088..9a3b67e42dc77 100644
--- a/src/test/run-pass/hashmap-memory.rs
+++ b/src/test/run-pass/hashmap-memory.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -16,8 +18,6 @@
 
 extern mod std;
 
-use option::Some;
-use option::None;
 use std::map;
 use std::map::HashMap;
 use comm::Chan;
diff --git a/src/test/run-pass/import-from-foreign.rs b/src/test/run-pass/import-from-foreign.rs
index 83c7d3d6f59d1..9106f4a5e750f 100644
--- a/src/test/run-pass/import-from-foreign.rs
+++ b/src/test/run-pass/import-from-foreign.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import-from.rs b/src/test/run-pass/import-from.rs
index e334e4bed50a0..390ccf35e376b 100644
--- a/src/test/run-pass/import-from.rs
+++ b/src/test/run-pass/import-from.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import-glob-0.rs b/src/test/run-pass/import-glob-0.rs
index cf4234358e865..5297ee61d2020 100644
--- a/src/test/run-pass/import-glob-0.rs
+++ b/src/test/run-pass/import-glob-0.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import-glob-1.rs b/src/test/run-pass/import-glob-1.rs
index 612078ecf783f..32770f39c0ec5 100644
--- a/src/test/run-pass/import-glob-1.rs
+++ b/src/test/run-pass/import-glob-1.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs
index bd73da0ee52d2..0d3d08b3a39ac 100644
--- a/src/test/run-pass/import-glob-crate.rs
+++ b/src/test/run-pass/import-glob-crate.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import-in-block.rs b/src/test/run-pass/import-in-block.rs
index 5283c7e84994b..58b45f3d5f81d 100644
--- a/src/test/run-pass/import-in-block.rs
+++ b/src/test/run-pass/import-in-block.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-
 fn main() {
     use vec::to_mut;
     log(debug, vec::len(to_mut(~[1, 2])));
diff --git a/src/test/run-pass/import-trailing-comma.rs b/src/test/run-pass/import-trailing-comma.rs
index 9babd89055de9..4a1ad3c510057 100644
--- a/src/test/run-pass/import-trailing-comma.rs
+++ b/src/test/run-pass/import-trailing-comma.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import.rs b/src/test/run-pass/import.rs
index 0e6e986cba76c..a3fdefaeba603 100644
--- a/src/test/run-pass/import.rs
+++ b/src/test/run-pass/import.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import2.rs b/src/test/run-pass/import2.rs
index f8337beb687fc..34f67340a28f3 100644
--- a/src/test/run-pass/import2.rs
+++ b/src/test/run-pass/import2.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import3.rs b/src/test/run-pass/import3.rs
index cbea124c5a092..b3545d9ec8c87 100644
--- a/src/test/run-pass/import3.rs
+++ b/src/test/run-pass/import3.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import4.rs b/src/test/run-pass/import4.rs
index 90ef72c14e284..9941648c4f03d 100644
--- a/src/test/run-pass/import4.rs
+++ b/src/test/run-pass/import4.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import5.rs b/src/test/run-pass/import5.rs
index 0e3eae3a6cb96..554aa4154b30b 100644
--- a/src/test/run-pass/import5.rs
+++ b/src/test/run-pass/import5.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -11,8 +13,9 @@
 use foo::bar;
 mod foo {
     #[legacy_exports];
-    use zed::bar;
+    use foo::zed::bar;
     export bar;
+    export zed;
     mod zed {
         #[legacy_exports];
         fn bar() { debug!("foo"); }
diff --git a/src/test/run-pass/import6.rs b/src/test/run-pass/import6.rs
index 8fa362e596a9a..5ffbc0895bd23 100644
--- a/src/test/run-pass/import6.rs
+++ b/src/test/run-pass/import6.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import7.rs b/src/test/run-pass/import7.rs
index 917e8108daaab..579a1e093ceea 100644
--- a/src/test/run-pass/import7.rs
+++ b/src/test/run-pass/import7.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/import8.rs b/src/test/run-pass/import8.rs
index b4ca26138a0fd..d05e88a2b8d6a 100644
--- a/src/test/run-pass/import8.rs
+++ b/src/test/run-pass/import8.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs
index 352cd089cdcbb..19ce8e8d224fa 100644
--- a/src/test/run-pass/intrinsics-math.rs
+++ b/src/test/run-pass/intrinsics-math.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-1112.rs b/src/test/run-pass/issue-1112.rs
index f0eb3fc24052d..8eca57eacbf72 100644
--- a/src/test/run-pass/issue-1112.rs
+++ b/src/test/run-pass/issue-1112.rs
@@ -11,9 +11,6 @@
 // Issue #1112
 // Alignment of interior pointers to dynamic-size types
 
-extern mod std;
-use ptr::addr_of;
-
 type x<T> = {
     a: T,
     b: u8,
@@ -44,4 +41,4 @@ fn bar<T>(x: x<T>) {
     assert x.e == 11u16;
     assert x.f == 12u8;
     assert x.g == 13u8;
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/issue-1696.rs b/src/test/run-pass/issue-1696.rs
index ef757f6394ac9..72ce678cd2384 100644
--- a/src/test/run-pass/issue-1696.rs
+++ b/src/test/run-pass/issue-1696.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs
index 0c61695755732..05c2595931eb1 100644
--- a/src/test/run-pass/issue-2214.rs
+++ b/src/test/run-pass/issue-2214.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -36,4 +38,4 @@ fn main() {
   let mut y: int = 5;
   let x: &mut int = &mut y;
   assert (lgamma(1.0 as c_double, x) == 0.0 as c_double);
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/issue-2383.rs b/src/test/run-pass/issue-2383.rs
index 49661a31cdbc6..eb7506aa3d28e 100644
--- a/src/test/run-pass/issue-2383.rs
+++ b/src/test/run-pass/issue-2383.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-2445.rs b/src/test/run-pass/issue-2445.rs
index 1cc9783dd5b2c..7cf681c9f94ef 100644
--- a/src/test/run-pass/issue-2445.rs
+++ b/src/test/run-pass/issue-2445.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use dvec::DVec;
-
 struct c1<T: Copy> {
     x: T,
 }
diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs
index 690cc6a4ab767..a8412aacee981 100644
--- a/src/test/run-pass/issue-2718.rs
+++ b/src/test/run-pass/issue-2718.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs
index 750bdbd570f87..c79b59f7cd99d 100644
--- a/src/test/run-pass/issue-2804-2.rs
+++ b/src/test/run-pass/issue-2804-2.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs
index ba3bd2869f2be..cb81dad98faa5 100644
--- a/src/test/run-pass/issue-2804.rs
+++ b/src/test/run-pass/issue-2804.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs
index 0a7c7ddce2dc8..a21cad8fd3939 100644
--- a/src/test/run-pass/issue-2895.rs
+++ b/src/test/run-pass/issue-2895.rs
@@ -8,9 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use sys::size_of;
-extern mod std;
-
 struct Cat {
     x: int
 }
@@ -25,12 +22,12 @@ impl Kitty : Drop {
 
 #[cfg(target_arch = "x86_64")]
 fn main() {
-    assert (size_of::<Cat>() == 8 as uint);
-    assert (size_of::<Kitty>() == 16 as uint);
+    assert (sys::size_of::<Cat>() == 8 as uint);
+    assert (sys::size_of::<Kitty>() == 16 as uint);
 }
 
 #[cfg(target_arch = "x86")]
 fn main() {
-    assert (size_of::<Cat>() == 4 as uint);
-    assert (size_of::<Kitty>() == 8 as uint);
+    assert (sys::size_of::<Cat>() == 4 as uint);
+    assert (sys::size_of::<Kitty>() == 8 as uint);
 }
diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs
index c228c8199f208..506f9dfa64ee2 100644
--- a/src/test/run-pass/issue-2904.rs
+++ b/src/test/run-pass/issue-2904.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs
index a0a7fd5f3ff2b..04932676f3d63 100644
--- a/src/test/run-pass/issue-3026.rs
+++ b/src/test/run-pass/issue-3026.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs
index 012a827c2394a..74f67ff92809a 100644
--- a/src/test/run-pass/issue-3052.rs
+++ b/src/test/run-pass/issue-3052.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use option::*;
-
 type Connection = fn@(~[u8]);
 
 fn f() -> Option<Connection> {
diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs
index e24384fcc12fe..6064713b29527 100644
--- a/src/test/run-pass/issue-3424.rs
+++ b/src/test/run-pass/issue-3424.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs
index 3464f3a363f27..ee68a546cafed 100644
--- a/src/test/run-pass/issue-3559.rs
+++ b/src/test/run-pass/issue-3559.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/issue-3702.rs b/src/test/run-pass/issue-3702.rs
index 942114eef6c8d..9045e3aecda3c 100644
--- a/src/test/run-pass/issue-3702.rs
+++ b/src/test/run-pass/issue-3702.rs
@@ -8,15 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use io::println;
-
 fn main() {
   trait Text {
     fn to_str(&self) -> ~str;
   }
 
   fn to_string(t: Text) {
-    println(t.to_str());
+    io::println(t.to_str());
   }
 
 }
diff --git a/src/test/run-pass/issue-507.rs b/src/test/run-pass/issue-507.rs
index 92c8e6494da99..5d267f9d91447 100644
--- a/src/test/run-pass/issue-507.rs
+++ b/src/test/run-pass/issue-507.rs
@@ -15,26 +15,19 @@
    https://github.com/graydon/rust/issues/507
 */
 
-extern mod std;
+fn grandchild(c: core::comm::Chan<int>) { core::comm::send(c, 42); }
 
-use comm::Chan;
-use comm::send;
-use comm::Port;
-use comm::recv;
-
-fn grandchild(c: Chan<int>) { send(c, 42); }
-
-fn child(c: Chan<int>) {
+fn child(c: core::comm::Chan<int>) {
     task::spawn(|| grandchild(c) )
 }
 
 fn main() {
-    let p = comm::Port();
-    let ch = Chan(&p);
+    let p = core::comm::Port();
+    let ch = core::comm::Chan(&p);
 
     task::spawn(|| child(ch) );
 
-    let x: int = recv(p);
+    let x: int = core::comm::recv(p);
 
     log(debug, x);
 
diff --git a/src/test/run-pass/issue-687.rs b/src/test/run-pass/issue-687.rs
index 890dce22bff3d..bac6dc67ac2bf 100644
--- a/src/test/run-pass/issue-687.rs
+++ b/src/test/run-pass/issue-687.rs
@@ -8,26 +8,20 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use comm::Chan;
-use comm::Port;
-use comm::recv;
-use comm::send;
-
 enum msg { closed, received(~[u8]), }
 
-fn producer(c: Chan<~[u8]>) {
-    send(c, ~[1u8, 2u8, 3u8, 4u8]);
+fn producer(c: core::comm::Chan<~[u8]>) {
+    core::comm::send(c, ~[1u8, 2u8, 3u8, 4u8]);
     let empty: ~[u8] = ~[];
-    send(c, empty);
+    core::comm::send(c, empty);
 }
 
-fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
-    let p: Port<~[u8]> = Port();
-    send(cb, Chan(&p));
+fn packager(cb: core::comm::Chan<core::comm::Chan<~[u8]>>, msg: core::comm::Chan<msg>) {
+    let p: core::comm::Port<~[u8]> = core::comm::Port();
+    core::comm::send(cb, core::comm::Chan(&p));
     loop {
         debug!("waiting for bytes");
-        let data = recv(p);
+        let data = core::comm::recv(p);
         debug!("got bytes");
         if vec::len(data) == 0u {
             debug!("got empty bytes, quitting");
@@ -35,26 +29,26 @@ fn packager(cb: Chan<Chan<~[u8]>>, msg: Chan<msg>) {
         }
         debug!("sending non-empty buffer of length");
         log(debug, vec::len(data));
-        send(msg, received(data));
+        core::comm::send(msg, received(data));
         debug!("sent non-empty buffer");
     }
     debug!("sending closed message");
-    send(msg, closed);
+    core::comm::send(msg, closed);
     debug!("sent closed message");
 }
 
 fn main() {
-    let p: Port<msg> = Port();
-    let ch = Chan(&p);
-    let recv_reader: Port<Chan<~[u8]>> = Port();
-    let recv_reader_chan = Chan(&recv_reader);
+    let p: core::comm::Port<msg> = core::comm::Port();
+    let ch = core::comm::Chan(&p);
+    let recv_reader: core::comm::Port<core::comm::Chan<~[u8]>> = core::comm::Port();
+    let recv_reader_chan = core::comm::Chan(&recv_reader);
     let pack = task::spawn(|| packager(recv_reader_chan, ch) );
 
-    let source_chan: Chan<~[u8]> = recv(recv_reader);
+    let source_chan: core::comm::Chan<~[u8]> = core::comm::recv(recv_reader);
     let prod = task::spawn(|| producer(source_chan) );
 
     loop {
-        let msg = recv(p);
+        let msg = core::comm::recv(p);
         match msg {
           closed => { debug!("Got close message"); break; }
           received(data) => {
diff --git a/src/test/run-pass/issue-783.rs b/src/test/run-pass/issue-783.rs
index 5174b57e4f0cd..2654a7385993f 100644
--- a/src/test/run-pass/issue-783.rs
+++ b/src/test/run-pass/issue-783.rs
@@ -8,20 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use comm::*;
-use task::spawn;
-
 fn a() {
     fn doit() {
-        fn b(c: Chan<Chan<int>>) {
-            let p = Port();
-            send(c, Chan(&p));
+        fn b(c: core::comm::Chan<core::comm::Chan<int>>) {
+            let p = core::comm::Port();
+            core::comm::send(c, core::comm::Chan(&p));
         }
-        let p = Port();
-        let ch = Chan(&p);
-        spawn(|| b(ch) );
-        recv(p);
+        let p = core::comm::Port();
+        let ch = core::comm::Chan(&p);
+        task::spawn(|| b(ch) );
+        core::comm::recv(p);
     }
     let mut i = 0;
     while i < 100 {
@@ -32,6 +28,6 @@ fn a() {
 
 fn main() {
     for iter::repeat(100u) {
-        spawn(|| a() );
+        task::spawn(|| a() );
     }
 }
diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs
index b92d20bbe40c1..4a33d770872b0 100644
--- a/src/test/run-pass/ivec-tag.rs
+++ b/src/test/run-pass/ivec-tag.rs
@@ -1,20 +1,13 @@
-extern mod std;
-
-use comm::Chan;
-use comm::Port;
-use comm::send;
-use comm::recv;
-
-fn producer(c: Chan<~[u8]>) {
-    send(c,
+fn producer(c: core::comm::Chan<~[u8]>) {
+    core::comm::send(c,
          ~[1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8, 12u8,
           13u8]);
 }
 
 fn main() {
-    let p: Port<~[u8]> = Port();
-    let ch = Chan(&p);
+    let p: core::comm::Port<~[u8]> = core::comm::Port();
+    let ch = core::comm::Chan(&p);
     let prod = task::spawn(|| producer(ch) );
 
-    let data: ~[u8] = recv(p);
+    let data: ~[u8] = core::comm::recv(p);
 }
diff --git a/src/test/run-pass/lazychan.rs b/src/test/run-pass/lazychan.rs
index dabc211279ee8..a093b89b70f4b 100644
--- a/src/test/run-pass/lazychan.rs
+++ b/src/test/run-pass/lazychan.rs
@@ -9,26 +9,22 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-extern mod std;
-use comm::*;
-
 fn main() {
-    let p = Port();
-    let ch = Chan(&p);
+    let p = core::comm::Port();
+    let ch = core::comm::Chan(&p);
     let mut y: int;
 
     task::spawn(|| child(ch) );
-    y = recv(p);
+    y = core::comm::recv(p);
     debug!("received 1");
     log(debug, y);
     assert (y == 10);
 
     task::spawn(|| child(ch) );
-    y = recv(p);
+    y = core::comm::recv(p);
     debug!("received 2");
     log(debug, y);
     assert (y == 10);
 }
 
-fn child(c: Chan<int>) { send(c, 10); }
+fn child(c: core::comm::Chan<int>) { core::comm::send(c, 10); }
diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
index a47e482908bcd..af2fe623c447d 100644
--- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
+++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/mod-merge-hack-template.rs b/src/test/run-pass/mod-merge-hack-template.rs
index 61d10fcbfd641..94edb596b5f73 100644
--- a/src/test/run-pass/mod-merge-hack-template.rs
+++ b/src/test/run-pass/mod-merge-hack-template.rs
@@ -10,7 +10,7 @@
 
 // xfail-test not a test. used by mod-merge-hack.rs
 
-use T = inst::T;
+use T = self::inst::T;
 
 pub const bits: uint = inst::bits;
 pub pure fn min(x: T, y: T) -> T { if x < y { x } else { y } }
diff --git a/src/test/run-pass/mod-view-items.rs b/src/test/run-pass/mod-view-items.rs
index b76d57ddfe70d..dd5f7484f1037 100644
--- a/src/test/run-pass/mod-view-items.rs
+++ b/src/test/run-pass/mod-view-items.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs
index 0cbd8cc616d26..450b697bfb1c3 100644
--- a/src/test/run-pass/nested-pattern.rs
+++ b/src/test/run-pass/nested-pattern.rs
@@ -11,9 +11,6 @@
 
 
 // a bug was causing this to complain about leaked memory on exit
-extern mod std;
-use option::Some;
-use option::None;
 
 enum t { foo(int, uint), bar(int, Option<int>), }
 
diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs
index daf1b461f900f..620bd04905324 100644
--- a/src/test/run-pass/non-boolean-pure-fns.rs
+++ b/src/test/run-pass/non-boolean-pure-fns.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs
index 9deba54a1a87c..2f863a4211b9e 100644
--- a/src/test/run-pass/pipe-bank-proto.rs
+++ b/src/test/run-pass/pipe-bank-proto.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs
index bb86ba8f45aeb..c2d4be04191bc 100644
--- a/src/test/run-pass/pipe-detect-term.rs
+++ b/src/test/run-pass/pipe-detect-term.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-peek.rs b/src/test/run-pass/pipe-peek.rs
index 7ca81a6d13ac9..d7d0ccfc40440 100644
--- a/src/test/run-pass/pipe-peek.rs
+++ b/src/test/run-pass/pipe-peek.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs
index 5dd23a28fd78b..8589bbb8e257f 100644
--- a/src/test/run-pass/pipe-pingpong-bounded.rs
+++ b/src/test/run-pass/pipe-pingpong-bounded.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs
index 8228cf5a19cf9..88db8953b8c33 100644
--- a/src/test/run-pass/pipe-pingpong-proto.rs
+++ b/src/test/run-pass/pipe-pingpong-proto.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-presentation-examples.rs b/src/test/run-pass/pipe-presentation-examples.rs
index 82c011f106032..173325834c068 100644
--- a/src/test/run-pass/pipe-presentation-examples.rs
+++ b/src/test/run-pass/pipe-presentation-examples.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs
index 020d0fe06191a..d14b89aff7750 100644
--- a/src/test/run-pass/pipe-select.rs
+++ b/src/test/run-pass/pipe-select.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs
index c465621ac8376..4a6e7b4ce36a8 100644
--- a/src/test/run-pass/pipe-sleep.rs
+++ b/src/test/run-pass/pipe-sleep.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -29,4 +31,4 @@ fn main() {
     sleep(iotask, 500);
     
     signal(move c);
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs
index 0b3ab7fa746ed..71023d6c7f48b 100644
--- a/src/test/run-pass/placement-new-arena.rs
+++ b/src/test/run-pass/placement-new-arena.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/reexport-star.rs b/src/test/run-pass/reexport-star.rs
index 0574794deb4f5..b59ce4d9020e7 100644
--- a/src/test/run-pass/reexport-star.rs
+++ b/src/test/run-pass/reexport-star.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs
index 5b4ec1c85c9e0..0fd1b361b2973 100644
--- a/src/test/run-pass/regions-mock-trans-impls.rs
+++ b/src/test/run-pass/regions-mock-trans-impls.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs
index db5f7345a64e5..054c29c2a0571 100644
--- a/src/test/run-pass/regions-mock-trans.rs
+++ b/src/test/run-pass/regions-mock-trans.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use libc, sys, cast;
-
 enum arena = ();
 
 type bcx = {
diff --git a/src/test/run-pass/rt-circular-buffer.rs b/src/test/run-pass/rt-circular-buffer.rs
index a644f9fcb1e0e..6fde5bef74136 100644
--- a/src/test/run-pass/rt-circular-buffer.rs
+++ b/src/test/run-pass/rt-circular-buffer.rs
@@ -12,13 +12,8 @@
 
 // Regression tests for circular_buffer when using a unit
 // that has a size that is not a power of two
-extern mod std;
-use comm::Port;
-use comm::Chan;
-use comm::send;
-use comm::recv;
 
-// A 12-byte unit to send over the channel
+// A 12-byte unit to core::comm::send over the channel
 type record = {val1: u32, val2: u32, val3: u32};
 
 
@@ -27,52 +22,52 @@ type record = {val1: u32, val2: u32, val3: u32};
 // power of two so needs to be rounded up. Don't trigger any
 // assertions.
 fn test_init() {
-    let myport = Port();
-    let mychan = Chan(&myport);
+    let myport = core::comm::Port();
+    let mychan = core::comm::Chan(&myport);
     let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
-    send(mychan, val);
+    core::comm::send(mychan, val);
 }
 
 
 // Dump lots of items into the channel so it has to grow.
 // Don't trigger any assertions.
 fn test_grow() {
-    let myport = Port();
-    let mychan = Chan(&myport);
+    let myport = core::comm::Port();
+    let mychan = core::comm::Chan(&myport);
     for uint::range(0u, 100u) |i| {
         let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
-        comm::send(mychan, val);
+        core::comm::send(mychan, val);
     }
 }
 
 
 // Don't allow the buffer to shrink below it's original size
 fn test_shrink1() {
-    let myport = Port();
-    let mychan = Chan(&myport);
-    send(mychan, 0i8);
-    let x = recv(myport);
+    let myport = core::comm::Port();
+    let mychan = core::comm::Chan(&myport);
+    core::comm::send(mychan, 0i8);
+    let x = core::comm::recv(myport);
 }
 
 fn test_shrink2() {
-    let myport = Port();
-    let mychan = Chan(&myport);
+    let myport = core::comm::Port();
+    let mychan = core::comm::Chan(&myport);
     for uint::range(0u, 100u) |_i| {
         let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
-        send(mychan, val);
+        core::comm::send(mychan, val);
     }
-    for uint::range(0u, 100u) |_i| { let x = recv(myport); }
+    for uint::range(0u, 100u) |_i| { let x = core::comm::recv(myport); }
 }
 
 
 // Test rotating the buffer when the unit size is not a power of two
 fn test_rotate() {
-    let myport = Port();
-    let mychan = Chan(&myport);
+    let myport = core::comm::Port();
+    let mychan = core::comm::Chan(&myport);
     for uint::range(0u, 100u) |i| {
         let val = {val1: i as u32, val2: i as u32, val3: i as u32};
-        send(mychan, val);
-        let x = recv(myport);
+        core::comm::send(mychan, val);
+        let x = core::comm::recv(myport);
         assert (x.val1 == i as u32);
         assert (x.val2 == i as u32);
         assert (x.val3 == i as u32);
@@ -83,16 +78,16 @@ fn test_rotate() {
 // Test rotating and growing the buffer when
 // the unit size is not a power of two
 fn test_rotate_grow() {
-    let myport = Port::<record>();
-    let mychan = Chan(&myport);
+    let myport = core::comm::Port::<record>();
+    let mychan = core::comm::Chan(&myport);
     for uint::range(0u, 10u) |j| {
         for uint::range(0u, 10u) |i| {
             let val: record =
                 {val1: i as u32, val2: i as u32, val3: i as u32};
-            send(mychan, val);
+            core::comm::send(mychan, val);
         }
         for uint::range(0u, 10u) |i| {
-            let x = recv(myport);
+            let x = core::comm::recv(myport);
             assert (x.val1 == i as u32);
             assert (x.val2 == i as u32);
             assert (x.val3 == i as u32);
diff --git a/src/test/run-pass/rt-sched-1.rs b/src/test/run-pass/rt-sched-1.rs
index 66fd68faada90..ed45627a37985 100644
--- a/src/test/run-pass/rt-sched-1.rs
+++ b/src/test/run-pass/rt-sched-1.rs
@@ -10,8 +10,6 @@
 
 // Tests of the runtime's scheduler interface
 
-use ptr::is_null;
-
 type sched_id = int;
 type task_id = *libc::c_void;
 
diff --git a/src/test/run-pass/self-shadowing-import.rs b/src/test/run-pass/self-shadowing-import.rs
index caa614e1a7ef4..86e6b7f0f50fe 100644
--- a/src/test/run-pass/self-shadowing-import.rs
+++ b/src/test/run-pass/self-shadowing-import.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/send-resource.rs b/src/test/run-pass/send-resource.rs
index 3c7fa7cc3d4a7..75d526aa2c787 100644
--- a/src/test/run-pass/send-resource.rs
+++ b/src/test/run-pass/send-resource.rs
@@ -8,9 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use task::*;
-use comm::*;
-
 struct test {
   f: int,
 }
@@ -26,12 +23,12 @@ fn test(f: int) -> test {
 }
 
 fn main() {
-    let p = Port();
-    let c = Chan(&p);
+    let p = core::comm::Port();
+    let c = core::comm::Chan(&p);
 
-    do spawn() {
-        let p = Port();
-        c.send(Chan(&p));
+    do task::spawn() {
+        let p = core::comm::Port();
+        c.send(core::comm::Chan(&p));
 
         let _r = p.recv();
     }
diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs
index df21dcdda9869..664ba09ae4b10 100644
--- a/src/test/run-pass/send-type-inference.rs
+++ b/src/test/run-pass/send-type-inference.rs
@@ -8,16 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use comm::Chan;
-use comm::send;
-use comm::Port;
-
 // tests that ctrl's type gets inferred properly
 type command<K: Send, V: Send> = {key: K, val: V};
 
-fn cache_server<K: Send, V: Send>(c: Chan<Chan<command<K, V>>>) {
-    let ctrl = Port();
-    send(c, Chan(&ctrl));
+fn cache_server<K: Send, V: Send>(c: core::comm::Chan<core::comm::Chan<command<K, V>>>) {
+    let ctrl = core::comm::Port();
+    core::comm::send(c, core::comm::Chan(&ctrl));
 }
 fn main() { }
diff --git a/src/test/run-pass/sendfn-deep-copy.rs b/src/test/run-pass/sendfn-deep-copy.rs
index 441adda3a232c..01a480ff25d9a 100644
--- a/src/test/run-pass/sendfn-deep-copy.rs
+++ b/src/test/run-pass/sendfn-deep-copy.rs
@@ -8,11 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-
-use comm::Chan;
-use comm::send;
-
 fn main() { test05(); }
 
 fn mk_counter<A:Copy>() -> fn~(A) -> (A,uint) {
diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs
index 5bbb001cb151d..504d7948ffc15 100644
--- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs
+++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs
@@ -8,11 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-
-use comm::Chan;
-use comm::send;
-
 fn main() { test05(); }
 
 fn test05_start(&&f: fn~(int)) {
diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs
index bfc9079c8d0fe..4139aedf88137 100644
--- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs
+++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs
index 8b67a01420c6b..5ae5bbaeec909 100644
--- a/src/test/run-pass/spawn-fn.rs
+++ b/src/test/run-pass/spawn-fn.rs
@@ -10,9 +10,6 @@
 // except according to those terms.
 
 
-extern mod std;
-use task::yield;
-
 fn x(s: ~str, n: int) {
     log(debug, s);
     log(debug, n);
@@ -23,5 +20,5 @@ fn main() {
     task::spawn(|| x(~"hello from second spawned fn", 66) );
     task::spawn(|| x(~"hello from third spawned fn", 67) );
     let mut i: int = 30;
-    while i > 0 { i = i - 1; debug!("parent sleeping"); yield(); }
+    while i > 0 { i = i - 1; debug!("parent sleeping"); task::yield(); }
 }
diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs
index d358d7d7986df..fb3dc1ff74100 100644
--- a/src/test/run-pass/spawn2.rs
+++ b/src/test/run-pass/spawn2.rs
@@ -9,11 +9,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-extern mod std;
-use task::spawn;
-
-fn main() { spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
+fn main() { task::spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
 
 fn child(&&args: (int, int, int, int, int, int, int, int, int)) {
     let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
diff --git a/src/test/run-pass/tag-exports.rs b/src/test/run-pass/tag-exports.rs
index 31a9c2ff69804..ff4f5bfe62fb3 100644
--- a/src/test/run-pass/tag-exports.rs
+++ b/src/test/run-pass/tag-exports.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs
index dcfc6fed20717..767887319470d 100644
--- a/src/test/run-pass/task-comm-16.rs
+++ b/src/test/run-pass/task-comm-16.rs
@@ -10,7 +10,6 @@
 // except according to those terms.
 
 
-extern mod std;
 use pipes::send;
 use pipes::Port;
 use pipes::recv;
diff --git a/src/test/run-pass/task-comm-4.rs b/src/test/run-pass/task-comm-4.rs
index 3f42b4d5b57f8..dc82ae214dcd4 100644
--- a/src/test/run-pass/task-comm-4.rs
+++ b/src/test/run-pass/task-comm-4.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
 use pipes::send;
 
 fn main() { test00(); }
diff --git a/src/test/run-pass/task-comm-6.rs b/src/test/run-pass/task-comm-6.rs
index 41e24146635a8..cad0f4f1ddeec 100644
--- a/src/test/run-pass/task-comm-6.rs
+++ b/src/test/run-pass/task-comm-6.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
 use pipes::send;
 use pipes::Chan;
 use pipes::recv;
diff --git a/src/test/run-pass/task-comm.rs b/src/test/run-pass/task-comm.rs
index 3f316f8c5f327..5147c2ba6e491 100644
--- a/src/test/run-pass/task-comm.rs
+++ b/src/test/run-pass/task-comm.rs
@@ -8,14 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-
-use task::task;
-use comm::Chan;
-use comm::Port;
-use comm::send;
-use comm::recv;
-
 fn main() {
     test00();
     // test01();
@@ -25,12 +17,12 @@ fn main() {
     test06();
 }
 
-fn test00_start(ch: Chan<int>, message: int, count: int) {
+fn test00_start(ch: core::comm::Chan<int>, message: int, count: int) {
     debug!("Starting test00_start");
     let mut i: int = 0;
     while i < count {
         debug!("Sending Message");
-        send(ch, message + 0);
+        core::comm::send(ch, message + 0);
         i = i + 1;
     }
     debug!("Ending test00_start");
@@ -41,8 +33,8 @@ fn test00() {
     let number_of_messages: int = 4;
     debug!("Creating tasks");
 
-    let po = Port();
-    let ch = Chan(&po);
+    let po = core::comm::Port();
+    let ch = core::comm::Chan(&po);
 
     let mut i: int = 0;
 
@@ -58,7 +50,7 @@ fn test00() {
     let mut sum: int = 0;
     for results.each |r| {
         i = 0;
-        while i < number_of_messages { sum += recv(po); i = i + 1; }
+        while i < number_of_messages { sum += core::comm::recv(po); i = i + 1; }
     }
 
     for results.each |r| { r.recv(); }
@@ -71,19 +63,19 @@ fn test00() {
 }
 
 fn test01() {
-    let p = Port();
+    let p = core::comm::Port();
     debug!("Reading from a port that is never written to.");
-    let value: int = recv(p);
+    let value: int = core::comm::recv(p);
     log(debug, value);
 }
 
 fn test02() {
-    let p = Port();
-    let c = Chan(&p);
+    let p = core::comm::Port();
+    let c = core::comm::Chan(&p);
     debug!("Writing to a local task channel.");
-    send(c, 42);
+    core::comm::send(c, 42);
     debug!("Reading from a local task port.");
-    let value: int = recv(p);
+    let value: int = core::comm::recv(p);
     log(debug, value);
 }
 
@@ -101,22 +93,22 @@ fn test04() {
     debug!("Finishing up.");
 }
 
-fn test05_start(ch: Chan<int>) {
-    send(ch, 10);
-    send(ch, 20);
-    send(ch, 30);
-    send(ch, 30);
-    send(ch, 30);
+fn test05_start(ch: core::comm::Chan<int>) {
+    core::comm::send(ch, 10);
+    core::comm::send(ch, 20);
+    core::comm::send(ch, 30);
+    core::comm::send(ch, 30);
+    core::comm::send(ch, 30);
 }
 
 fn test05() {
-    let po = comm::Port();
-    let ch = Chan(&po);
+    let po = core::comm::Port();
+    let ch = core::comm::Chan(&po);
     task::spawn(|| test05_start(ch) );
     let mut value: int;
-    value = recv(po);
-    value = recv(po);
-    value = recv(po);
+    value = core::comm::recv(po);
+    value = core::comm::recv(po);
+    value = core::comm::recv(po);
     log(debug, value);
 }
 
diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs
index c69886b7cadc5..2fe24a7b38e33 100644
--- a/src/test/run-pass/task-killjoin-rsrc.rs
+++ b/src/test/run-pass/task-killjoin-rsrc.rs
@@ -13,8 +13,6 @@
 // A port of task-killjoin to use a class with a dtor to manage
 // the join.
 
-extern mod std;
-
 struct notify {
     ch: comm::Chan<bool>, v: @mut bool,
 }
diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs
index f1e99924108f5..7ef94afa54fdd 100644
--- a/src/test/run-pass/task-killjoin.rs
+++ b/src/test/run-pass/task-killjoin.rs
@@ -15,8 +15,6 @@
 // task will kill the supervising task, waking it up. The supervising task no
 // longer needs to be wakened when the supervised task exits.
 
-extern mod std;
-
 fn supervised() {
     // Yield to make sure the supervisor joins before we fail. This is
     // currently not needed because the supervisor runs first, but I can
diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs
index 63f88180d0ee1..52785ed12d40a 100644
--- a/src/test/run-pass/trait-inheritance-num.rs
+++ b/src/test/run-pass/trait-inheritance-num.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs
index eb79cfb53a41a..43077a7b2e607 100644
--- a/src/test/run-pass/trait-inheritance-num0.rs
+++ b/src/test/run-pass/trait-inheritance-num0.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs
index e0ed5491f0402..ae72fce4f94d0 100644
--- a/src/test/run-pass/trait-inheritance-num2.rs
+++ b/src/test/run-pass/trait-inheritance-num2.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -103,4 +105,4 @@ fn test_float_ext<T:FloatExt>(n: T) { io::println(fmt!("%?", n < n)) }
 
 fn main() {
     test_float_ext(1f32);
-}
\ No newline at end of file
+}
diff --git a/src/test/run-pass/unique-copy-box.rs b/src/test/run-pass/unique-copy-box.rs
index 67832810d8618..2d3bb42ad4c76 100644
--- a/src/test/run-pass/unique-copy-box.rs
+++ b/src/test/run-pass/unique-copy-box.rs
@@ -8,15 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use sys::refcount;
-
 fn main() unsafe {
     let i = ~@1;
     let j = ~@2;
-    let rc1 = refcount(*i);
+    let rc1 = sys::refcount(*i);
     let j = copy i;
-    let rc2 = refcount(*i);
+    let rc2 = sys::refcount(*i);
     error!("rc1: %u rc2: %u", rc1, rc2);
     assert rc1 + 1u == rc2;
 }
diff --git a/src/test/run-pass/use-mod.rs b/src/test/run-pass/use-mod.rs
index 086bf4fed53b0..dc09d6b44487f 100644
--- a/src/test/run-pass/use-mod.rs
+++ b/src/test/run-pass/use-mod.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs
index 94d320775a1bd..d58c168e7cd32 100644
--- a/src/test/run-pass/use.rs
+++ b/src/test/run-pass/use.rs
@@ -1,3 +1,5 @@
+// xfail-fast
+
 // 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.
@@ -22,4 +24,4 @@ mod baz {
     use x = core::str;
 }
 
-fn main() { }
\ No newline at end of file
+fn main() { }
diff --git a/src/test/run-pass/yield.rs b/src/test/run-pass/yield.rs
index b19cf183b352c..2d73e67213185 100644
--- a/src/test/run-pass/yield.rs
+++ b/src/test/run-pass/yield.rs
@@ -9,20 +9,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use task::*;
-
 fn main() {
     let mut result = None;
     task::task().future_result(|+r| { result = Some(move r); }).spawn(child);
     error!("1");
-    yield();
+    task::yield();
     error!("2");
-    yield();
+    task::yield();
     error!("3");
     option::unwrap(move result).recv();
 }
 
 fn child() {
-    error!("4"); yield(); error!("5"); yield(); error!("6");
+    error!("4"); task::yield(); error!("5"); task::yield(); error!("6");
 }
diff --git a/src/test/run-pass/yield1.rs b/src/test/run-pass/yield1.rs
index ce0f9cefde0cc..34e2f7b3c5d73 100644
--- a/src/test/run-pass/yield1.rs
+++ b/src/test/run-pass/yield1.rs
@@ -9,14 +9,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use task::*;
-
 fn main() {
     let mut result = None;
     task::task().future_result(|+r| { result = Some(move r); }).spawn(child);
     error!("1");
-    yield();
+    task::yield();
     option::unwrap(move result).recv();
 }
 
diff --git a/src/test/run-pass/yield2.rs b/src/test/run-pass/yield2.rs
index 3d5a326815e29..85a8befd3baa0 100644
--- a/src/test/run-pass/yield2.rs
+++ b/src/test/run-pass/yield2.rs
@@ -9,8 +9,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-
 fn main() {
     let mut i: int = 0;
     while i < 100 { i = i + 1; log(error, i); task::yield(); }
diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs
index eef2a414bb6aa..c5a3c8baa3dab 100644
--- a/src/test/run-pass/zip-same-length.rs
+++ b/src/test/run-pass/zip-same-length.rs
@@ -10,7 +10,6 @@
 
 // In this case, the code should compile and should
 // succeed at runtime
-extern mod std;
 use vec::{head, is_not_empty, last, same_length, zip};
 
 fn enum_chars(start: u8, end: u8) -> ~[char] {

From 08b1c841daa401afb9516987ceb07906615c4a1d Mon Sep 17 00:00:00 2001
From: Andrew Dunham <andrew@du.nham.ca>
Date: Thu, 13 Dec 2012 20:07:58 -0500
Subject: [PATCH 23/23] Rename "to_str" to "make_string" in the docs

There's already a "to_str" impl for string, so it fails here.
---
 doc/rust.md | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/rust.md b/doc/rust.md
index a17e3dcd2308d..d7f5c10b5d6e9 100644
--- a/doc/rust.md
+++ b/doc/rust.md
@@ -2719,18 +2719,18 @@ The special type `self` has a meaning within methods inside an
 impl item. It refers to the type of the implicit `self` argument. For
 example, in:
 
-~~~~~~~~{.xfail-test}
+~~~~~~~~
 trait Printable {
-  fn to_str() -> ~str;
+  fn make_string() -> ~str;
 }
 
 impl ~str: Printable {
-  fn to_str() -> ~str { copy self }
+  fn make_string() -> ~str { copy self }
 }
 ~~~~~~~~
 
 `self` refers to the value of type `~str` that is the receiver for a
-call to the method `to_str`.
+call to the method `make_string`.
 
 ## Type kinds