diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-12 19:32:14 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-13 20:07:10 -0700 |
| commit | 8fa66e8e07ca565119de195ceefb20cff50ae1ea (patch) | |
| tree | f9ae9910b40b04ae62daff56b8de1ae002765d2e /src/test/compile-fail | |
| parent | a410652bc953137c8d579f218c2e3e68a9ef8c1c (diff) | |
| download | rust-8fa66e8e07ca565119de195ceefb20cff50ae1ea.tar.gz rust-8fa66e8e07ca565119de195ceefb20cff50ae1ea.zip | |
librustc: Remove implicit self from the language, except for old-style drop blocks.
Diffstat (limited to 'src/test/compile-fail')
45 files changed, 90 insertions, 110 deletions
diff --git a/src/test/compile-fail/ambig_impl_unify.rs b/src/test/compile-fail/ambig_impl_unify.rs index 7e27a51ccdd..ce8c2a29544 100644 --- a/src/test/compile-fail/ambig_impl_unify.rs +++ b/src/test/compile-fail/ambig_impl_unify.rs @@ -9,15 +9,15 @@ // except according to those terms. trait foo { - fn foo() -> int; + fn foo(&self) -> int; } impl foo for ~[uint] { - fn foo() -> int {1} //~ NOTE candidate #1 is `__extensions__::foo` + fn foo(&self) -> int {1} //~ NOTE candidate #1 is `__extensions__::foo` } impl foo for ~[int] { - fn foo() -> int {2} //~ NOTE candidate #2 is `__extensions__::foo` + fn foo(&self) -> int {2} //~ NOTE candidate #2 is `__extensions__::foo` } fn main() { diff --git a/src/test/compile-fail/assign-to-method.rs b/src/test/compile-fail/assign-to-method.rs index 2436e4da8df..4993846f445 100644 --- a/src/test/compile-fail/assign-to-method.rs +++ b/src/test/compile-fail/assign-to-method.rs @@ -16,7 +16,7 @@ struct cat { pub impl cat { - fn speak() { self.meows += 1u; } + fn speak(&self) { self.meows += 1u; } } fn cat(in_x : uint, in_y : int) -> cat { diff --git a/src/test/compile-fail/auto-ref-borrowck-failure.rs b/src/test/compile-fail/auto-ref-borrowck-failure.rs index 3cf1c770df7..9fe7ae40dbb 100644 --- a/src/test/compile-fail/auto-ref-borrowck-failure.rs +++ b/src/test/compile-fail/auto-ref-borrowck-failure.rs @@ -15,11 +15,11 @@ struct Foo { } trait Stuff { - fn printme(); + fn printme(self); } impl Stuff for &'self mut Foo { - fn printme() { + fn printme(self) { io::println(fmt!("%d", self.x)); } } diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index 7032a3a0b22..d5b8f99ada0 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -13,11 +13,11 @@ fn foo<T>() { } trait bar { - fn bar<T:Copy>(); + fn bar<T:Copy>(&self); } impl bar for uint { - fn bar<T:Copy>() { + fn bar<T:Copy>(&self) { } } diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index b874eac34b1..9f517ad99a1 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -11,7 +11,7 @@ struct X(Either<(uint,uint),extern fn()>); pub impl &'self X { - fn with(blk: &fn(x: &Either<(uint,uint),extern fn()>)) { + fn with(self, blk: &fn(x: &Either<(uint,uint),extern fn()>)) { blk(&**self) } } diff --git a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs index 61cf346ffa4..23debb4c5e2 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs @@ -20,7 +20,7 @@ impl ops::Add<int,int> for Point { } pub impl Point { - fn times(z: int) -> int { + fn times(&self, z: int) -> int { self.x * self.y * z } } diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs index 85989bf9d21..4a7228dcca3 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr.rs @@ -11,18 +11,18 @@ struct point { x: int, y: int } trait methods { - fn impurem(); - fn blockm(f: &fn()); - pure fn purem(); + fn impurem(&self); + fn blockm(&self, f: &fn()); + pure fn purem(&self); } impl methods for point { - fn impurem() { + fn impurem(&self) { } - fn blockm(f: &fn()) { f() } + fn blockm(&self, f: &fn()) { f() } - pure fn purem() { + pure fn purem(&self) { } } diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs index 9133b80aa1e..caa79132182 100644 --- a/src/test/compile-fail/class-cast-to-trait.rs +++ b/src/test/compile-fail/class-cast-to-trait.rs @@ -9,7 +9,7 @@ // except according to those terms. trait noisy { - fn speak(); + fn speak(&self); } struct cat { @@ -21,7 +21,7 @@ struct cat { pub impl cat { - fn eat() -> bool { + fn eat(&self) -> bool { if self.how_hungry > 0 { error!("OM NOM NOM"); self.how_hungry -= 2; @@ -35,12 +35,12 @@ pub impl cat { } impl noisy for cat { - fn speak() { self.meow(); } + fn speak(&self) { self.meow(); } } priv impl cat { - fn meow() { + fn meow(&self) { error!("Meow"); self.meows += 1; if self.meows % 5 == 0 { @@ -49,7 +49,7 @@ priv impl cat { } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { +fn cat(&self, in_x : uint, in_y : int, in_name: ~str) -> cat { cat { meows: in_x, how_hungry: in_y, diff --git a/src/test/compile-fail/class-method-missing.rs b/src/test/compile-fail/class-method-missing.rs index 2a7e2cea6fa..f3c5ab2019d 100644 --- a/src/test/compile-fail/class-method-missing.rs +++ b/src/test/compile-fail/class-method-missing.rs @@ -10,7 +10,7 @@ // error-pattern:missing method `eat` trait animal { - fn eat(); + fn eat(&self); } struct cat { diff --git a/src/test/compile-fail/class-missing-self.rs b/src/test/compile-fail/class-missing-self.rs index 9d3eb644656..b78b065d028 100644 --- a/src/test/compile-fail/class-missing-self.rs +++ b/src/test/compile-fail/class-missing-self.rs @@ -13,8 +13,8 @@ struct cat { } priv impl cat { - fn sleep() { loop{} } - fn meow() { + fn sleep(&self) { loop{} } + fn meow(&self) { error!("Meow"); meows += 1u; //~ ERROR unresolved name sleep(); //~ ERROR unresolved name diff --git a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs index 3b1dda19448..26b13566f7a 100644 --- a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs +++ b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs @@ -13,7 +13,7 @@ struct Foo { } trait Bar : Drop { - fn blah(); + fn blah(&self); } impl Drop for Foo { @@ -23,7 +23,7 @@ impl Drop for Foo { } impl Bar for Foo { - fn blah() { + fn blah(&self) { self.finalize(); //~ ERROR explicit call to destructor } } diff --git a/src/test/compile-fail/infinite-instantiation.rs b/src/test/compile-fail/infinite-instantiation.rs index 21f49b11f66..23b9532083a 100644 --- a/src/test/compile-fail/infinite-instantiation.rs +++ b/src/test/compile-fail/infinite-instantiation.rs @@ -12,17 +12,17 @@ // issue 2258 trait to_opt { - fn to_option() -> Option<Self>; + fn to_option(&self) -> Option<Self>; } impl to_opt for uint { - fn to_option() -> Option<uint> { + fn to_option(&self) -> Option<uint> { Some(self) } } impl<T:Copy> to_opt for Option<T> { - fn to_option() -> Option<Option<T>> { + fn to_option(&self) -> Option<Option<T>> { Some(self) } } diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index 361a20ad451..def1fa30f3b 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -9,11 +9,11 @@ // except according to those terms. trait vec_monad<A> { - fn bind<B>(f: &fn(A) -> ~[B]); + fn bind<B>(&self, f: &fn(A) -> ~[B]); } impl<A> vec_monad<A> for ~[A] { - fn bind<B>(f: &fn(A) -> ~[B]) { + fn bind<B>(&self, f: &fn(A) -> ~[B]) { let mut r = fail!(); for self.each |elt| { r += f(*elt); } //~^ WARNING unreachable expression diff --git a/src/test/compile-fail/issue-2330.rs b/src/test/compile-fail/issue-2330.rs index e255d46633a..d8acbf2893a 100644 --- a/src/test/compile-fail/issue-2330.rs +++ b/src/test/compile-fail/issue-2330.rs @@ -11,12 +11,12 @@ enum chan { } trait channel<T> { - fn send(v: T); + fn send(&self, v: T); } // `chan` is not a trait, it's an enum impl chan for int { //~ ERROR can only implement trait types - fn send(v: int) { fail!() } + fn send(&self, v: int) { fail!() } } fn main() { diff --git a/src/test/compile-fail/issue-2611-5.rs b/src/test/compile-fail/issue-2611-5.rs index b0e2878c46b..9840650fa2e 100644 --- a/src/test/compile-fail/issue-2611-5.rs +++ b/src/test/compile-fail/issue-2611-5.rs @@ -12,7 +12,7 @@ // an impl against a trait trait A { - fn b<C:Copy,D>(x: C) -> C; + fn b<C:Copy,D>(&self, x: C) -> C; } struct E { @@ -21,7 +21,7 @@ struct E { impl A for E { // n.b. The error message is awful -- see #3404 - fn b<F:Copy,G>(_x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type + fn b<F:Copy,G>(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type } fn main() {} diff --git a/src/test/compile-fail/issue-3021-c.rs b/src/test/compile-fail/issue-3021-c.rs index f5bcae5377c..4fc4c005cf6 100644 --- a/src/test/compile-fail/issue-3021-c.rs +++ b/src/test/compile-fail/issue-3021-c.rs @@ -13,7 +13,7 @@ extern mod std; fn siphash<T>() { trait t { - fn g(x: T) -> T; //~ ERROR attempt to use a type argument out of scope + fn g(&self, x: T) -> T; //~ ERROR attempt to use a type argument out of scope //~^ ERROR attempt to use a type argument out of scope //~^^ ERROR use of undeclared type name `T` //~^^^ ERROR use of undeclared type name `T` diff --git a/src/test/compile-fail/issue-3021-d.rs b/src/test/compile-fail/issue-3021-d.rs index 4efbec92948..5b076c81eb8 100644 --- a/src/test/compile-fail/issue-3021-d.rs +++ b/src/test/compile-fail/issue-3021-d.rs @@ -11,8 +11,8 @@ extern mod std; trait siphash { - fn result() -> u64; - fn reset(); + fn result(&self) -> u64; + fn reset(&self); } fn siphash(k0 : u64, k1 : u64) -> siphash { @@ -21,7 +21,7 @@ fn siphash(k0 : u64, k1 : u64) -> siphash { v1: u64, } - fn mk_result(st : SipState) -> u64 { + fn mk_result(&self, st : SipState) -> u64 { let v0 = st.v0, v1 = st.v1; @@ -29,13 +29,13 @@ fn siphash(k0 : u64, k1 : u64) -> siphash { } impl siphash for SipState { - fn reset() { + fn reset(&self) { self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture //~^ ERROR unresolved name: `k0`. self.v1 = k1 ^ 0x646f72616e646f6d; //~ ERROR attempted dynamic environment-capture //~^ ERROR unresolved name: `k1`. } - fn result() -> u64 { return mk_result(self); } + fn result(&self) -> u64 { return mk_result(self); } } } diff --git a/src/test/compile-fail/issue-3021.rs b/src/test/compile-fail/issue-3021.rs index 117156748ae..343683d79c1 100644 --- a/src/test/compile-fail/issue-3021.rs +++ b/src/test/compile-fail/issue-3021.rs @@ -11,7 +11,7 @@ extern mod std; trait SipHash { - fn reset(); + fn reset(&self); } fn siphash(k0 : u64) -> SipHash { @@ -20,7 +20,7 @@ fn siphash(k0 : u64) -> SipHash { } impl SipHash for SipState { - fn reset() { + fn reset(&self) { self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture //~^ ERROR unresolved name: `k0`. } diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index 2b25afeb0e7..1b121878697 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -10,11 +10,11 @@ struct P { child: Option<@mut P> } trait PTrait { - fn getChildOption() -> Option<@P>; + fn getChildOption(&self) -> Option<@P>; } impl PTrait for P { - fn getChildOption() -> Option<@P> { + fn getChildOption(&self) -> Option<@P> { const childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant fail!(); } diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs index 09a3f3d89c4..f6226032eee 100644 --- a/src/test/compile-fail/issue-3763.rs +++ b/src/test/compile-fail/issue-3763.rs @@ -16,7 +16,7 @@ mod my_mod { MyStruct {priv_field: 4} } pub impl MyStruct { - priv fn happyfun() {} + priv fn happyfun(&self) {} } } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 4f8269bb11b..abde71fb5d3 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait repeat<A> { fn get() -> A; } +trait repeat<A> { fn get(&self) -> A; } impl<A:Copy> repeat<A> for @A { - fn get() -> A { *self } + fn get(&self) -> A { *self } } fn repeater<A:Copy>(v: @A) -> @repeat<A> { diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index 391b65e3c81..1f8b9577e6c 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -12,11 +12,11 @@ // be parameterized by a region due to the &self/int constraint. trait foo { - fn foo(i: &'self int) -> int; + fn foo(&self, i: &'self int) -> int; } impl<T:Copy> foo<'self> for T { - fn foo(i: &'self int) -> int {*i} + fn foo(&self, i: &'self int) -> int {*i} } fn to_foo<T:Copy>(t: T) { diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs index a92a764afe7..af6924ef608 100644 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ b/src/test/compile-fail/kindck-owned-trait.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait foo { fn foo(); } +trait foo { fn foo(&self); } fn to_foo<T:Copy + foo>(t: T) -> @foo { @t as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound diff --git a/src/test/compile-fail/lint-deprecated-self.rs b/src/test/compile-fail/lint-deprecated-self.rs deleted file mode 100644 index 9da103396d8..00000000000 --- a/src/test/compile-fail/lint-deprecated-self.rs +++ /dev/null @@ -1,20 +0,0 @@ -#[forbid(deprecated_self)] -mod a { - trait T { - fn f(); //~ ERROR this method form is deprecated - } - - struct S { - x: int - } - - impl T for S { - fn f() { //~ ERROR this method form is deprecated - } - } -} - -fn main() { -} - - diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index 8b6c6b8410a..486fa63a9aa 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -15,7 +15,7 @@ use core::hashmap::linear::LinearMap; fn main() { let x: @Map<~str, ~str> = @LinearMap::new::<~str, ~str>() as - @Map::<~str, ~str>; + @(Map::<~str, ~str>); let y: @Map<uint, ~str> = @x; //~^ ERROR mismatched types: expected `@core::container::Map<uint,~str>` } diff --git a/src/test/compile-fail/mutable-class-fields-2.rs b/src/test/compile-fail/mutable-class-fields-2.rs index 3a63cdee20c..56c715c9847 100644 --- a/src/test/compile-fail/mutable-class-fields-2.rs +++ b/src/test/compile-fail/mutable-class-fields-2.rs @@ -16,7 +16,7 @@ struct cat { } pub impl cat { - fn eat() { + fn eat(&self) { self.how_hungry -= 5; } diff --git a/src/test/compile-fail/private-impl-method.rs b/src/test/compile-fail/private-impl-method.rs index 1ab8d25bb30..74bdcdc7f82 100644 --- a/src/test/compile-fail/private-impl-method.rs +++ b/src/test/compile-fail/private-impl-method.rs @@ -14,7 +14,7 @@ mod a { } pub impl Foo { - priv fn foo() {} + priv fn foo(&self) {} } } diff --git a/src/test/compile-fail/private-method.rs b/src/test/compile-fail/private-method.rs index 363a5fd0d2b..c918758ad7c 100644 --- a/src/test/compile-fail/private-method.rs +++ b/src/test/compile-fail/private-method.rs @@ -18,7 +18,7 @@ mod kitties { } pub impl cat { - priv fn nap() { uint::range(1u, 10000u, |_i| false)} + priv fn nap(&self) { uint::range(1u, 10000u, |_i| false)} } pub fn cat(in_x : uint, in_y : int) -> cat { diff --git a/src/test/compile-fail/pure-modifies-aliased.rs b/src/test/compile-fail/pure-modifies-aliased.rs index 2aa81dd4fa2..e48b03f694e 100644 --- a/src/test/compile-fail/pure-modifies-aliased.rs +++ b/src/test/compile-fail/pure-modifies-aliased.rs @@ -19,11 +19,11 @@ pure fn modify_in_box(sum: @mut S) { } trait modify_in_box_rec { - pure fn modify_in_box_rec(sum: @mut S); + pure fn modify_in_box_rec(&self, sum: @mut S); } impl modify_in_box_rec for int { - pure fn modify_in_box_rec(sum: @mut S) { + pure fn modify_in_box_rec(&self, sum: @mut S) { sum.f = self; //~ ERROR assigning to mutable field prohibited in pure context } } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index 92d1aab781c..a136c829165 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -14,7 +14,7 @@ struct an_enum(&'self int); trait a_trait { - fn foo() -> &'self int; + fn foo(&self) -> &'self int; } struct a_class { x:&'self int } diff --git a/src/test/compile-fail/regions-escape-via-trait-or-not.rs b/src/test/compile-fail/regions-escape-via-trait-or-not.rs index 767d7c9174d..1b737c273db 100644 --- a/src/test/compile-fail/regions-escape-via-trait-or-not.rs +++ b/src/test/compile-fail/regions-escape-via-trait-or-not.rs @@ -9,11 +9,11 @@ // except according to those terms. trait deref { - fn get() -> int; + fn get(self) -> int; } impl deref for &'self int { - fn get() -> int { + fn get(self) -> int { *self } } diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index 7b2a760270c..600590daded 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -19,12 +19,12 @@ struct c<'self> { } trait set_f<'self> { - fn set_f_ok(b: @b<'self>); - fn set_f_bad(b: @b); + fn set_f_ok(&self, b: @b<'self>); + fn set_f_bad(&self, b: @b); } impl<'self> set_f<'self> for c<'self> { - fn set_f_ok(b: @b<'self>) { + fn set_f_ok(&self, b: @b<'self>) { self.f = b; } diff --git a/src/test/compile-fail/regions-infer-paramd-method.rs b/src/test/compile-fail/regions-infer-paramd-method.rs index 93d493314fd..5fd3d68d9f3 100644 --- a/src/test/compile-fail/regions-infer-paramd-method.rs +++ b/src/test/compile-fail/regions-infer-paramd-method.rs @@ -12,9 +12,9 @@ // refers to self. trait foo<'self> { - fn self_int() -> &'self int; + fn self_int(&self) -> &'self int; - fn any_int() -> ∫ + fn any_int(&self) -> ∫ } struct with_foo<'self> { @@ -34,7 +34,7 @@ impl<'self> set_foo_foo for with_foo<'self> { // Bar is not region parameterized. trait bar { - fn any_int() -> ∫ + fn any_int(&self) -> ∫ } struct with_bar { diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index 8104f62595c..74afdf11758 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -12,7 +12,7 @@ struct ctxt { v: uint } trait get_ctxt { // Here the `&` is bound in the method definition: - fn get_ctxt() -> &ctxt; + fn get_ctxt(&self) -> &ctxt; } struct has_ctxt { c: &'self ctxt } @@ -21,7 +21,7 @@ impl get_ctxt for has_ctxt<'self> { // Here an error occurs because we used `&self` but // the definition used `&`: - fn get_ctxt() -> &'self ctxt { //~ ERROR method `get_ctxt` has an incompatible type + fn get_ctxt(&self) -> &'self ctxt { //~ ERROR method `get_ctxt` has an incompatible type self.c } diff --git a/src/test/compile-fail/regions-trait-2.rs b/src/test/compile-fail/regions-trait-2.rs index d76bc798705..d6f3a74e3ee 100644 --- a/src/test/compile-fail/regions-trait-2.rs +++ b/src/test/compile-fail/regions-trait-2.rs @@ -11,13 +11,13 @@ struct ctxt { v: uint } trait get_ctxt<'self> { - fn get_ctxt() -> &'self ctxt; + fn get_ctxt(&self) -> &'self ctxt; } struct has_ctxt<'self> { c: &'self ctxt } impl<'self> get_ctxt<'self> for has_ctxt<'self> { - fn get_ctxt() -> &self/ctxt { self.c } + fn get_ctxt(&self) -> &self/ctxt { self.c } } fn make_gc() -> @get_ctxt { diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index 414d848a966..6bd0b212b96 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -9,7 +9,7 @@ // except according to those terms. trait get_ctxt { - fn get_ctxt() -> &self/uint; + fn get_ctxt(&self) -> &self/uint; } fn make_gc1(gc: @get_ctxt/&a) -> @get_ctxt/&b { @@ -21,7 +21,7 @@ struct Foo { } impl get_ctxt/&self for Foo/&self { - fn get_ctxt() -> &self/uint { self.r } + fn get_ctxt(&self) -> &self/uint { self.r } } fn make_gc2(foo: Foo/&a) -> @get_ctxt/&b { diff --git a/src/test/compile-fail/selftype-traittype.rs b/src/test/compile-fail/selftype-traittype.rs index f704f408662..467154244b7 100644 --- a/src/test/compile-fail/selftype-traittype.rs +++ b/src/test/compile-fail/selftype-traittype.rs @@ -9,7 +9,7 @@ // except according to those terms. trait add { - fn plus(x: Self) -> Self; + fn plus(&self, x: Self) -> Self; } fn do_add(x: add, y: add) -> add { diff --git a/src/test/compile-fail/staticness-mismatch.rs b/src/test/compile-fail/staticness-mismatch.rs index e67a4099987..531d722d8bc 100644 --- a/src/test/compile-fail/staticness-mismatch.rs +++ b/src/test/compile-fail/staticness-mismatch.rs @@ -14,7 +14,7 @@ trait foo { } impl foo for int { - fn bar() {} //~ ERROR method `bar` is declared as static in its trait, but not in its impl + fn bar(&self) {} //~ ERROR method `bar` is declared as static in its trait, but not in its impl } fn main() {} diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs index 1699534216e..a4d39fa829e 100644 --- a/src/test/compile-fail/tps-invariant-trait.rs +++ b/src/test/compile-fail/tps-invariant-trait.rs @@ -9,8 +9,8 @@ // except according to those terms. trait box_trait<T> { - fn get() -> T; - fn set(t: T); + fn get(&self) -> T; + fn set(&self, t: T); } struct box<T> { @@ -20,8 +20,8 @@ struct box<T> { struct box_impl<T>(box<T>); impl<T:Copy> box_trait<T> for box_impl<T> { - fn get() -> T { return self.f; } - fn set(t: T) { self.f = t; } + fn get(&self) -> T { return self.f; } + fn set(&self, t: T) { self.f = t; } } fn set_box_trait<T>(b: @box_trait<@const T>, v: @const T) { diff --git a/src/test/compile-fail/trait-impl-can-not-have-untraitful-methods.rs b/src/test/compile-fail/trait-impl-can-not-have-untraitful-methods.rs index a20186c362b..1471d9232b2 100644 --- a/src/test/compile-fail/trait-impl-can-not-have-untraitful-methods.rs +++ b/src/test/compile-fail/trait-impl-can-not-have-untraitful-methods.rs @@ -11,7 +11,7 @@ trait A { } impl A for int { - fn foo() { } //~ ERROR method `foo` is not a member of trait `A` + fn foo(&self) { } //~ ERROR method `foo` is not a member of trait `A` } fn main() { } diff --git a/src/test/compile-fail/trait-impl-different-num-params.rs b/src/test/compile-fail/trait-impl-different-num-params.rs index f32793ad1e4..c1544c2f557 100644 --- a/src/test/compile-fail/trait-impl-different-num-params.rs +++ b/src/test/compile-fail/trait-impl-different-num-params.rs @@ -9,10 +9,10 @@ // except according to those terms. trait foo { - fn bar(x: uint) -> Self; + fn bar(&self, x: uint) -> Self; } impl foo for int { - fn bar() -> int { + fn bar(&self) -> int { //~^ ERROR method `bar` has 0 parameters but the trait has 1 self } diff --git a/src/test/compile-fail/trait-or-new-type-instead.rs b/src/test/compile-fail/trait-or-new-type-instead.rs index dc7c7cec65f..a5e37eb949d 100644 --- a/src/test/compile-fail/trait-or-new-type-instead.rs +++ b/src/test/compile-fail/trait-or-new-type-instead.rs @@ -10,7 +10,7 @@ // error-pattern: implement a trait or new type instead pub impl <T> Option<T> { - fn foo() { } + fn foo(&self) { } } fn main() { } diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index e63a1dc3563..ebdf354234a 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait bar { fn dup() -> Self; fn blah<X>(); } -impl bar for int { fn dup() -> int { self } fn blah<X>() {} } -impl bar for uint { fn dup() -> uint { self } fn blah<X>() {} } +trait bar { fn dup(&self) -> Self; fn blah<X>(); } +impl bar for int { fn dup(&self) -> int { self } fn blah<X>() {} } +impl bar for uint { fn dup(&self) -> uint { self } fn blah<X>() {} } fn main() { 10i.dup::<int>(); //~ ERROR does not take type parameters diff --git a/src/test/compile-fail/trait-test.rs b/src/test/compile-fail/trait-test.rs index cd92801fb4d..1682e98fb23 100644 --- a/src/test/compile-fail/trait-test.rs +++ b/src/test/compile-fail/trait-test.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait foo { fn foo(); } +trait foo { fn foo(&self); } -impl int for uint { fn foo() {} } //~ ERROR trait +impl int for uint { fn foo(&self) {} } //~ ERROR trait fn main() {} diff --git a/src/test/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs index 514448c9644..adcf2021274 100644 --- a/src/test/compile-fail/vtable-res-trait-param.rs +++ b/src/test/compile-fail/vtable-res-trait-param.rs @@ -9,15 +9,15 @@ // except according to those terms. trait TraitA { - fn method_a() -> int; + fn method_a(&self) -> int; } trait TraitB { - fn gimme_an_a<A:TraitA>(a: A) -> int; + fn gimme_an_a<A:TraitA>(&self, a: A) -> int; } impl TraitB for int { - fn gimme_an_a<A:TraitA>(a: A) -> int { + fn gimme_an_a<A:TraitA>(&self, a: A) -> int { a.method_a() + self } } |
