diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-03-05 17:49:50 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-03-06 11:02:19 -0500 |
| commit | 6d764cc361b2e82f6ffead7bb7ddea18adf31481 (patch) | |
| tree | 2847021a9128d699f6e618128d40a88024b782cb /src/test/compile-fail | |
| parent | 6267339d6869a27b95f13c578a235204a1562697 (diff) | |
| download | rust-6d764cc361b2e82f6ffead7bb7ddea18adf31481.tar.gz rust-6d764cc361b2e82f6ffead7bb7ddea18adf31481.zip | |
Make object types not implement associated trait. Fixes #5087.
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/object-does-not-impl-trait.rs (renamed from src/test/compile-fail/selftype-astparam.rs) | 20 | ||||
| -rw-r--r-- | src/test/compile-fail/regions-trait-3.rs | 12 | ||||
| -rw-r--r-- | src/test/compile-fail/trait-cast.rs | 21 |
3 files changed, 16 insertions, 37 deletions
diff --git a/src/test/compile-fail/selftype-astparam.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index 08b6c0f71fe..886b849dbef 100644 --- a/src/test/compile-fail/selftype-astparam.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -8,18 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait add { - fn plus(++x: Self) -> Self; -} +// Test that an object type `@Foo` is not considered to implement the +// trait `Foo`. Issue #5087. -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 -} +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() {} diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index 0ddaf25710c..a10c239617e 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -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/trait-cast.rs b/src/test/compile-fail/trait-cast.rs deleted file mode 100644 index d0738be09c7..00000000000 --- a/src/test/compile-fail/trait-cast.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -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() {} |
