From 4ecb672d7f526cf2cda2d62c04106196ad57d7db Mon Sep 17 00:00:00 2001
From: Niko Matsakis <niko@alum.mit.edu>
Date: Tue, 26 Feb 2013 21:42:00 -0500
Subject: [PATCH] Remove legacy object creation mode, and convert remaining
 uses of it

---
 src/libcore/io.rs                             |  14 +-
 src/libcore/rand.rs                           |  12 +-
 src/libcore/repr.rs                           |   4 +-
 src/libcore/run.rs                            |   2 +-
 src/libcore/task/local_data_priv.rs           |   2 +-
 src/librustc/metadata/common.rs               |   5 +-
 src/librustc/metadata/filesearch.rs           |   4 +-
 src/librustc/middle/astencode.rs              |  10 +-
 src/librustc/middle/trans/cabi.rs             |   4 +-
 src/librustc/middle/trans/cabi_arm.rs         |   4 +-
 src/librustc/middle/trans/cabi_x86_64.rs      |   2 +-
 src/librustc/middle/trans/meth.rs             |  25 +-
 src/librustc/middle/ty.rs                     |   2 -
 src/librustc/middle/typeck/check/vtable.rs    | 224 ++++++++----------
 src/librustc/middle/typeck/rscope.rs          |   6 +-
 src/libstd/sha1.rs                            |   4 +-
 src/libsyntax/ext/auto_encode.rs              |   8 +-
 src/libsyntax/fold.rs                         | 221 ++++++++---------
 src/libsyntax/parse/mod.rs                    |   2 +-
 src/test/auxiliary/issue-2380.rs              |   2 +-
 src/test/bench/shootout-mandelbrot.rs         |   2 +-
 src/test/compile-fail/class-cast-to-trait.rs  |   2 +-
 .../kindck-owned-trait-contains.rs            |   2 +-
 .../compile-fail/kindck-owned-trait-scoped.rs |   6 +-
 src/test/compile-fail/kindck-owned-trait.rs   |   4 +-
 src/test/compile-fail/map-types.rs            |   4 +-
 src/test/compile-fail/regions-trait-1.rs      |   2 +-
 src/test/compile-fail/regions-trait-2.rs      |   2 +-
 src/test/compile-fail/regions-trait-3.rs      |   2 +-
 src/test/compile-fail/selftype-astparam.rs    |   4 +-
 src/test/compile-fail/tps-invariant-trait.rs  |   2 +-
 src/test/compile-fail/trait-cast.rs           |   2 +-
 src/test/compile-fail/trait-test-2.rs         |   2 +-
 src/test/run-fail/unwind-box-trait.rs         |   2 +-
 ...autoderef-method-on-trait-monomorphized.rs |   2 +-
 .../run-pass/autoderef-method-on-trait.rs     |   2 +-
 src/test/run-pass/boxed-trait-with-vstore.rs  |   2 +-
 .../class-cast-to-trait-cross-crate-2.rs      |   2 +-
 .../class-cast-to-trait-multiple-types.rs     |   4 +-
 src/test/run-pass/class-cast-to-trait.rs      |   2 +-
 src/test/run-pass/class-separate-impl.rs      |   2 +-
 .../run-pass/explicit-self-objects-ext-1.rs   |   2 +-
 .../run-pass/explicit-self-objects-ext-2.rs   |   2 +-
 .../run-pass/explicit-self-objects-ext-3.rs   |   2 +-
 .../run-pass/explicit-self-objects-ext-4.rs   |   2 +-
 src/test/run-pass/issue-2288.rs               |   2 +-
 src/test/run-pass/issue-2734.rs               |   2 +-
 src/test/run-pass/issue-2735.rs               |   6 +-
 src/test/run-pass/issue-2904.rs               |   2 +-
 src/test/run-pass/issue-2935.rs               |   2 +-
 src/test/run-pass/issue-3305.rs               |   2 +-
 .../run-pass/kindck-owned-trait-contains-1.rs |   2 +-
 src/test/run-pass/reflect-visit-data.rs       |   4 +-
 src/test/run-pass/regions-trait.rs            |   2 +-
 54 files changed, 292 insertions(+), 351 deletions(-)

diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 45d89b29a2e..fdb622f6539 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -504,7 +504,7 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader {
 
 pub fn stdin() -> @Reader {
     unsafe {
-        rustrt::rust_get_stdin() as @Reader
+        @rustrt::rust_get_stdin() as @Reader
     }
 }
 
@@ -642,11 +642,11 @@ impl Writer for *libc::FILE {
     }
 }
 
-pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer {
+pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer {
     if cleanup {
-        Wrapper { base: f, cleanup: FILERes(f) } as Writer
+        @Wrapper { base: f, cleanup: FILERes(f) } as @Writer
     } else {
-        f as Writer
+        @f as @Writer
     }
 }
 
@@ -702,11 +702,11 @@ pub fn FdRes(fd: fd_t) -> FdRes {
     }
 }
 
-pub fn fd_writer(fd: fd_t, cleanup: bool) -> Writer {
+pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer {
     if cleanup {
-        Wrapper { base: fd, cleanup: FdRes(fd) } as Writer
+        @Wrapper { base: fd, cleanup: FdRes(fd) } as @Writer
     } else {
-        fd as Writer
+        @fd as @Writer
     }
 }
 
diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs
index 04a551740a8..d9c2b91fb97 100644
--- a/src/libcore/rand.rs
+++ b/src/libcore/rand.rs
@@ -412,8 +412,8 @@ pub fn Rng() -> Rng {
  * all other generators constructed with the same seed. The seed may be any
  * length.
  */
-pub fn seeded_rng(seed: &[u8]) -> Rng {
-    seeded_randres(seed) as Rng
+pub fn seeded_rng(seed: &[u8]) -> @Rng {
+    @seeded_randres(seed) as @Rng
 }
 
 fn seeded_randres(seed: &[u8]) -> @RandRes {
@@ -449,8 +449,8 @@ pub pure fn xorshift() -> Rng {
     seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32)
 }
 
-pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
-    XorShiftState { x: x, y: y, z: z, w: w } as Rng
+pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng {
+    @XorShiftState { x: x, y: y, z: z, w: w } as @Rng
 }
 
 
@@ -472,10 +472,10 @@ pub fn task_rng() -> Rng {
             unsafe {
                 let rng = seeded_randres(seed());
                 task::local_data::local_data_set(tls_rng_state, rng);
-                rng as Rng
+                @rng as @Rng
             }
         }
-        Some(rng) => rng as Rng
+        Some(rng) => @rng as @Rng
     }
 }
 
diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs
index ab4bdec266c..af135339b2e 100644
--- a/src/libcore/repr.rs
+++ b/src/libcore/repr.rs
@@ -201,7 +201,7 @@ pub impl ReprVisitor {
         unsafe {
             let mut u = ReprVisitor(ptr, self.writer);
             let v = reflect::MovePtrAdaptor(u);
-            visit_tydesc(inner, (v) as @TyVisitor);
+            visit_tydesc(inner, @v as @TyVisitor);
             true
         }
     }
@@ -570,7 +570,7 @@ pub fn write_repr<T>(writer: @Writer, object: &T) {
         let tydesc = intrinsic::get_tydesc::<T>();
         let mut u = ReprVisitor(ptr, writer);
         let v = reflect::MovePtrAdaptor(u);
-        visit_tydesc(tydesc, (v) as @TyVisitor)
+        visit_tydesc(tydesc, @v as @TyVisitor)
     }
 }
 
diff --git a/src/libcore/run.rs b/src/libcore/run.rs
index aa1e473e3bf..e8cd9caaef6 100644
--- a/src/libcore/run.rs
+++ b/src/libcore/run.rs
@@ -288,7 +288,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
         finished: false,
     };
 
