]> git.lizzy.rs Git - rust.git/commitdiff
Make object types not implement associated trait. Fixes #5087.
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 5 Mar 2013 22:49:50 +0000 (17:49 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 6 Mar 2013 16:02:19 +0000 (11:02 -0500)
22 files changed:
src/libcore/io.rs
src/librustc/middle/astencode.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/meth.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/check/writeback.rs
src/librustc/middle/typeck/mod.rs
src/test/compile-fail/object-does-not-impl-trait.rs [new file with mode: 0644]
src/test/compile-fail/regions-trait-3.rs
src/test/compile-fail/selftype-astparam.rs [deleted file]
src/test/compile-fail/trait-cast.rs [deleted file]
src/test/run-pass/autoderef-method-on-trait-monomorphized.rs [deleted file]
src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
src/test/run-pass/class-cast-to-trait-multiple-types.rs
src/test/run-pass/class-separate-impl.rs
src/test/run-pass/explicit-self-objects-ext-1.rs [deleted file]
src/test/run-pass/explicit-self-objects-ext-2.rs [deleted file]
src/test/run-pass/explicit-self-objects-ext-3.rs [deleted file]
src/test/run-pass/explicit-self-objects-ext-4.rs [deleted file]
src/test/run-pass/issue-2611.rs
src/test/run-pass/issue-3305.rs [deleted file]

index 27456fbe160435610a851f25df282f5bccb5c0a4..65879f88a5dad63dae45bd2c6f8d24cb2b0488b2 100644 (file)
@@ -69,6 +69,26 @@ pub trait Reader {
     fn tell(&self) -> uint;
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Reader for @Reader {
+    fn read(&self, bytes: &mut [u8], len: uint) -> uint {
+        self.read(bytes, len)
+    }
+    fn read_byte(&self) -> int {
+        self.read_byte()
+    }
+    fn eof(&self) -> bool {
+        self.eof()
+    }
+    fn seek(&self, position: int, style: SeekStyle) {
+        self.seek(position, style)
+    }
+    fn tell(&self) -> uint {
+        self.tell()
+    }
+}
+
 /// Generic utility functions defined on readers.
 pub trait ReaderUtil {
 
@@ -631,6 +651,16 @@ pub trait Writer {
     fn get_type(&self) -> WriterType;
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Writer for @Writer {
+    fn write(&self, v: &[const u8]) { self.write(v) }
+    fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) }
+    fn tell(&self) -> uint { self.tell() }
+    fn flush(&self) -> int { self.flush() }
+    fn get_type(&self) -> WriterType { self.get_type() }
+}
+
 impl<W:Writer,C> Writer for Wrapper<W, C> {
     fn write(&self, bs: &[const u8]) { self.base.write(bs); }
     fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); }
@@ -1067,8 +1097,8 @@ pub fn buffered_file_writer(path: &Path) -> Result<Writer, ~str> {
 // FIXME (#2004) it would be great if this could be a const
 // FIXME (#2004) why are these different from the way stdin() is
 // implemented?
-pub fn stdout() -> Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
-pub fn stderr() -> Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
+pub fn stdout() -> @Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
+pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
 
 pub fn print(s: &str) { stdout().write_str(s); }
 pub fn println(s: &str) { stdout().write_line(s); }
index 0fb587dfc9a6263788df63405774d1a39ea4aa30..e418aa35e1e861e69d2adbda6eafb73b05c84695 100644 (file)
@@ -664,16 +664,6 @@ fn encode_vtable_origin(ecx: @e::EncodeContext,
                 }
             }
           }
-          typeck::vtable_trait(def_id, tys) => {
-            do ebml_w.emit_enum_variant(~"vtable_trait", 1u, 3u) {
-                do ebml_w.emit_enum_variant_arg(0u) {
-                    ebml_w.emit_def_id(def_id)
-                }
-                do ebml_w.emit_enum_variant_arg(1u) {
-                    ebml_w.emit_tys(ecx, /*bad*/copy tys);
-                }
-            }
-          }
         }
     }
 
@@ -720,16 +710,6 @@ fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext)
                         }
                     )
                   }
-                  2 => {
-                    typeck::vtable_trait(
-                        do self.read_enum_variant_arg(0u) {
-                            self.read_def_id(xcx)
-                        },
-                        do self.read_enum_variant_arg(1u) {
-                            self.read_tys(xcx)
-                        }
-                    )
-                  }
                   // hard to avoid - user input
                   _ => fail!(~"bad enum variant")
                 }
index f3ac11771975bba4cabee179c47d91239b1a281e..33b52c6e6b6ca9edd3a391a9a5dab3f276ca19b8 100644 (file)
@@ -1405,7 +1405,6 @@ pub fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, +vt: typeck::vtable_origin)
                 }
             }
         }
-        vt => vt
     }
 }
 
index 917960f7a27a729d2a4698b39d2b9e8687fbf3a4..2f4e8d715e0a000f8296f658e501eb3bf33cf1b0 100644 (file)
@@ -478,14 +478,6 @@ pub fn trans_monomorphized_callee(bcx: block,
               })
           }
       }
-      typeck::vtable_trait(_, _) => {
-          trans_trait_callee(bcx,
-                             callee_id,
-                             n_method,
-                             base,
-                             ty::vstore_box,
-                             mentry.explicit_self)
-      }
       typeck::vtable_param(*) => {
           fail!(~"vtable_param left in monomorphized function's " +
               "vtable substs");
@@ -756,13 +748,7 @@ pub fn vtable_id(ccx: @CrateContext,
                 None,
                 None)
         }
-        typeck::vtable_trait(trait_id, substs) => {
-            @mono_id_ {
-                def: trait_id,
-                params: vec::map(substs, |t| mono_precise(*t, None)),
-                impl_did_opt: None
-            }
-        }
+
         // can't this be checked at the callee?
         _ => fail!(~"vtable_id")
     }
index b269e594395951d1816405c07cef62a4beb5a710..5d0b3f948e2d20236e485f954bf3320fbbc2d7ec 100644 (file)
@@ -30,7 +30,7 @@ impl like `impl Foo` are inherent methods.  Nothing needs to be
 module as the type itself).
 
 Inherent candidates are not always derived from impls.  If you have a
-trait instance, such as a value of type `ToStr`, then the trait
+trait instance, such as a value of type `@ToStr`, then the trait
 methods (`to_str()`, in this case) are inherently associated with it.
 Another case is type parameters, in which case the methods of their
 bounds are inherent.
@@ -1221,7 +1221,7 @@ fn report_candidate(&self, idx: uint, origin: &method_origin) {
             }
             method_trait(trait_did, _, _) | method_self(trait_did, _)
                 | method_super(trait_did, _) => {
-                self.report_param_candidate(idx, trait_did)
+                self.report_trait_candidate(idx, trait_did)
             }
         }
     }
index da2b80364771ec9872d38264b3e57a848794e39d..fa17c9438a22383eab3ca8f22f49704b16c003b4 100644 (file)
@@ -18,7 +18,7 @@
 use middle::typeck::infer::{resolve_and_force_all_but_regions, resolve_type};
 use middle::typeck::infer;
 use middle::typeck::{CrateCtxt, vtable_origin, vtable_param, vtable_res};
-use middle::typeck::{vtable_static, vtable_trait};
+use middle::typeck::{vtable_static};
 use util::common::indenter;
 use util::ppaux::tys_to_str;
 use util::ppaux;