-    ProgRes(repr) as Program
+    @ProgRes(repr) as @Program
 }
 
 fn read_all(rd: io::Reader) -> ~str {
diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs
index 3ac457b23d1..df5a5af74ca 100644
--- a/src/libcore/task/local_data_priv.rs
+++ b/src/libcore/task/local_data_priv.rs
@@ -155,7 +155,7 @@ pub unsafe fn local_set<T:Durable>(
     // does not have a reference associated with it, so it may become invalid
     // when the box is destroyed.
     let data_ptr = cast::reinterpret_cast(&data);
-    let data_box = data as LocalData;
+    let data_box = @data as @LocalData;
     // Construct new entry to store in the map.
     let new_entry = Some((keyval, data_ptr, data_box));
     // Find a place to put it.
diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs
index 90d8dcdc235..daf369f7279 100644
--- a/src/librustc/metadata/common.rs
+++ b/src/librustc/metadata/common.rs
@@ -132,9 +132,8 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
     tag_table_method_map = 0x60,
     tag_table_vtable_map = 0x61,
     tag_table_adjustments = 0x62,
-    tag_table_legacy_boxed_trait = 0x63,
-    tag_table_moves_map = 0x64,
-    tag_table_capture_map = 0x65
+    tag_table_moves_map = 0x63,
+    tag_table_capture_map = 0x64
 }
 
 pub const tag_item_trait_method_sort: uint = 0x70;
diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs
index 82ea0b6d6f1..1a7c7b0793a 100644
--- a/src/librustc/metadata/filesearch.rs
+++ b/src/librustc/metadata/filesearch.rs
@@ -71,11 +71,11 @@ pub fn mk_filesearch(maybe_sysroot: Option<Path>,
 
     let sysroot = get_sysroot(maybe_sysroot);
     debug!("using sysroot = %s", sysroot.to_str());
-    FileSearchImpl {
+    @FileSearchImpl {
         sysroot: sysroot,
         addl_lib_search_paths: addl_lib_search_paths,
         target_triple: str::from_slice(target_triple)
-    } as FileSearch
+    } as @FileSearch
 }
 
 pub fn search<T:Copy>(filesearch: FileSearch, pick: pick<T>) -> Option<T> {
diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index d6af3873999..47e0b3d26ab 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -966,12 +966,6 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
         }
     }
 