@@ -81,7 +81,6 @@ pub fn lookup_vtables(vcx: &VtableContext,
                       location_info: &LocationInfo,
                       bounds: @~[ty::param_bounds],
                       substs: &ty::substs,
-                      allow_unsafe: bool,
                       is_early: bool) -> vtable_res {
     debug!("lookup_vtables(location_info=%?,
             # bounds=%?, \
@@ -110,8 +109,7 @@ pub fn lookup_vtables(vcx: &VtableContext,
             debug!("after subst: %?",
                    ppaux::ty_to_str(tcx, trait_ty));
 
-            match lookup_vtable(vcx, location_info, *ty, trait_ty,
-                                allow_unsafe, is_early) {
+            match lookup_vtable(vcx, location_info, *ty, trait_ty, is_early) {
                 Some(vtable) => result.push(vtable),
                 None => {
                     vcx.tcx().sess.span_fatal(
@@ -162,7 +160,6 @@ pub fn lookup_vtable(vcx: &VtableContext,
                      location_info: &LocationInfo,
                      ty: ty::t,
                      trait_ty: ty::t,
-                     allow_unsafe: bool,
                      is_early: bool)
                   -> Option<vtable_origin> {
     debug!("lookup_vtable(ty=%s, trait_ty=%s)",
@@ -224,30 +221,6 @@ pub fn lookup_vtable(vcx: &VtableContext,
             }
         }
 
-        ty::ty_trait(did, ref substs, _) if trait_id == did => {
-            debug!("(checking vtable) @1 relating ty to trait ty with did %?",
-                   did);
-
-            relate_trait_tys(vcx, location_info, trait_ty, ty);
-            if !allow_unsafe && !is_early {
-                for vec::each(*ty::trait_methods(tcx, did)) |m| {
-                    if ty::type_has_self(ty::mk_bare_fn(tcx, copy m.fty)) {
-                        tcx.sess.span_err(
-                            location_info.span,
-                            ~"a boxed trait with self types may not be \
-                              passed as a bounded type");
-                    } else if (*m.tps).len() > 0u {
-                        tcx.sess.span_err(
-                            location_info.span,
-                            ~"a boxed trait with generic methods may not \
-                              be passed as a bounded type");
-
-                    }
-                }
-            }
-            return Some(vtable_trait(did, /*bad*/copy (*substs).tps));
-        }
-
         _ => {
             let mut found = ~[];
 
@@ -411,7 +384,7 @@ pub fn lookup_vtable(vcx: &VtableContext,
                                               trait_vstore);
                             let subres = lookup_vtables(
                                 vcx, location_info, im_bs, &substs_f,
-                                false, is_early);
+                                is_early);
 
                             // Finally, we register that we found a
                             // matching impl, and record the def ID of
@@ -542,8 +515,7 @@ pub fn early_resolve_expr(ex: @ast::expr,
                 }
                 let vcx = VtableContext { ccx: fcx.ccx, infcx: fcx.infcx() };
                 let vtbls = lookup_vtables(&vcx, &location_info_for_expr(ex),
-                                           item_ty.bounds, substs, false,
-                                           is_early);
+                                           item_ty.bounds, substs, is_early);
                 if !is_early {
                     let vtable_map = cx.vtable_map;
                     vtable_map.insert(ex.id, vtbls);
@@ -573,7 +545,7 @@ pub fn early_resolve_expr(ex: @ast::expr,
                 let substs = fcx.node_ty_substs(callee_id);
                 let vcx = VtableContext { ccx: fcx.ccx, infcx: fcx.infcx() };
                 let vtbls = lookup_vtables(&vcx, &location_info_for_expr(ex),
-                                           bounds, &substs, false, is_early);
+                                           bounds, &substs, is_early);
                 if !is_early {
                     insert_vtables(cx, callee_id, vtbls);
                 }
@@ -607,7 +579,6 @@ pub fn early_resolve_expr(ex: @ast::expr,
                                             location_info,
                                             mt.ty,
                                             target_ty,
-                                            true,
                                             is_early);
                           match vtable_opt {
                               Some(vtable) => {
index 00f757412f6af4ab318d4f46a961b1ade4c98f2b..5cfb7973b96a0934a9eb1b24f5f5d30c8cabafe4 100644 (file)
@@ -22,7 +22,7 @@
 use middle::typeck::infer::{resolve_type};
 use middle::typeck::infer;
 use middle::typeck::method_map_entry;
-use middle::typeck::{vtable_param, vtable_trait, write_substs_to_tcx};
+use middle::typeck::{vtable_param, write_substs_to_tcx};
 use middle::typeck::{write_ty_to_tcx};
 use util::ppaux;
 
index b7d60817627fd88c0c461630f19e7cf98aeeae69..81094e3fb97e3a1a70d4d30090f2e5f6ad2ab6eb 100644 (file)
@@ -150,12 +150,7 @@ fn foo<T:quux,baz,bar>(a: T) -- a's vtable would have a
       The first uint is the param number (identifying T in the example),
       and the second is the bound number (identifying baz)
      */
-    vtable_param(uint, uint),
-    /*
-      Dynamic vtable, comes from something known to have a trait
-      type. def_id refers to the trait item, tys are the substs
-     */
-    vtable_trait(ast::def_id, ~[ty::t]),
+    vtable_param(uint, uint)
 }
 
 pub impl vtable_origin {
@@ -171,12 +166,6 @@ fn to_str(&self, tcx: ty::ctxt) -> ~str {
             vtable_param(x, y) => {
                 fmt!("vtable_param(%?, %?)", x, y)
             }
-
-            vtable_trait(def_id, ref tys) => {
-                fmt!("vtable_trait(%?:%s, %?)",
-                     def_id, ty::item_path_str(tcx, def_id),
-                     tys.map(|t| ppaux::ty_to_str(tcx, *t)))
-            }
         }
     }
 }
diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs
new file mode 100644 (file)
index 0000000..886b849
--- /dev/null
@@ -0,0 +1,17 @@
+// 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.
+
+// Test that an object type `@Foo` is not considered to implement the
+// trait `Foo`. Issue #5087.
+
+trait Foo {}
+fn take_foo<F:Foo>(f: F) {}
+fn take_object(f: @Foo) { take_foo(f); } //~ ERROR failed to find an implementation of trait
+fn main() {}
index 0ddaf25710c94ec16c697e07ab604232a7f0a8e7..a10c239617ec96a107ca7395fd249e17b17533cb 100644 (file)
@@ -16,8 +16,16 @@ fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b  {
     return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b` but found `@get_ctxt/&a`
 }
 
-fn make_gc2(gc: get_ctxt/&a) -> get_ctxt/&b  {
-    return @gc as get_ctxt; //~ ERROR cannot infer an appropriate lifetime
+struct Foo {
+    r: &'self uint
+}
+
+impl get_ctxt/&self for Foo/&self {
+    fn get_ctxt() -> &self/uint { self.r }
+}
+
+fn make_gc2(foo: Foo/&a) -> get_ctxt/&b  {
+    return @foo 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
deleted file mode 100644 (file)
index 08b6c0f..0000000
+++ /dev/null
@@ -1,25 +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 add {
-    fn plus(++x: Self) -> Self;
-}
-
-impl add for int {
-    fn plus(++x: int) -> int { self + x }
-}
-
-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;
-    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/trait-cast.rs b/src/test/compile-fail/trait-cast.rs
deleted file mode 100644 (file)
index d0738be..0000000
+++ /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.
-
-trait foo<T> { }
-
-fn bar(x: foo<uint>) -> 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
-    // gets printed twice
-}
-
-fn main() {}
diff --git a/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs b/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs
deleted file mode 100644 (file)
index bfde199..0000000
+++ /dev/null
@@ -1,26 +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 double {
-    fn double() -> uint;
-}
-
-impl double for uint {
-    fn double() -> uint { self * 2u }
-}
-
-fn is_equal<D:double>(x: @D, exp: uint) {
-    assert x.double() == exp;
-}
-
-pub fn main() {
-    let x = @(@3u as @double);
-    is_equal(x, 6);
-}
index 1db3d4b38d7978db70acf38b9ffd57d69b5985c9..53c50d7fca0c43d0a42ac8de61d38a67843e52bc 100644 (file)
@@ -14,7 +14,7 @@
 use core::to_str::ToStr;
 use cci_class_cast::kitty::*;
 
-fn print_out<T:ToStr>(thing: T, expected: ~str) {
+fn print_out(thing: @ToStr, expected: ~str) {
   let actual = thing.to_str();
   debug!("%s", actual);
   assert(actual == expected);
index 5cf68174075fac58fd886ab8965fad8e2f95a3f6..39466bb8c16700f214b09fdc5d263db977012c2d 100644 (file)
@@ -79,7 +79,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
 }
 
 
-fn annoy_neighbors<T:noisy>(critter: T) {
+fn annoy_neighbors(critter: @noisy) {
   for uint::range(0u, 10u) |i| { critter.speak(); }
 }
 
index b232be3255025ef7e6145ad507fc3a897538dfb5..eb0d8de7eab8901ad19f376ec49341b5b507c121 100644 (file)
@@ -56,7 +56,7 @@ impl ToStr for cat {
   pure fn to_str(&self) -> ~str { copy self.name }
 }
 
-fn print_out<T:ToStr>(thing: T, expected: ~str) {
+fn print_out(thing: @ToStr, expected: ~str) {
   let actual = thing.to_str();
   debug!("%s", actual);
   assert(actual == expected);
diff --git a/src/test/run-pass/explicit-self-objects-ext-1.rs b/src/test/run-pass/explicit-self-objects-ext-1.rs
deleted file mode 100644 (file)
index 92f745d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-pub trait Reader {
-    // FIXME (#2004): Seekable really should be orthogonal.
-
-    /// Read up to len bytes (or EOF) and put them into bytes (which
-    /// must be at least len bytes long). Return number of bytes read.
-    // FIXME (#2982): This should probably return an error.
-    fn read(&self, bytes: &mut [u8], len: uint) -> uint;
-}
-
-pub trait ReaderUtil {
-
-    /// Read len bytes into a new vec.
-    fn read_bytes(&self, len: uint);
-}
-
-impl<T:Reader> ReaderUtil for T {
-
-    fn read_bytes(&self, len: uint) {
-        let mut count = self.read(&mut [0], len);
-    }
-
-}
-
-struct S {
-    x: int,
-    y: int
-}
-
-impl Reader for S {
-    fn read(&self, bytes: &mut [u8], len: uint) -> uint {
-        0
-    }
-}
-
-pub fn main() {
-    let x = S { x: 1, y: 2 };
-    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
deleted file mode 100644 (file)
index 92f745d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-pub trait Reader {
-    // FIXME (#2004): Seekable really should be orthogonal.
-
-    /// Read up to len bytes (or EOF) and put them into bytes (which
-    /// must be at least len bytes long). Return number of bytes read.
-    // FIXME (#2982): This should probably return an error.
-    fn read(&self, bytes: &mut [u8], len: uint) -> uint;
-}
-
-pub trait ReaderUtil {
-
-    /// Read len bytes into a new vec.
-    fn read_bytes(&self, len: uint);
-}
-
-impl<T:Reader> ReaderUtil for T {
-
-    fn read_bytes(&self, len: uint) {
-        let mut count = self.read(&mut [0], len);
-    }
-
-}
-
-struct S {
-    x: int,
-    y: int
-}
-
-impl Reader for S {
-    fn read(&self, bytes: &mut [u8], len: uint) -> uint {
-        0
-    }
-}
-
-pub fn main() {
-    let x = S { x: 1, y: 2 };
-    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
deleted file mode 100644 (file)
index 2cfd327..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-pub trait Reader {
-    // FIXME (#2004): Seekable really should be orthogonal.
-
-    /// Read up to len bytes (or EOF) and put them into bytes (which
-    /// must be at least len bytes long). Return number of bytes read.
-    // FIXME (#2982): This should probably return an error.
-    fn read(&self, bytes: &mut [u8], len: uint) -> uint;
-}
-
-pub trait ReaderUtil {
-
-    /// Read len bytes into a new vec.
-    fn read_bytes(len: uint);
-}
-
-impl<T:Reader> ReaderUtil for T {
-
-    fn read_bytes(len: uint) {
-        let mut count = self.read(&mut [0], len);
-    }
-
-}
-
-struct S {
-    x: int,
-    y: int
-}
-
-impl Reader for S {
-    fn read(&self, bytes: &mut [u8], len: uint) -> uint {
-        0
-    }
-}
-
-pub fn main() {
-    let x = S { x: 1, y: 2 };
-    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
deleted file mode 100644 (file)
index 3945be7..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-pub trait Reader {
-    // FIXME (#2004): Seekable really should be orthogonal.
-
-    /// Read up to len bytes (or EOF) and put them into bytes (which
-    /// must be at least len bytes long). Return number of bytes read.
-    // FIXME (#2982): This should probably return an error.
-    fn read(bytes: &mut [u8], len: uint) -> uint;
-}
-
-pub trait ReaderUtil {
-
-    /// Read len bytes into a new vec.
-    fn read_bytes(len: uint);
-}
-
-impl<T:Reader> ReaderUtil for T {
-
-    fn read_bytes(len: uint) {
-        let mut count = self.read(&mut [0], len);
-    }
-
-}
-
-struct S {
-    x: int,
-    y: int
-}
-
-impl Reader for S {
-    fn read(bytes: &mut [u8], len: uint) -> uint {
-        0
-    }
-}
-
-pub fn main() {
-    let x = S { x: 1, y: 2 };
-    let x = @x as @Reader;
-    x.read_bytes(0);
-}
index 7b3247fafc7d4ec5ccd51d4b1757819975f7d3cd..83cedc0fe502468b7c2dd001cce74e45decc0bcb 100644 (file)
 use core::iter::BaseIter;
 
 trait FlatMapToVec<A> {
-  fn flat_map_to_vec<B, IB:BaseIter<B>>(op: fn(&A) -> IB) -> ~[B];
+  fn flat_map_to_vec<B, IB:BaseIter<B>>(&self, op: fn(&A) -> IB) -> ~[B];
 }
 
-impl<A:Copy> FlatMapToVec<A> for BaseIter<A> {
-   fn flat_map_to_vec<B, IB:BaseIter<B>>(op: fn(&A) -> IB) -> ~[B] {
-     iter::flat_map_to_vec(&self, op)
+impl<A:Copy> FlatMapToVec<A> for ~[A] {
+   fn flat_map_to_vec<B, IB:BaseIter<B>>(&self, op: fn(&A) -> IB) -> ~[B] {
+     iter::flat_map_to_vec(self, op)
    }
 }
 
diff --git a/src/test/run-pass/issue-3305.rs b/src/test/run-pass/issue-3305.rs
deleted file mode 100644 (file)
index bfde199..0000000
+++ /dev/null
@@ -1,26 +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 double {
-    fn double() -> uint;
-}
-
-impl double for uint {
-    fn double() -> uint { self * 2u }
-}
-
-fn is_equal<D:double>(x: @D, exp: uint) {
-    assert x.double() == exp;
-}
-
-pub fn main() {
-    let x = @(@3u as @double);
-    is_equal(x, 6);
-}