-    do option::iter(&tcx.legacy_boxed_traits.find(&id)) |_x| {
-        do ebml_w.tag(c::tag_table_legacy_boxed_trait) {
-            ebml_w.id(id);
-        }
-    }
-
     for maps.moves_map.find(&id).each |_| {
         do ebml_w.tag(c::tag_table_moves_map) {
             ebml_w.id(id);
@@ -1121,8 +1115,6 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
 
         if tag == (c::tag_table_mutbl as uint) {
             dcx.maps.mutbl_map.insert(id, ());
-        } else if tag == (c::tag_table_legacy_boxed_trait as uint) {
-            dcx.tcx.legacy_boxed_traits.insert(id, ());
         } else if tag == (c::tag_table_moves_map as uint) {
             dcx.maps.moves_map.insert(id, ());
         } else {
@@ -1230,7 +1222,7 @@ impl fake_ext_ctxt for fake_session {
 
 #[cfg(test)]
 fn mk_ctxt() -> fake_ext_ctxt {
-    parse::new_parse_sess(None) as fake_ext_ctxt
+    @parse::new_parse_sess(None) as fake_ext_ctxt
 }
 
 #[cfg(test)]
diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs
index 269fe344fea..bbc19cf86ea 100644
--- a/src/librustc/middle/trans/cabi.rs
+++ b/src/librustc/middle/trans/cabi.rs
@@ -209,8 +209,8 @@ impl ABIInfo for LLVM_ABIInfo {
     }
 }
 
-pub fn llvm_abi_info() -> ABIInfo {
-    return LLVM_ABIInfo as ABIInfo;
+pub fn llvm_abi_info() -> @ABIInfo {
+    return @LLVM_ABIInfo as @ABIInfo;
 }
 
 
diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc/middle/trans/cabi_arm.rs
index 259392bef40..a16b3672b7a 100644
--- a/src/librustc/middle/trans/cabi_arm.rs
+++ b/src/librustc/middle/trans/cabi_arm.rs
@@ -159,6 +159,6 @@ impl ABIInfo for ARM_ABIInfo {
     }
 }
 
-pub fn abi_info() -> ABIInfo {
-    return ARM_ABIInfo as ABIInfo;
+pub fn abi_info() -> @ABIInfo {
+    return @ARM_ABIInfo as @ABIInfo;
 }
diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs
index 1dc70596994..562009dc2ca 100644
--- a/src/librustc/middle/trans/cabi_x86_64.rs
+++ b/src/librustc/middle/trans/cabi_x86_64.rs
@@ -408,5 +408,5 @@ impl ABIInfo for X86_64_ABIInfo {
 }
 
 pub fn x86_64_abi_info() -> ABIInfo {
-    return X86_64_ABIInfo as ABIInfo;
+    return @X86_64_ABIInfo as @ABIInfo;
 }
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index 5e7d13c3ad3..be1a3b90b4c 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -870,26 +870,11 @@ pub fn trans_trait_cast(bcx: block,
     match vstore {
         ty::vstore_slice(*) | ty::vstore_box => {
             let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]);
-            if bcx.tcx().legacy_boxed_traits.contains_key(&id) {
-                // Allocate an @ box and store the value into it
-                let MallocResult {bcx: new_bcx, box: llbox, body: body} =
-                    malloc_boxed(bcx, v_ty);
-                bcx = new_bcx;
-                add_clean_free(bcx, llbox, heap_managed);
-                bcx = expr::trans_into(bcx, val, SaveIn(body));
-                revoke_clean(bcx, llbox);
-
-                // Store the @ box into the pair
-                Store(bcx, llbox, PointerCast(bcx,
-                                              llboxdest,
-                                              T_ptr(val_ty(llbox))));
-            } else {
-                // Just store the pointer into the pair.
-                llboxdest = PointerCast(bcx,
-                                        llboxdest,
-                                        T_ptr(type_of(bcx.ccx(), v_ty)));
-                bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
-            }
+            // Just store the pointer into the pair.
+            llboxdest = PointerCast(bcx,
+                                    llboxdest,
+                                    T_ptr(type_of(bcx.ccx(), v_ty)));
+            bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
         }
         ty::vstore_uniq => {
             // Translate the uniquely-owned value into the second element of
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 7105017cd88..8bca7f42b48 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -269,7 +269,6 @@ struct ctxt_ {
     adjustments: HashMap<ast::node_id, @AutoAdjustment>,
     normalized_cache: HashMap<t, t>,
     lang_items: middle::lang_items::LanguageItems,
-    legacy_boxed_traits: HashMap<node_id, ()>,
     // A mapping from an implementation ID to the method info and trait
     // method ID of the provided (a.k.a. default) methods in the traits that
     // that implementation implements.
@@ -831,7 +830,6 @@ pub fn mk_ctxt(s: session::Session,
         adjustments: HashMap(),
         normalized_cache: new_ty_hash(),
         lang_items: lang_items,
-        legacy_boxed_traits: HashMap(),
         provided_methods: HashMap(),
         provided_method_sources: HashMap(),
         supertraits: HashMap(),
diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs
index e6b837fa949..5ed247eb447 100644
--- a/src/librustc/middle/typeck/check/vtable.rs
+++ b/src/librustc/middle/typeck/check/vtable.rs
@@ -97,8 +97,8 @@ pub fn lookup_vtables(vcx: &VtableContext,
     let mut result = ~[], i = 0u;
     for substs.tps.each |ty| {
         for ty::iter_bound_traits_and_supertraits(
-            tcx, bounds[i]) |trait_ty| {
-
+            tcx, bounds[i]) |trait_ty|
+        {
             debug!("about to subst: %?, %?",
                    ppaux::ty_to_str(tcx, trait_ty),
                    ty::substs_to_str(tcx, substs));
@@ -585,138 +585,102 @@ pub fn early_resolve_expr(ex: @ast::expr,
         }
       }
       ast::expr_cast(src, _) => {
-        let target_ty = fcx.expr_ty(ex);
-        match ty::get(target_ty).sty {
-          ty::ty_trait(_, _, vstore) => {
-            // Look up vtables for the type we're casting to, passing in the
-            // source and target type.
-            //
-            // XXX: This is invariant and shouldn't be. --pcw
+          let target_ty = fcx.expr_ty(ex);
+          match ty::get(target_ty).sty {
+              ty::ty_trait(_, _, vstore) => {
+                  // Look up vtables for the type we're casting to,
+                  // passing in the source and target type.  The source
+                  // must be a pointer type suitable to the object sigil,
+                  // e.g.: `@x as @Trait`, `&x as &Trait` or `~x as ~Trait`
+                  let ty = structurally_resolved_type(fcx, ex.span,
+                                                      fcx.expr_ty(src));
+                  match (&ty::get(ty).sty, vstore) {
+                      (&ty::ty_box(mt), ty::vstore_box) |
+                      (&ty::ty_uniq(mt), ty::vstore_uniq) |
+                      (&ty::ty_rptr(_, mt), ty::vstore_slice(*)) => {
+                          let location_info =
+                              &location_info_for_expr(ex);
+                          let vcx = VtableContext {
+                              ccx: fcx.ccx,
+                              infcx: fcx.infcx()
+                          };
+                          let vtable_opt =
+                              lookup_vtable(&vcx,
+                                            location_info,
+                                            mt.ty,
+                                            target_ty,
+                                            true,
+                                            is_early);
+                          match vtable_opt {
+                              Some(vtable) => {
+                                  // Map this expression to that
+                                  // vtable (that is: "ex has vtable
+                                  // <vtable>")
+                                  if !is_early {
+                                      let vtable_map =
+                                          cx.vtable_map;
+                                      vtable_map.insert(ex.id,
+                                                        @~[vtable]);
+                                  }
+                              }
+                              None => {
+                                  fcx.tcx().sess.span_err(
+                                      ex.span,
+                                      fmt!("failed to find an implementation \
+                                            of trait %s for %s",
+                                           fcx.infcx().ty_to_str(target_ty),
+                                           fcx.infcx().ty_to_str(mt.ty)));
+                              }
+                          }
 
-            let ty = fcx.expr_ty(src);
-            let vcx = VtableContext { ccx: fcx.ccx, infcx: fcx.infcx() };
-            let vtable_opt =
-                lookup_vtable(&vcx,
-                              &location_info_for_expr(ex),
-                              ty,
-                              target_ty,
-                              true,
-                              is_early);
-            match vtable_opt {
-                None => {
-                    // Try the new-style boxed trait; "@int as @Trait".
-                    // Or the new-style region trait; "&int as &Trait".
-                    // Or the new-style uniquely-owned trait; "~int as
-                    // ~Trait".
-                    let mut err = false;
-                    let ty = structurally_resolved_type(fcx, ex.span, ty);
-                    match ty::get(ty).sty {
-                        ty::ty_box(mt) | ty::ty_rptr(_, mt) |
-                        ty::ty_uniq(mt) => {
-                            // Ensure that the trait vstore and the pointer
-                            // type match.
-                            match (&ty::get(ty).sty, vstore) {
-                                (&ty::ty_box(_), ty::vstore_box) |
-                                (&ty::ty_uniq(_), ty::vstore_uniq) |
-                                (&ty::ty_rptr(*), ty::vstore_slice(*)) => {
-                                    let location_info =
-                                        &location_info_for_expr(ex);
-                                    let vtable_opt =
-                                        lookup_vtable(&vcx,
-                                                      location_info,
-                                                      mt.ty,
-                                                      target_ty,
-                                                      true,
-                                                      is_early);
-                                    match vtable_opt {
-                                        Some(vtable) => {
-                                            // Map this expression to that
-                                            // vtable (that is: "ex has vtable
-                                            // <vtable>")
-                                            if !is_early {
-                                                let vtable_map =
-                                                    cx.vtable_map;
-                                                vtable_map.insert(ex.id,
-                                                                  @~[vtable]);
-                                            }
-                                        }
-                                        None => err = true
-                                    }
+                          // Now, if this is &trait, we need to link the
+                          // regions.
+                          match (&ty::get(ty).sty, vstore) {
+                              (&ty::ty_rptr(ra, _),
+                               ty::vstore_slice(rb)) => {
+                                  infer::mk_subr(fcx.infcx(),
+                                                 false,
+                                                 ex.span,
+                                                 rb,
+                                                 ra);
+                              }
+                              _ => {}
+                          }
+                      }
 
-                                    // Now, if this is &trait, we need to link
-                                    // the regions.
-                                    match (&ty::get(ty).sty, vstore) {
-                                        (&ty::ty_rptr(ra, _),
-                                         ty::vstore_slice(rb)) => {
-                                            infer::mk_subr(fcx.infcx(),
-                                                           false,
-                                                           ex.span,
-                                                           rb,
-                                                           ra);
-                                        }
-                                        _ => {}
-                                    }
-                                }
-                                (&ty::ty_box(_), _) => {
-                                    fcx.ccx.tcx.sess.span_err(ex.span,
-                                                              ~"must cast \
-                                                                a boxed \
-                                                                pointer to \
-                                                                a boxed
-                                                                trait");
-                                    err = true;
-                                }
-                                (&ty::ty_rptr(*), _) => {
-                                    fcx.ccx.tcx.sess.span_err(ex.span,
-                                                              ~"must cast \
-                                                                a borrowed \
-                                                                pointer to \
-                                                                a borrowed \
-                                                                trait");
-                                }
-                                (&ty::ty_uniq(*), _) => {
-                                    fcx.ccx.tcx.sess.span_err(ex.span,
-                                                              ~"must cast \
-                                                                a unique \
-                                                                pointer to \
-                                                                a uniquely-\
-                                                                owned trait");
-                                }
-                                _ => {
-                                    fcx.ccx.tcx.sess.impossible_case(
-                                        ex.span,
-                                        ~"impossible combination of type and \
-                                          trait vstore");
-                                }
-                            }
-                        }
-                        _ => err = true
-                    }
+                      (_, ty::vstore_box(*)) => {
+                          fcx.ccx.tcx.sess.span_err(
+                              ex.span,
+                              fmt!("can only cast an @-pointer \
+                                    to an @-object, not a %s",
+                                   ty::ty_sort_str(fcx.tcx(), ty)));
+                      }
 
-                    if err {
-                        fcx.tcx().sess.span_fatal(
-                            ex.span,
-                            fmt!("failed to find an implementation of trait \
-                                  %s for %s",
-                                 fcx.infcx().ty_to_str(target_ty),
-                                 fcx.infcx().ty_to_str(ty)));
-                    }
-                }
-                Some(vtable) => {
-                    /*
-                    Map this expression to that vtable (that is: "ex has
-                    vtable <vtable>")
-                    */
-                    if !is_early {
-                        let vtable_map = cx.vtable_map;
-                        vtable_map.insert(ex.id, @~[vtable]);
-                    }
-                    fcx.tcx().legacy_boxed_traits.insert(ex.id, ());
-                }
-            }
+                      (_, ty::vstore_uniq(*)) => {
+                          fcx.ccx.tcx.sess.span_err(
+                              ex.span,
+                              fmt!("can only cast an ~-pointer \
+                                    to a ~-object, not a %s",
+                                   ty::ty_sort_str(fcx.tcx(), ty)));
+                      }
+
+                      (_, ty::vstore_slice(*)) => {
+                          fcx.ccx.tcx.sess.span_err(
+                              ex.span,
+                              fmt!("can only cast an &-pointer \
+                                    to an &-object, not a %s",
+                                   ty::ty_sort_str(fcx.tcx(), ty)));
+                      }
+
+                      (_, ty::vstore_fixed(*)) => {
+                          fcx.tcx().sess.span_bug(
+                              ex.span,
+                              fmt!("trait with fixed vstore"));
+                      }
+                  }
+              }
+              _ => { /* not a cast to a trait; ignore */ }
           }
-          _ => ()
-        }
       }
       _ => ()
     }
diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs
index 628cccfa9a2..d82667285ff 100644
--- a/src/librustc/middle/typeck/rscope.rs
+++ b/src/librustc/middle/typeck/rscope.rs
@@ -70,11 +70,11 @@ pub fn bound_self_region(rp: Option<ty::region_variance>)
     }
 }
 
-pub struct anon_rscope { anon: ty::Region, base: region_scope }
+pub struct anon_rscope { anon: ty::Region, base: @region_scope }
 pub fn in_anon_rscope<RS:region_scope + Copy + Durable>(self: RS,
                                                         r: ty::Region)
                                                      -> @anon_rscope {
-    @anon_rscope {anon: r, base: self as region_scope}
+    @anon_rscope {anon: r, base: @self as @region_scope}
 }
 
 impl region_scope for @anon_rscope {
@@ -97,7 +97,7 @@ pub struct binding_rscope {
 
 pub fn in_binding_rscope<RS:region_scope + Copy + Durable>(self: RS)
     -> @mut binding_rscope {
-    let base = self as region_scope;
+    let base = @self as @region_scope;
     @mut binding_rscope { base: base, anon_bindings: 0 }
 }
 
diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs
index 69c3de5ff62..e8c1413e90a 100644
--- a/src/libstd/sha1.rs
+++ b/src/libstd/sha1.rs
@@ -63,7 +63,7 @@ const k3: u32 = 0xCA62C1D6u32;
 
 
 /// Construct a `sha` object
-pub fn sha1() -> Sha1 {
+pub fn sha1() -> @Sha1 {
     struct Sha1State
         { h: ~[u32],
           len_low: u32,
@@ -269,7 +269,7 @@ pub fn sha1() -> Sha1 {
          computed: false,
          work_buf: @mut vec::from_elem(work_buf_len, 0u32)
     };
-    let mut sh = (st) as Sha1;
+    let mut sh = @st as @Sha1;
     sh.reset();
     return sh;
 }
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 43eaef95ee2..5f076136271 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -1296,7 +1296,7 @@ mod test {
     }
 
 
-    fn to_call_log (val: Encodable<TestEncoder>) -> ~[call] {
+    fn to_call_log<E:Encodable<TestEncoder>>(val: E) -> ~[call] {
         let mut te = TestEncoder {call_log: @mut ~[]};
         val.encode(&te);
         copy *te.call_log
@@ -1309,8 +1309,7 @@ mod test {
     }
 
     #[test] fn encode_enum_test () {
-        check_equal (to_call_log(Book(34,44)
-                                 as Encodable::<TestEncoder>),
+        check_equal (to_call_log(Book(34,44)),
                      ~[CallToEmitEnum (~"Written"),
                        CallToEmitEnumVariant (~"Book",0,2),
                        CallToEmitEnumVariantArg (0),
@@ -1325,8 +1324,7 @@ mod test {
     pub struct HasPos { pos : BPos }
 
     #[test] fn encode_newtype_test () {
-        check_equal (to_call_log (HasPos {pos:BPos(48)}
-                                 as Encodable::<TestEncoder>),
+        check_equal (to_call_log (HasPos {pos:BPos(48)}),
                     ~[CallToEmitStruct(~"HasPos",1),
                       CallToEmitField(~"pos",0),
                       CallToEmitUint(48)]);
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index f55ba3adfae..eb9dd0ec03c 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -19,29 +19,29 @@ use core::option;
 use core::vec;
 
 pub trait ast_fold {
-    fn fold_crate(crate) -> crate;
-    fn fold_view_item(&&v: @view_item) -> @view_item;
-    fn fold_foreign_item(&&v: @foreign_item) -> @foreign_item;
-    fn fold_item(&&v: @item) -> Option<@item>;
-    fn fold_struct_field(&&v: @struct_field) -> @struct_field;
-    fn fold_item_underscore(item_) -> item_;
-    fn fold_method(&&v: @method) -> @method;
-    fn fold_block(blk) -> blk;
-    fn fold_stmt(&&v: @stmt) -> @stmt;
-    fn fold_arm(arm) -> arm;
-    fn fold_pat(&&v: @pat) -> @pat;
-    fn fold_decl(&&v: @decl) -> @decl;
-    fn fold_expr(&&v: @expr) -> @expr;
-    fn fold_ty(&&v: @Ty) -> @Ty;
-    fn fold_mod(_mod) -> _mod;
-    fn fold_foreign_mod(foreign_mod) -> foreign_mod;
-    fn fold_variant(variant) -> variant;
-    fn fold_ident(&&v: ident) -> ident;
-    fn fold_path(&&v: @path) -> @path;
-    fn fold_local(&&v: @local) -> @local;
-    fn map_exprs(fn@(&&v: @expr) -> @expr, ~[@expr]) -> ~[@expr];
-    fn new_id(node_id) -> node_id;
-    fn new_span(span) -> span;
+    fn fold_crate(@self, crate) -> crate;
+    fn fold_view_item(@self, &&v: @view_item) -> @view_item;
+    fn fold_foreign_item(@self, &&v: @foreign_item) -> @foreign_item;
+    fn fold_item(@self, &&v: @item) -> Option<@item>;
+    fn fold_struct_field(@self, &&v: @struct_field) -> @struct_field;
+    fn fold_item_underscore(@self, item_) -> item_;
+    fn fold_method(@self, &&v: @method) -> @method;
+    fn fold_block(@self, blk) -> blk;
+    fn fold_stmt(@self, &&v: @stmt) -> @stmt;
+    fn fold_arm(@self, arm) -> arm;
+    fn fold_pat(@self, &&v: @pat) -> @pat;
+    fn fold_decl(@self, &&v: @decl) -> @decl;
+    fn fold_expr(@self, &&v: @expr) -> @expr;
+    fn fold_ty(@self, &&v: @Ty) -> @Ty;
+    fn fold_mod(@self, _mod) -> _mod;
+    fn fold_foreign_mod(@self, foreign_mod) -> foreign_mod;
+    fn fold_variant(@self, variant) -> variant;
+    fn fold_ident(@self, &&v: ident) -> ident;
+    fn fold_path(@self, &&v: @path) -> @path;
+    fn fold_local(@self, &&v: @local) -> @local;
+    fn map_exprs(@self, fn@(&&v: @expr) -> @expr, ~[@expr]) -> ~[@expr];
+    fn new_id(@self, node_id) -> node_id;
+    fn new_span(@self, span) -> span;
 }
 
 // We may eventually want to be able to fold over type parameters, too
@@ -78,7 +78,7 @@ pub type ast_fold_fns = @AstFoldFns;
 /* some little folds that probably aren't useful to have in ast_fold itself*/
 
 //used in noop_fold_item and noop_fold_crate and noop_fold_crate_directive
-fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
+fn fold_meta_item_(&&mi: @meta_item, fld: @ast_fold) -> @meta_item {
     @spanned {
         node:
             match mi.node {
@@ -95,7 +95,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
         span: fld.new_span(mi.span) }
 }
 //used in noop_fold_item and noop_fold_crate
-fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute {
+fn fold_attribute_(at: attribute, fld: @ast_fold) -> attribute {
     spanned {
         node: ast::attribute_ {
             style: at.node.style,
@@ -106,7 +106,7 @@ fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute {
     }
 }
 //used in noop_fold_foreign_item and noop_fold_fn_decl
-fn fold_arg_(a: arg, fld: ast_fold) -> arg {
+fn fold_arg_(a: arg, fld: @ast_fold) -> arg {
     ast::arg {
         mode: a.mode,
         is_mutbl: a.is_mutbl,
@@ -116,14 +116,14 @@ fn fold_arg_(a: arg, fld: ast_fold) -> arg {
     }
 }
 //used in noop_fold_expr, and possibly elsewhere in the future
-fn fold_mac_(m: mac, fld: ast_fold) -> mac {
+fn fold_mac_(m: mac, fld: @ast_fold) -> mac {
     spanned { node: match m.node {
                         mac_invoc_tt(*) => m.node,
                     },
               span: fld.new_span(m.span) }
 }
 
-pub fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
+pub fn fold_fn_decl(decl: ast::fn_decl, fld: @ast_fold) -> ast::fn_decl {
     ast::fn_decl {
         inputs: decl.inputs.map(|x| fold_arg_(*x, fld)),
         output: fld.fold_ty(decl.output),
@@ -131,41 +131,44 @@ pub fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
     }
 }
 
-fn fold_ty_param_bound(tpb: TyParamBound, fld: ast_fold) -> TyParamBound {
+fn fold_ty_param_bound(tpb: TyParamBound,
+                       fld: @ast_fold) -> TyParamBound {
     match tpb {
         TraitTyParamBound(ty) => TraitTyParamBound(fld.fold_ty(ty)),
         RegionTyParamBound => RegionTyParamBound
     }
 }
 
-pub fn fold_ty_param(tp: TyParam, fld: ast_fold) -> TyParam {
+pub fn fold_ty_param(tp: TyParam,
+                     fld: @ast_fold) -> TyParam {
     TyParam {ident: tp.ident,
              id: fld.new_id(tp.id),
              bounds: @tp.bounds.map(|x| fold_ty_param_bound(*x, fld))}
 }
 
 pub fn fold_ty_params(tps: &OptVec<TyParam>,
-                      fld: ast_fold) -> OptVec<TyParam> {
+                      fld: @ast_fold) -> OptVec<TyParam> {
     tps.map(|tp| fold_ty_param(*tp, fld))
 }
 
-pub fn fold_lifetime(l: &Lifetime, fld: ast_fold) -> Lifetime {
+pub fn fold_lifetime(l: &Lifetime,
+                     fld: @ast_fold) -> Lifetime {
     Lifetime {id: fld.new_id(l.id),
               span: fld.new_span(l.span),
               ident: l.ident}
 }
 
 pub fn fold_lifetimes(lts: &OptVec<Lifetime>,
-                      fld: ast_fold) -> OptVec<Lifetime> {
+                      fld: @ast_fold) -> OptVec<Lifetime> {
     lts.map(|l| fold_lifetime(l, fld))
 }
 
-pub fn fold_generics(generics: &Generics, fld: ast_fold) -> Generics {
+pub fn fold_generics(generics: &Generics, fld: @ast_fold) -> Generics {
     Generics {ty_params: fold_ty_params(&generics.ty_params, fld),
               lifetimes: fold_lifetimes(&generics.lifetimes, fld)}
 }
 
-pub fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
+pub fn noop_fold_crate(c: crate_, fld: @ast_fold) -> crate_ {
     let fold_meta_item = |x| fold_meta_item_(x, fld);
     let fold_attribute = |x| fold_attribute_(x, fld);
 
@@ -176,12 +179,12 @@ pub fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
     }
 }
 
-fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
+fn noop_fold_view_item(vi: view_item_, _fld: @ast_fold) -> view_item_ {
     return /* FIXME (#2543) */ copy vi;
 }
 
 
-fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
+fn noop_fold_foreign_item(&&ni: @foreign_item, fld: @ast_fold)
     -> @foreign_item {
     let fold_arg = |x| fold_arg_(x, fld);
     let fold_attribute = |x| fold_attribute_(x, fld);
@@ -211,7 +214,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
     }
 }
 
-pub fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> {
+pub fn noop_fold_item(&&i: @item, fld: @ast_fold) -> Option<@item> {
     let fold_attribute = |x| fold_attribute_(x, fld);
 
     Some(@ast::item { ident: fld.fold_ident(i.ident),
@@ -222,7 +225,7 @@ pub fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> {
                       span: fld.new_span(i.span) })
 }
 
-fn noop_fold_struct_field(&&sf: @struct_field, fld: ast_fold)
+fn noop_fold_struct_field(&&sf: @struct_field, fld: @ast_fold)
                        -> @struct_field {
     @spanned { node: ast::struct_field_ { kind: copy sf.node.kind,
                                           id: sf.node.id,
@@ -230,7 +233,7 @@ fn noop_fold_struct_field(&&sf: @struct_field, fld: ast_fold)
                span: sf.span }
 }
 
-pub fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
+pub fn noop_fold_item_underscore(i: item_, fld: @ast_fold) -> item_ {
     match i {
         item_const(t, e) => item_const(fld.fold_ty(t), fld.fold_expr(e)),
         item_fn(ref decl, purity, ref typms, ref body) => {
@@ -281,7 +284,7 @@ pub fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
     }
 }
 
-fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
+fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold)
                 -> @ast::struct_def {
     let dtor = do option::map(&struct_def.dtor) |dtor| {
         let dtor_body = fld.fold_block(dtor.node.body);
@@ -298,21 +301,21 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
     }
 }
 
-fn fold_trait_ref(&&p: @trait_ref, fld: ast_fold) -> @trait_ref {
+fn fold_trait_ref(&&p: @trait_ref, fld: @ast_fold) -> @trait_ref {
     @ast::trait_ref {
         path: fld.fold_path(p.path),
         ref_id: fld.new_id(p.ref_id),
     }
 }
 
-fn fold_struct_field(&&f: @struct_field, fld: ast_fold) -> @struct_field {
+fn fold_struct_field(&&f: @struct_field, fld: @ast_fold) -> @struct_field {
     @spanned { node: ast::struct_field_ { kind: copy f.node.kind,
                                           id: fld.new_id(f.node.id),
                                           ty: fld.fold_ty(f.node.ty) },
                span: fld.new_span(f.span) }
 }
 
-fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
+fn noop_fold_method(&&m: @method, fld: @ast_fold) -> @method {
     @ast::method {
         ident: fld.fold_ident(m.ident),
         attrs: /* FIXME (#2543) */ copy m.attrs,
@@ -329,7 +332,7 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
 }
 
 
-pub fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ {
+pub fn noop_fold_block(b: blk_, fld: @ast_fold) -> blk_ {
     ast::blk_ {
         view_items: b.view_items.map(|x| fld.fold_view_item(*x)),
         stmts: b.stmts.map(|x| fld.fold_stmt(*x)),
@@ -339,7 +342,7 @@ pub fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ {
     }
 }
 
-fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
+fn noop_fold_stmt(s: stmt_, fld: @ast_fold) -> stmt_ {
     let fold_mac = |x| fold_mac_(x, fld);
     return match s {
       stmt_decl(d, nid) => stmt_decl(fld.fold_decl(d), fld.new_id(nid)),
@@ -349,7 +352,7 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
     };
 }
 
-fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
+fn noop_fold_arm(a: arm, fld: @ast_fold) -> arm {
     arm {
         pats: vec::map(a.pats, |x| fld.fold_pat(*x)),
         guard: option::map(&a.guard, |x| fld.fold_expr(*x)),
@@ -357,7 +360,7 @@ fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
     }
 }
 
-pub fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
+pub fn noop_fold_pat(p: pat_, fld: @ast_fold) -> pat_ {
     return match p {
           pat_wild => pat_wild,
           pat_ident(binding_mode, pth, sub) => {
@@ -403,7 +406,7 @@ pub fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
         };
 }
 
-fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ {
+fn noop_fold_decl(d: decl_, fld: @ast_fold) -> decl_ {
     match d {
       decl_local(ls) => decl_local(vec::map(ls, |x| fld.fold_local(*x))),
       decl_item(it) => match fld.fold_item(it) {
@@ -416,13 +419,13 @@ fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ {
 pub fn wrap<T>(f: fn@(T, ast_fold) -> T)
     -> fn@(T, span, ast_fold) -> (T, span)
 {
-    return fn@(x: T, s: span, fld: ast_fold) -> (T, span) {
+    return fn@(x: T, s: span, fld: @ast_fold) -> (T, span) {
         (f(x, fld), s)
     }
 }
 
-pub fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
-    fn fold_field_(field: field, fld: ast_fold) -> field {
+pub fn noop_fold_expr(e: expr_, fld: @ast_fold) -> expr_ {
+    fn fold_field_(field: field, fld: @ast_fold) -> field {
         spanned {
             node: ast::field_ {
                 mutbl: field.node.mutbl,
@@ -533,12 +536,12 @@ pub fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
         }
 }
 
-pub fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
+pub fn noop_fold_ty(t: ty_, fld: @ast_fold) -> ty_ {
     let fold_mac = |x| fold_mac_(x, fld);
-    fn fold_mt(mt: mt, fld: ast_fold) -> mt {
+    fn fold_mt(mt: mt, fld: @ast_fold) -> mt {
         mt { ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl }
     }
-    fn fold_field(f: ty_field, fld: ast_fold) -> ty_field {
+    fn fold_field(f: ty_field, fld: @ast_fold) -> ty_field {
         spanned {
             node: ast::ty_field_ {
                 ident: fld.fold_ident(f.node.ident),
@@ -579,14 +582,14 @@ pub fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
 }
 
 // ...nor do modules
-pub fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
+pub fn noop_fold_mod(m: _mod, fld: @ast_fold) -> _mod {
     ast::_mod {
         view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)),
         items: vec::filter_mapped(m.items, |x| fld.fold_item(*x)),
     }
 }
 
-fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
+fn noop_fold_foreign_mod(nm: foreign_mod, fld: @ast_fold) -> foreign_mod {
     ast::foreign_mod {
         sort: nm.sort,
         abi: nm.abi,
@@ -595,8 +598,8 @@ fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
     }
 }
 
-fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
-    fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg {
+fn noop_fold_variant(v: variant_, fld: @ast_fold) -> variant_ {
+    fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg {
         ast::variant_arg { ty: fld.fold_ty(va.ty), id: fld.new_id(va.id) }
     }
     let fold_variant_arg = |x| fold_variant_arg_(x, fld);
@@ -654,11 +657,11 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
     }
 }
 
-fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident {
+fn noop_fold_ident(&&i: ident, _fld: @ast_fold) -> ident {
     return /* FIXME (#2543) */ copy i;
 }
 
-fn noop_fold_path(&&p: path, fld: ast_fold) -> path {
+fn noop_fold_path(&&p: path, fld: @ast_fold) -> path {
     ast::path { span: fld.new_span(p.span),
                 global: p.global,
                 idents: p.idents.map(|x| fld.fold_ident(*x)),
@@ -666,7 +669,7 @@ fn noop_fold_path(&&p: path, fld: ast_fold) -> path {
                 types: p.types.map(|x| fld.fold_ty(*x)) }
 }
 
-fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
+fn noop_fold_local(l: local_, fld: @ast_fold) -> local_ {
     local_ {
         is_mutbl: l.is_mutbl,
         ty: fld.fold_ty(l.ty),
@@ -712,72 +715,72 @@ pub fn default_ast_fold() -> ast_fold_fns {
           new_span: noop_span};
 }
 
-impl ast_fold for ast_fold_fns {
+impl ast_fold for AstFoldFns {
     /* naturally, a macro to write these would be nice */
-    fn fold_crate(c: crate) -> crate {
-        let (n, s) = (self.fold_crate)(c.node, c.span, self as ast_fold);
+    fn fold_crate(@self, c: crate) -> crate {
+        let (n, s) = (self.fold_crate)(c.node, c.span, self as @ast_fold);
         spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_view_item(&&x: @view_item) ->
+    fn fold_view_item(@self, &&x: @view_item) ->
        @view_item {
         @ast::view_item {
-            node: (self.fold_view_item)(x.node, self as ast_fold),
+            node: (self.fold_view_item)(x.node, self as @ast_fold),
             attrs: vec::map(x.attrs, |a|
-                  fold_attribute_(*a, self as ast_fold)),
+                  fold_attribute_(*a, self as @ast_fold)),
             vis: x.vis,
             span: (self.new_span)(x.span),
         }
     }
-    fn fold_foreign_item(&&x: @foreign_item)
+    fn fold_foreign_item(@self, &&x: @foreign_item)
         -> @foreign_item {
-        return (self.fold_foreign_item)(x, self as ast_fold);
+        return (self.fold_foreign_item)(x, self as @ast_fold);
     }
-    fn fold_item(&&i: @item) -> Option<@item> {
-        return (self.fold_item)(i, self as ast_fold);
+    fn fold_item(@self, &&i: @item) -> Option<@item> {
+        return (self.fold_item)(i, self as @ast_fold);
     }
-    fn fold_struct_field(&&sf: @struct_field) -> @struct_field {
+    fn fold_struct_field(@self, &&sf: @struct_field) -> @struct_field {
         @spanned {
             node: ast::struct_field_ {
                 kind: copy sf.node.kind,
                 id: sf.node.id,
-                ty: (self as ast_fold).fold_ty(sf.node.ty),
+                ty: (self as @ast_fold).fold_ty(sf.node.ty),
             },
             span: (self.new_span)(sf.span),
         }
     }
-    fn fold_item_underscore(i: item_) ->
+    fn fold_item_underscore(@self, i: item_) ->
        item_ {
-        return (self.fold_item_underscore)(i, self as ast_fold);
+        return (self.fold_item_underscore)(i, self as @ast_fold);
     }
-    fn fold_method(&&x: @method)
+    fn fold_method(@self, &&x: @method)
         -> @method {
-        return (self.fold_method)(x, self as ast_fold);
+        return (self.fold_method)(x, self as @ast_fold);
     }
-    fn fold_block(x: blk) -> blk {
-        let (n, s) = (self.fold_block)(x.node, x.span, self as ast_fold);
+    fn fold_block(@self, x: blk) -> blk {
+        let (n, s) = (self.fold_block)(x.node, x.span, self as @ast_fold);
         spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_stmt(&&x: @stmt) -> @stmt {
-        let (n, s) = (self.fold_stmt)(x.node, x.span, self as ast_fold);
+    fn fold_stmt(@self, &&x: @stmt) -> @stmt {
+        let (n, s) = (self.fold_stmt)(x.node, x.span, self as @ast_fold);
         @spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_arm(x: arm) -> arm {
-        return (self.fold_arm)(x, self as ast_fold);
+    fn fold_arm(@self, x: arm) -> arm {
+        return (self.fold_arm)(x, self as @ast_fold);
     }
-    fn fold_pat(&&x: @pat) -> @pat {
-        let (n, s) =  (self.fold_pat)(x.node, x.span, self as ast_fold);
+    fn fold_pat(@self, &&x: @pat) -> @pat {
+        let (n, s) =  (self.fold_pat)(x.node, x.span, self as @ast_fold);
         @pat {
             id: (self.new_id)(x.id),
             node: n,
             span: (self.new_span)(s),
         }
     }
-    fn fold_decl(&&x: @decl) -> @decl {
-        let (n, s) = (self.fold_decl)(x.node, x.span, self as ast_fold);
+    fn fold_decl(@self, &&x: @decl) -> @decl {
+        let (n, s) = (self.fold_decl)(x.node, x.span, self as @ast_fold);
         @spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_expr(&&x: @expr) -> @expr {
-        let (n, s) = (self.fold_expr)(x.node, x.span, self as ast_fold);
+    fn fold_expr(@self, &&x: @expr) -> @expr {
+        let (n, s) = (self.fold_expr)(x.node, x.span, self as @ast_fold);
         @expr {
             id: (self.new_id)(x.id),
             callee_id: (self.new_id)(x.callee_id),
@@ -785,43 +788,45 @@ impl ast_fold for ast_fold_fns {
             span: (self.new_span)(s),
         }
     }
-    fn fold_ty(&&x: @Ty) -> @Ty {
-        let (n, s) = (self.fold_ty)(x.node, x.span, self as ast_fold);
+    fn fold_ty(@self, &&x: @Ty) -> @Ty {
+        let (n, s) = (self.fold_ty)(x.node, x.span, self as @ast_fold);
         @Ty {
             id: (self.new_id)(x.id),
             node: n,
             span: (self.new_span)(s),
         }
     }
-    fn fold_mod(x: _mod) -> _mod {
-        return (self.fold_mod)(x, self as ast_fold);
+    fn fold_mod(@self, x: _mod) -> _mod {
+        return (self.fold_mod)(x, self as @ast_fold);
     }
-    fn fold_foreign_mod(x: foreign_mod) ->
+    fn fold_foreign_mod(@self, x: foreign_mod) ->
        foreign_mod {
-        return (self.fold_foreign_mod)(x, self as ast_fold);
+        return (self.fold_foreign_mod)(x, self as @ast_fold);
     }
-    fn fold_variant(x: variant) ->
+    fn fold_variant(@self, x: variant) ->
        variant {
-        let (n, s) = (self.fold_variant)(x.node, x.span, self as ast_fold);
+        let (n, s) = (self.fold_variant)(x.node, x.span, self as @ast_fold);
         spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_ident(&&x: ident) -> ident {
-        return (self.fold_ident)(x, self as ast_fold);
+    fn fold_ident(@self, &&x: ident) -> ident {
+        return (self.fold_ident)(x, self as @ast_fold);
     }
-    fn fold_path(&&x: @path) -> @path {
-        @(self.fold_path)(*x, self as ast_fold)
+    fn fold_path(@self, &&x: @path) -> @path {
+        @(self.fold_path)(*x, self as @ast_fold)
     }
-    fn fold_local(&&x: @local) -> @local {
-        let (n, s) = (self.fold_local)(x.node, x.span, self as ast_fold);
+    fn fold_local(@self, &&x: @local) -> @local {
+        let (n, s) = (self.fold_local)(x.node, x.span, self as @ast_fold);
         @spanned { node: n, span: (self.new_span)(s) }
     }
-    fn map_exprs(f: fn@(&&v: @expr) -> @expr, e: ~[@expr]) -> ~[@expr] {
+    fn map_exprs(@self,
+                 f: fn@(&&v: @expr) -> @expr,
+                 e: ~[@expr]) -> ~[@expr] {
         (self.map_exprs)(f, e)
     }
-    fn new_id(node_id: ast::node_id) -> node_id {
+    fn new_id(@self, node_id: ast::node_id) -> node_id {
         (self.new_id)(node_id)
     }
-    fn new_span(span: span) -> span {
+    fn new_span(@self, span: span) -> span {
         (self.new_span)(span)
     }
 }
@@ -833,7 +838,7 @@ pub impl ast_fold {
 }
 
 pub fn make_fold(afp: ast_fold_fns) -> ast_fold {
-    afp as ast_fold
+    afp as @ast_fold
 }
 
 //
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 057412fcd7e..923bc738cf0 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -251,7 +251,7 @@ mod test {
             @~"fn foo (x : int) { x; }",
             ~[],
             new_parse_sess(None));
-        check_equal(to_json_str(tts as Encodable::<std::json::Encoder>),
+        check_equal(to_json_str(@tts as Encodable::<std::json::Encoder>),
                     ~"[[\"tt_tok\",[,[\"IDENT\",[\"fn\",false]]]],\
                       [\"tt_tok\",[,[\"IDENT\",[\"foo\",false]]]],\
                       [\"tt_delim\",[[[\"tt_tok\",[,[\"LPAREN\",[]]]],\
diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs
index 7cc8dcb22c9..afe7d4a6e8b 100644
--- a/src/test/auxiliary/issue-2380.rs
+++ b/src/test/auxiliary/issue-2380.rs
@@ -16,5 +16,5 @@ pub trait i<T> { }
 pub fn f<T>() -> i<T> {
     impl<T> i<T> for () { }
 
-    () as i::<T>
+    @() as @i<T>
 }
diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs
index 5e472712fda..a52b7889017 100644
--- a/src/test/bench/shootout-mandelbrot.rs
+++ b/src/test/bench/shootout-mandelbrot.rs
@@ -112,7 +112,7 @@ fn writer(path: ~str, pport: comm::Port<Line>, size: uint)
 {
     let cout: io::Writer = match path {
         ~"" => {
-            Devnull as io::Writer
+            @Devnull as @io::Writer
         }
         ~"-" => {
             io::stdout()
diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs
index 3169b0299a0..092fb4a5b66 100644
--- a/src/test/compile-fail/class-cast-to-trait.rs
+++ b/src/test/compile-fail/class-cast-to-trait.rs
@@ -58,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
 }
 
 fn main() {
-  let nyan : noisy  = cat(0, 2, ~"nyan") as noisy;
+  let nyan : noisy  = @cat(0, 2, ~"nyan") as @noisy;
   nyan.eat(); //~ ERROR type `@noisy` does not implement any method in scope named `eat`
 }
diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs
index 2864e27f42f..f369e765d69 100644
--- a/src/test/compile-fail/kindck-owned-trait-contains.rs
+++ b/src/test/compile-fail/kindck-owned-trait-contains.rs
@@ -16,7 +16,7 @@ impl<A:Copy> repeat<A> for @A {
 
 fn repeater<A:Copy>(v: @A) -> repeat<A> {
     // Note: owned kind is not necessary as A appears in the trait type
-    v as repeat::<A> // No
+    @v as repeat::<A> // No
 }
 
 fn main() {
diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs
index f11703ecf02..2e0f2774861 100644
--- a/src/test/compile-fail/kindck-owned-trait-scoped.rs
+++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs
@@ -26,7 +26,7 @@ fn to_foo<T:Copy>(t: T) {
     // the fn body itself.
     let v = &3;
     struct F<T> { f: T }
-    let x = F {f:t} as foo;
+    let x = @F {f:t} as foo;
     assert x.foo(v) == 3;
 }
 
@@ -34,14 +34,14 @@ fn to_foo_2<T:Copy>(t: T) -> foo {
     // Not OK---T may contain borrowed ptrs and it is going to escape
     // as part of the returned foo value
     struct F<T> { f: T }
-    F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound
+    @F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound
 }
 
 fn to_foo_3<T:Copy + &static>(t: T) -> foo {
     // OK---T may escape as part of the returned foo value, but it is
     // owned and hence does not contain borrowed ptrs
     struct F<T> { f: T }
-    F {f:t} as foo
+    @F {f:t} as foo
 }
 
 fn main() {
diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs
index 2bc6a911204..30f6a5f9b2d 100644
--- a/src/test/compile-fail/kindck-owned-trait.rs
+++ b/src/test/compile-fail/kindck-owned-trait.rs
@@ -11,11 +11,11 @@
 trait foo { fn foo(); }
 
 fn to_foo<T:Copy + foo>(t: T) -> foo {
-    t as foo //~ ERROR value may contain borrowed pointers; use `&static` bound
+    @t as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound
 }
 
 fn to_foo2<T:Copy + foo + &static>(t: T) -> foo {
-    t as foo
+    @t as @foo
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs
index f829c730637..8512e8d13dc 100644
--- a/src/test/compile-fail/map-types.rs
+++ b/src/test/compile-fail/map-types.rs
@@ -14,8 +14,8 @@ use core::hashmap::linear::LinearMap;
 // Test that trait types printed in error msgs include the type arguments.
 
 fn main() {
-    let x: Map<~str, ~str> = LinearMap::new::<~str, ~str>() as
+    let x: @Map<~str, ~str> = @LinearMap::new::<~str, ~str>() as
         Map::<~str, ~str>;
-    let y: Map<uint, ~str> = x;
+    let y: @Map<uint, ~str> = @x;
     //~^ ERROR mismatched types: expected `@core::container::Map/&<uint,~str>`
 }
diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs
index 4a78fdf9714..811d7c452e3 100644
--- a/src/test/compile-fail/regions-trait-1.rs
+++ b/src/test/compile-fail/regions-trait-1.rs
@@ -34,5 +34,5 @@ fn get_v(gc: get_ctxt) -> uint {
 fn main() {
     let ctxt = ctxt { v: 22u };
     let hc = has_ctxt { c: &ctxt };
-    assert get_v(hc as get_ctxt) == 22u;
+    assert get_v(@hc as get_ctxt) == 22u;
 }
diff --git a/src/test/compile-fail/regions-trait-2.rs b/src/test/compile-fail/regions-trait-2.rs
index 2cb1f9deb49..c5978e55fb3 100644
--- a/src/test/compile-fail/regions-trait-2.rs
+++ b/src/test/compile-fail/regions-trait-2.rs
@@ -23,7 +23,7 @@ impl get_ctxt for has_ctxt {
 fn make_gc() -> get_ctxt  {
     let ctxt = ctxt { v: 22u };
     let hc = has_ctxt { c: &ctxt }; //~ ERROR illegal borrow
-    return hc as get_ctxt;
+    return @hc as get_ctxt;
 }
 
 fn main() {
diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs
index d62d6cace3e..0ddaf25710c 100644
--- a/src/test/compile-fail/regions-trait-3.rs
+++ b/src/test/compile-fail/regions-trait-3.rs
@@ -17,7 +17,7 @@ fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b  {
 }
 
 fn make_gc2(gc: get_ctxt/&a) -> get_ctxt/&b  {
-    return gc as get_ctxt; //~ ERROR cannot infer an appropriate lifetime
+    return @gc as get_ctxt; //~ ERROR cannot infer an appropriate lifetime
 }
 
 fn main() {
diff --git a/src/test/compile-fail/selftype-astparam.rs b/src/test/compile-fail/selftype-astparam.rs
index c89d1d2795b..08b6c0f71fe 100644
--- a/src/test/compile-fail/selftype-astparam.rs
+++ b/src/test/compile-fail/selftype-astparam.rs
@@ -19,7 +19,7 @@ impl add for int {
 fn do_add<A:add>(x: A, y: A) -> A { x.plus(y) }
 
 fn main() {
-    let x = 3 as add;
-    let y = 4 as add;
+    let x = @3 as @add;
+    let y = @4 as @add;
     do_add(x, y); //~ ERROR a boxed trait with self types may not be passed as a bounded type
 }
diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs
index 60da6d2208a..94bcea8f1d3 100644
--- a/src/test/compile-fail/tps-invariant-trait.rs
+++ b/src/test/compile-fail/tps-invariant-trait.rs
@@ -34,7 +34,7 @@ fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
 
 fn main() {
     let b = box_impl::<@int>(box::<@int> {f: @3});
-    set_box_trait(b as box_trait::<@int>, @mut 5);
+    set_box_trait(@b as box_trait::<@int>, @mut 5);
     //~^ ERROR values differ in mutability
     set_box_impl(b, @mut 5);
     //~^ ERROR values differ in mutability
diff --git a/src/test/compile-fail/trait-cast.rs b/src/test/compile-fail/trait-cast.rs
index 7b2fc2165b4..d0738be09c7 100644
--- a/src/test/compile-fail/trait-cast.rs
+++ b/src/test/compile-fail/trait-cast.rs
@@ -11,7 +11,7 @@
 trait foo<T> { }
 
 fn bar(x: foo<uint>) -> foo<int> {
-    return (x as foo::<int>);
+    return (@x as foo::<int>);
     //~^ ERROR mismatched types: expected `@foo<int>` but found `@foo<uint>`
     //~^^ ERROR mismatched types: expected `@foo<int>` but found `@foo<uint>`
     // This is unfortunate -- new handling of parens means the error message
diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs
index 73b7c4369ac..a00e63b60d7 100644
--- a/src/test/compile-fail/trait-test-2.rs
+++ b/src/test/compile-fail/trait-test-2.rs
@@ -15,5 +15,5 @@ impl bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
 fn main() {
     10i.dup::<int>(); //~ ERROR does not take type parameters
     10i.blah::<int, int>(); //~ ERROR incorrect number of type parameters
-    (10 as bar).dup(); //~ ERROR contains a self-type
+    (@10 as bar).dup(); //~ ERROR contains a self-type
 }
diff --git a/src/test/run-fail/unwind-box-trait.rs b/src/test/run-fail/unwind-box-trait.rs
index b17fc467f0b..905670f8fb7 100644
--- a/src/test/run-fail/unwind-box-trait.rs
+++ b/src/test/run-fail/unwind-box-trait.rs
@@ -23,7 +23,7 @@ impl i for ~int {
 }
 
 fn main() {
-    let x = ~0 as i;
+    let x = @~0 as @i;
     failfn();
     log(error, x);
 }
diff --git a/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs b/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs
index b44d1cbb78d..bfde19993e9 100644
--- a/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs
+++ b/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs
@@ -21,6 +21,6 @@ fn is_equal<D:double>(x: @D, exp: uint) {
 }
 
 pub fn main() {
-    let x = @(3u as double);
+    let x = @(@3u as @double);
     is_equal(x, 6);
 }
diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs
index 3653c0eb9c9..65a274d7764 100644
--- a/src/test/run-pass/autoderef-method-on-trait.rs
+++ b/src/test/run-pass/autoderef-method-on-trait.rs
@@ -17,6 +17,6 @@ impl double for uint {
 }
 
 pub fn main() {
-    let x = @(3u as double);
+    let x = @(@3u as @double);
     assert x.double() == 6u;
 }
diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/run-pass/boxed-trait-with-vstore.rs
index 50e137d6fd5..1d2c30108f1 100644
--- a/src/test/run-pass/boxed-trait-with-vstore.rs
+++ b/src/test/run-pass/boxed-trait-with-vstore.rs
@@ -19,7 +19,7 @@ impl Foo for int {
 }
 
 pub fn main() {
-    let x = 3 as @Foo;
+    let x = @3 as @Foo;
     x.foo();
 }
 
diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
index f81b12b555e..1db3d4b38d7 100644
--- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
+++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
@@ -21,7 +21,7 @@ fn print_out<T:ToStr>(thing: T, expected: ~str) {
 }
 
 pub fn main() {
-  let nyan : ToStr  = cat(0u, 2, ~"nyan") as ToStr;
+  let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr;
   print_out(nyan, ~"nyan");
 }
 
diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs
index 7c5d5c4d126..5cf68174075 100644
--- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs
+++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs
@@ -86,8 +86,8 @@ fn annoy_neighbors<T:noisy>(critter: T) {
 pub fn main() {
   let nyan : cat  = cat(0u, 2, ~"nyan");
   let whitefang : dog = dog();
-  annoy_neighbors((copy nyan) as noisy);
-  annoy_neighbors((copy whitefang) as noisy);
+  annoy_neighbors(@(copy nyan) as @noisy);
+  annoy_neighbors(@(copy whitefang) as @noisy);
   assert(nyan.meow_count() == 10u);
   assert(*whitefang.volume == 1);
 }
diff --git a/src/test/run-pass/class-cast-to-trait.rs b/src/test/run-pass/class-cast-to-trait.rs
index 581361c154c..a15afa60c75 100644
--- a/src/test/run-pass/class-cast-to-trait.rs
+++ b/src/test/run-pass/class-cast-to-trait.rs
@@ -56,6 +56,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
 
 
 pub fn main() {
-  let mut nyan: noisy = cat(0u, 2, ~"nyan") as noisy;
+  let mut nyan: @noisy = @cat(0u, 2, ~"nyan") as @noisy;
   nyan.speak();
 }
diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs
index 728deff8e2d..b232be32550 100644
--- a/src/test/run-pass/class-separate-impl.rs
+++ b/src/test/run-pass/class-separate-impl.rs
@@ -63,6 +63,6 @@ fn print_out<T:ToStr>(thing: T, expected: ~str) {
 }
 
 pub fn main() {
-  let mut nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr;
+  let mut nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr;
   print_out(nyan, ~"nyan");
 }
diff --git a/src/test/run-pass/explicit-self-objects-ext-1.rs b/src/test/run-pass/explicit-self-objects-ext-1.rs
index e226423f848..92f745d7d53 100644
--- a/src/test/run-pass/explicit-self-objects-ext-1.rs
+++ b/src/test/run-pass/explicit-self-objects-ext-1.rs
@@ -34,6 +34,6 @@ impl Reader for S {
 
 pub fn main() {
     let x = S { x: 1, y: 2 };
-    let x = x as @Reader;
+    let x = @x as @Reader;
     x.read_bytes(0);
 }
diff --git a/src/test/run-pass/explicit-self-objects-ext-2.rs b/src/test/run-pass/explicit-self-objects-ext-2.rs
index e226423f848..92f745d7d53 100644
--- a/src/test/run-pass/explicit-self-objects-ext-2.rs
+++ b/src/test/run-pass/explicit-self-objects-ext-2.rs
@@ -34,6 +34,6 @@ impl Reader for S {
 
 pub fn main() {
     let x = S { x: 1, y: 2 };
-    let x = x as @Reader;
+    let x = @x as @Reader;
     x.read_bytes(0);
 }
diff --git a/src/test/run-pass/explicit-self-objects-ext-3.rs b/src/test/run-pass/explicit-self-objects-ext-3.rs
index 1a18ee7c6f7..2cfd327dc4e 100644
--- a/src/test/run-pass/explicit-self-objects-ext-3.rs
+++ b/src/test/run-pass/explicit-self-objects-ext-3.rs
@@ -34,6 +34,6 @@ impl Reader for S {
 
 pub fn main() {
     let x = S { x: 1, y: 2 };
-    let x = x as @Reader;
+    let x = @x as @Reader;
     x.read_bytes(0);
 }
diff --git a/src/test/run-pass/explicit-self-objects-ext-4.rs b/src/test/run-pass/explicit-self-objects-ext-4.rs
index a5d934d9984..3945be77904 100644
--- a/src/test/run-pass/explicit-self-objects-ext-4.rs
+++ b/src/test/run-pass/explicit-self-objects-ext-4.rs
@@ -34,6 +34,6 @@ impl Reader for S {
 
 pub fn main() {
     let x = S { x: 1, y: 2 };
-    let x = x as @Reader;
+    let x = @x as @Reader;
     x.read_bytes(0);
 }
diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs
index 375259baaf5..85ed524118b 100644
--- a/src/test/run-pass/issue-2288.rs
+++ b/src/test/run-pass/issue-2288.rs
@@ -33,6 +33,6 @@ fn f<A:Copy>(x: clam<A>, a: A) {
 pub fn main() {
 
   let c = foo(42);
-  let d: clam<int> = c as clam::<int>;
+  let d: clam<int> = @c as clam::<int>;
   f(d, c.x);
 }
diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs
index 45c6b22544d..a76d2242b40 100644
--- a/src/test/run-pass/issue-2734.rs
+++ b/src/test/run-pass/issue-2734.rs
@@ -12,7 +12,7 @@ trait hax { }
 impl<A> hax for A { } 
 
 fn perform_hax<T:&static>(x: @T) -> hax {
-    x as hax 
+    @x as @hax
 }
 
 fn deadcode() {
diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs
index 7c87c6a31cd..14e27dce63d 100644
--- a/src/test/run-pass/issue-2735.rs
+++ b/src/test/run-pass/issue-2735.rs
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-trait hax { } 
-impl<A> hax for A { } 
+trait hax { }
+impl<A> hax for A { }
 
 fn perform_hax<T:&static>(x: @T) -> hax {
-    x as hax 
+    @x as @hax
 }
 
 fn deadcode() {
diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs
index 9106d39c592..3ed7d2f842d 100644
--- a/src/test/run-pass/issue-2904.rs
+++ b/src/test/run-pass/issue-2904.rs
@@ -60,7 +60,7 @@ fn square_from_char(c: char) -> square {
 }
 
 fn read_board_grid<rdr: &static + io::Reader>(+in: rdr) -> ~[~[square]] {
-    let in = (in) as io::Reader;
+    let in = @in as @io::Reader;
     let mut grid = ~[];
     for in.each_line |line| {
         let mut row = ~[];
diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs
index 82089dd3bed..64af4de46a2 100644
--- a/src/test/run-pass/issue-2935.rs
+++ b/src/test/run-pass/issue-2935.rs
@@ -25,7 +25,7 @@ pub fn main() {
   //   let y = @({a: 4i});
   //    let z = @({a: 4i} as it);
   //    let z = @({a: true} as it);
-    let z = @(true as it);
+    let z = @(@true as it);
     //  x.f();
     // y.f();
     // (*z).f();
diff --git a/src/test/run-pass/issue-3305.rs b/src/test/run-pass/issue-3305.rs
index b44d1cbb78d..bfde19993e9 100644
--- a/src/test/run-pass/issue-3305.rs
+++ b/src/test/run-pass/issue-3305.rs
@@ -21,6 +21,6 @@ fn is_equal<D:double>(x: @D, exp: uint) {
 }
 
 pub fn main() {
-    let x = @(3u as double);
+    let x = @(@3u as @double);
     is_equal(x, 6);
 }
diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs
index 351f68ab37c..0ef09d39663 100644
--- a/src/test/run-pass/kindck-owned-trait-contains-1.rs
+++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs
@@ -16,7 +16,7 @@ impl<A:Copy> repeat<A> for @A {
 
 fn repeater<A:Copy>(v: @A) -> repeat<A> {
     // Note: owned kind is not necessary as A appears in the trait type
-    v as repeat::<A> // No
+    @v as repeat::<A> // No
 }
 
 pub fn main() {
diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs
index 98e42bd7b4d..c472e530584 100644
--- a/src/test/run-pass/reflect-visit-data.rs
+++ b/src/test/run-pass/reflect-visit-data.rs
@@ -489,7 +489,7 @@ pub impl my_visitor {
         unsafe {
             let u = my_visitor(*self);
             let v = ptr_visit_adaptor::<my_visitor>(Inner {inner: u});
-            visit_tydesc(inner, v as TyVisitor);
+            visit_tydesc(inner, @v as @TyVisitor);
             true
         }
     }
@@ -644,7 +644,7 @@ pub fn main() {
         let td = get_tydesc_for(r);
         unsafe { error!("tydesc sz: %u, align: %u",
                         (*td).size, (*td).align); }
-        let v = v as TyVisitor;
+        let v = @v as @TyVisitor;
         visit_tydesc(td, v);
 
         for (copy u.vals).each |s| {
diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs
index e45a0d252c6..2b9930778b2 100644
--- a/src/test/run-pass/regions-trait.rs
+++ b/src/test/run-pass/regions-trait.rs
@@ -30,5 +30,5 @@ pub fn main() {
     let ctxt = Ctxt { v: 22 };
     let hc = HasCtxt { c: &ctxt };
 
-    assert get_v(hc as get_ctxt) == 22;
+    assert get_v(@hc as @get_ctxt) == 22;
 }