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/run-pass | |
| parent | a410652bc953137c8d579f218c2e3e68a9ef8c1c (diff) | |
librustc: Remove implicit self from the language, except for old-style drop blocks.
Diffstat (limited to 'src/test/run-pass')
72 files changed, 202 insertions, 203 deletions
diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index ae046babfdf..5fecbbe70e4 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -13,11 +13,11 @@ // it. trait iterable<A> { - fn iterate(blk: &fn(x: &A) -> bool); + fn iterate(&self, blk: &fn(x: &A) -> bool); } impl<A> iterable<A> for &self/[A] { - fn iterate(f: &fn(x: &A) -> bool) { + fn iterate(&self, f: &fn(x: &A) -> bool) { for vec::each(self) |e| { if !f(e) { break; } } @@ -25,7 +25,7 @@ impl<A> iterable<A> for &self/[A] { } impl<A> iterable<A> for ~[A] { - fn iterate(f: &fn(x: &A) -> bool) { + fn iterate(&self, f: &fn(x: &A) -> bool) { for vec::each(self) |e| { if !f(e) { break; } } diff --git a/src/test/run-pass/auto-ref.rs b/src/test/run-pass/auto-ref.rs index b6d71fcfb55..82fca3318b1 100644 --- a/src/test/run-pass/auto-ref.rs +++ b/src/test/run-pass/auto-ref.rs @@ -13,11 +13,11 @@ struct Foo { } trait Stuff { - fn printme(); + fn printme(self); } impl Stuff for &self/Foo { - fn printme() { + fn printme(self) { io::println(fmt!("%d", self.x)); } } diff --git a/src/test/run-pass/autoderef-method-newtype.rs b/src/test/run-pass/autoderef-method-newtype.rs index 732c26694ad..a4dbab49c0c 100644 --- a/src/test/run-pass/autoderef-method-newtype.rs +++ b/src/test/run-pass/autoderef-method-newtype.rs @@ -9,11 +9,11 @@ // except according to those terms. trait double { - fn double() -> uint; + fn double(&self) -> uint; } impl double for uint { - fn double() -> uint { self * 2u } + fn double(&self) -> uint { *self * 2u } } struct foo(uint); diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 3d64c5d0e42..c4e8e168573 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -9,11 +9,11 @@ // except according to those terms. trait double { - fn double() -> uint; + fn double(self) -> uint; } impl double for uint { - fn double() -> uint { self * 2u } + fn double(self) -> uint { self * 2u } } pub fn main() { diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index a3d4e28dec7..ee37781d702 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -9,15 +9,15 @@ // except according to those terms. trait double { - fn double() -> uint; + fn double(self) -> uint; } impl double for uint { - fn double() -> uint { self } + fn double(self) -> uint { self } } impl double for @uint { - fn double() -> uint { *self * 2u } + fn double(self) -> uint { *self * 2u } } pub fn main() { diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index 9a6469bbca8..1a49ceb1cde 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -9,11 +9,11 @@ // except according to those terms. trait double { - fn double() -> uint; + fn double(self) -> uint; } impl double for @@uint { - fn double() -> uint { **self * 2u } + fn double(self) -> uint { **self * 2u } } pub fn main() { diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index c44ded77ec8..68691d9aa62 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -9,11 +9,11 @@ // except according to those terms. trait double { - fn double() -> uint; + fn double(self) -> uint; } impl double for uint { - fn double() -> uint { self * 2u } + fn double(self) -> uint { self * 2u } } pub fn main() { diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index e6b05989903..9721eb9207e 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -9,11 +9,11 @@ // except according to those terms. trait double { - fn double() -> uint; + fn double(self) -> uint; } impl double for uint { - fn double() -> uint { self * 2u } + fn double(self) -> uint { self * 2u } } pub fn main() { diff --git a/src/test/run-pass/borrowck-newtype-issue-2573.rs b/src/test/run-pass/borrowck-newtype-issue-2573.rs index 7e81345739f..7724836b5db 100644 --- a/src/test/run-pass/borrowck-newtype-issue-2573.rs +++ b/src/test/run-pass/borrowck-newtype-issue-2573.rs @@ -15,11 +15,11 @@ struct baz_ {baz: int} type baz = @mut baz_; trait frob { - fn frob(); + fn frob(&self); } impl frob for foo { - fn frob() { + fn frob(&self) { really_impure(self.bar); } } diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/run-pass/boxed-trait-with-vstore.rs index 1d2c30108f1..e94525d1691 100644 --- a/src/test/run-pass/boxed-trait-with-vstore.rs +++ b/src/test/run-pass/boxed-trait-with-vstore.rs @@ -9,11 +9,11 @@ // except according to those terms. trait Foo { - fn foo(); + fn foo(self); } impl Foo for int { - fn foo() { + fn foo(self) { io::println("Hello world!"); } } 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 50a3d5cc617..eefa78cc3c9 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 @@ -9,7 +9,7 @@ // except according to those terms. trait noisy { - fn speak() -> int; + fn speak(&self) -> int; } struct dog { @@ -19,7 +19,7 @@ struct dog { } pub impl dog { - priv fn bark() -> int { + priv fn bark(&self) -> int { debug!("Woof %u %d", *self.barks, *self.volume); *self.barks += 1u; if *self.barks % 3u == 0u { @@ -34,7 +34,7 @@ pub impl dog { } impl noisy for dog { - fn speak() -> int { self.bark() } + fn speak(&self) -> int { self.bark() } } fn dog() -> dog { @@ -52,15 +52,15 @@ struct cat { } impl noisy for cat { - fn speak() -> int { self.meow() as int } + fn speak(&self) -> int { self.meow() as int } } pub impl cat { - fn meow_count() -> uint { *self.meows } + fn meow_count(&self) -> uint { *self.meows } } priv impl cat { - fn meow() -> uint { + fn meow(&self) -> uint { debug!("Meow"); *self.meows += 1u; if *self.meows % 5u == 0u { diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs index 85cbbcc23a3..aa5bb2b519c 100644 --- a/src/test/run-pass/class-exports.rs +++ b/src/test/run-pass/class-exports.rs @@ -22,10 +22,10 @@ mod kitty { } pub impl cat { - fn get_name() -> ~str { copy self.name } + fn get_name(&self) -> ~str { copy self.name } } - pub fn cat(in_name: ~str) -> cat { + pub fn cat(&self, in_name: ~str) -> cat { cat { name: in_name, meows: 0u diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index fa6f59999f8..3a626ca6ac1 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -137,25 +137,25 @@ mod test_methods { impl Fooable for Foo { #[cfg(bogus)] - static fn what() { } + static fn what(&self) { } - static fn what() { } + static fn what(&self) { } #[cfg(bogus)] - fn the() { } + fn the(&self) { } - fn the() { } + fn the(&self) { } } trait Fooable { #[cfg(bogus)] - static fn what(); + static fn what(&self); - static fn what(); + static fn what(&self); #[cfg(bogus)] - fn the(); + fn the(&self); - fn the(); + fn the(&self); } } diff --git a/src/test/run-pass/default-method-simple.rs b/src/test/run-pass/default-method-simple.rs index 4e17506d6ea..62b29d4e4eb 100644 --- a/src/test/run-pass/default-method-simple.rs +++ b/src/test/run-pass/default-method-simple.rs @@ -11,11 +11,11 @@ #[allow(default_methods)]; trait Foo { - fn f() { + fn f(&self) { io::println("Hello!"); self.g(); } - fn g(); + fn g(&self); } struct A { @@ -23,7 +23,7 @@ struct A { } impl Foo for A { - fn g() { + fn g(&self) { io::println("Goodbye!"); } } diff --git a/src/test/run-pass/early-vtbl-resolution.rs b/src/test/run-pass/early-vtbl-resolution.rs index 0191934d608..4728f718463 100644 --- a/src/test/run-pass/early-vtbl-resolution.rs +++ b/src/test/run-pass/early-vtbl-resolution.rs @@ -10,10 +10,10 @@ trait thing<A> { - fn foo() -> Option<A>; + fn foo(&self) -> Option<A>; } impl<A> thing<A> for int { - fn foo() -> Option<A> { None } + fn foo(&self) -> Option<A> { None } } fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() } diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index 60e1c1a7c37..acdd3fc4600 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -9,7 +9,7 @@ // except according to those terms. trait Foo<T> { - fn get() -> T; + fn get(&self) -> T; } struct S { @@ -17,7 +17,7 @@ struct S { } impl Foo<int> for S { - fn get() -> int { + fn get(&self) -> int { self.x } } diff --git a/src/test/run-pass/impl-implicit-trait.rs b/src/test/run-pass/impl-implicit-trait.rs index 88e220670ba..10a5661a324 100644 --- a/src/test/run-pass/impl-implicit-trait.rs +++ b/src/test/run-pass/impl-implicit-trait.rs @@ -14,7 +14,7 @@ enum option_<T> { } pub impl<T> option_<T> { - fn foo() -> bool { true } + fn foo(&self) -> bool { true } } enum option__ { @@ -23,7 +23,7 @@ enum option__ { } pub impl option__ { - fn foo() -> bool { true } + fn foo(&self) -> bool { true } } pub fn main() { diff --git a/src/test/run-pass/impl-variance.rs b/src/test/run-pass/impl-variance.rs index d772b76108e..849aa2a29f4 100644 --- a/src/test/run-pass/impl-variance.rs +++ b/src/test/run-pass/impl-variance.rs @@ -9,11 +9,11 @@ // except according to those terms. trait foo { - fn foo() -> uint; + fn foo(&self) -> uint; } impl<T> foo for ~[const T] { - fn foo() -> uint { vec::len(self) } + fn foo(&self) -> uint { vec::len(self) } } pub fn main() { diff --git a/src/test/run-pass/issue-2284.rs b/src/test/run-pass/issue-2284.rs index ebf7eec470c..6dda45a99f9 100644 --- a/src/test/run-pass/issue-2284.rs +++ b/src/test/run-pass/issue-2284.rs @@ -9,11 +9,11 @@ // except according to those terms. trait Send { - fn f(); + fn f(&self); } fn f<T:Send>(t: T) { - t.f(); + t.f(&self); } pub fn main() { diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index fe32af7b15f..9dcee06ba85 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -9,14 +9,14 @@ // except according to those terms. trait c lam<A:Copy> { - fn chowder(y: A); + fn chowder(&self, y: A); } struct foo<A> { x: A, } impl<A:Copy> clam<A> for foo<A> { - fn chowder(y: A) { + fn chowder(&self, y: A) { } } diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index f60db84eb86..5f47e7ccb9f 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -14,7 +14,7 @@ struct foo<A> { } pub impl<A:Copy> foo<A> { - fn bar<B,C:clam<A>>(c: C) -> B { + fn bar<B,C:clam<A>>(&self, c: C) -> B { fail!(); } } diff --git a/src/test/run-pass/issue-2311.rs b/src/test/run-pass/issue-2311.rs index f3ced02c122..dc873ed08d7 100644 --- a/src/test/run-pass/issue-2311.rs +++ b/src/test/run-pass/issue-2311.rs @@ -10,7 +10,7 @@ trait clam<A> { } trait foo<A> { - fn bar<B,C:clam<A>>(c: C) -> B; + fn bar<B,C:clam<A>>(&self, c: C) -> B; } pub fn main() { } diff --git a/src/test/run-pass/issue-2312.rs b/src/test/run-pass/issue-2312.rs index ad6320aed2b..f3aa96298f0 100644 --- a/src/test/run-pass/issue-2312.rs +++ b/src/test/run-pass/issue-2312.rs @@ -15,7 +15,7 @@ trait clam<A> { } struct foo(int); pub impl foo { - fn bar<B,C:clam<B>>(c: C) -> B { fail!(); } + fn bar<B,C:clam<B>>(&self, c: C) -> B { fail!(); } } pub fn main() { } diff --git a/src/test/run-pass/issue-2445-b.rs b/src/test/run-pass/issue-2445-b.rs index 73bf97ad7af..55c72a41a6a 100644 --- a/src/test/run-pass/issue-2445-b.rs +++ b/src/test/run-pass/issue-2445-b.rs @@ -13,7 +13,7 @@ struct c1<T> { } pub impl<T:Copy> c1<T> { - fn f1(x: int) { + fn f1(&self, x: int) { } } @@ -24,7 +24,7 @@ fn c1<T:Copy>(x: T) -> c1<T> { } pub impl<T:Copy> c1<T> { - fn f2(x: int) { + fn f2(&self, x: int) { } } diff --git a/src/test/run-pass/issue-2445.rs b/src/test/run-pass/issue-2445.rs index 973b8d85161..5a82b534015 100644 --- a/src/test/run-pass/issue-2445.rs +++ b/src/test/run-pass/issue-2445.rs @@ -13,7 +13,7 @@ struct c1<T> { } pub impl<T:Copy> c1<T> { - fn f1(x: T) {} + fn f1(&self, x: T) {} } fn c1<T:Copy>(x: T) -> c1<T> { @@ -23,7 +23,7 @@ fn c1<T:Copy>(x: T) -> c1<T> { } pub impl<T:Copy> c1<T> { - fn f2(x: T) {} + fn f2(&self, x: T) {} } diff --git a/src/test/run-pass/issue-2487-a.rs b/src/test/run-pass/issue-2487-a.rs index 138860ce72d..59986638088 100644 --- a/src/test/run-pass/issue-2487-a.rs +++ b/src/test/run-pass/issue-2487-a.rs @@ -18,8 +18,7 @@ impl Drop for socket { } pub impl socket { - - fn set_identity() { + fn set_identity(&self) { do closure { setsockopt_bytes(copy self.sock) } diff --git a/src/test/run-pass/issue-2502.rs b/src/test/run-pass/issue-2502.rs index c7a7dc53965..9af41e48aa2 100644 --- a/src/test/run-pass/issue-2502.rs +++ b/src/test/run-pass/issue-2502.rs @@ -13,7 +13,7 @@ struct font { } pub impl font/&self { - fn buf() -> &self/~[u8] { + fn buf(&self) -> &self/~[u8] { self.fontbuf } } diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index a76d2242b40..35c3d6a88ee 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -11,7 +11,7 @@ trait hax { } impl<A> hax for A { } -fn perform_hax<T:&static>(x: @T) -> hax { +fn perform_hax<T:&static>(x: @T) -> @hax { @x as @hax } diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index 323b5d8ed5a..c1f4e1e49aa 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -13,11 +13,11 @@ type t = bool; trait it { - fn f(); + fn f(&self); } impl it for t { - fn f() { } + fn f(&self) { } } pub fn main() { diff --git a/src/test/run-pass/issue-2936.rs b/src/test/run-pass/issue-2936.rs index 2e343e9afe6..5acae2da1ce 100644 --- a/src/test/run-pass/issue-2936.rs +++ b/src/test/run-pass/issue-2936.rs @@ -9,7 +9,7 @@ // except according to those terms. trait bar<T> { - fn get_bar() -> T; + fn get_bar(&self) -> T; } fn foo<T, U: bar<T>>(b: U) -> T { @@ -21,7 +21,7 @@ struct cbar { } impl bar<int> for cbar { - fn get_bar() -> int { + fn get_bar(&self) -> int { self.x } } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index 72af21368f1..10b845a923d 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -11,11 +11,11 @@ extern mod std; trait methods { - fn to_bytes() -> ~[u8]; + fn to_bytes(&self) -> ~[u8]; } impl methods for () { - fn to_bytes() -> ~[u8] { + fn to_bytes(&self) -> ~[u8] { vec::from_elem(0, 0) } } diff --git a/src/test/run-pass/issue-3563-2.rs b/src/test/run-pass/issue-3563-2.rs index 332127d0204..52d6792f401 100644 --- a/src/test/run-pass/issue-3563-2.rs +++ b/src/test/run-pass/issue-3563-2.rs @@ -10,8 +10,8 @@ #[allow(default_methods)] trait Canvas { - fn add_point(point: &int); - fn add_points(shapes: &[int]) { + fn add_point(&self, point: &int); + fn add_points(&self, shapes: &[int]) { for shapes.each |pt| { self.add_point(pt) } diff --git a/src/test/run-pass/issue-3683.rs b/src/test/run-pass/issue-3683.rs index 79e205d262a..edbc7852542 100644 --- a/src/test/run-pass/issue-3683.rs +++ b/src/test/run-pass/issue-3683.rs @@ -11,14 +11,14 @@ #[allow(default_methods)]; trait Foo { - fn a() -> int; - fn b() -> int { + fn a(&self) -> int; + fn b(&self) -> int { self.a() + 2 } } impl Foo for int { - fn a() -> int { + fn a(&self) -> int { 3 } } diff --git a/src/test/run-pass/issue-3753.rs b/src/test/run-pass/issue-3753.rs index 920736a976e..948ff1afd81 100644 --- a/src/test/run-pass/issue-3753.rs +++ b/src/test/run-pass/issue-3753.rs @@ -23,7 +23,7 @@ pub enum Shape { } pub impl Shape { - pub fn area(sh: Shape) -> float { + pub fn area(&self, sh: Shape) -> float { match sh { Circle(_, size) => float::consts::pi * size * size, Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y) 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 75b0a633552..7beb4881d7a 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.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/run-pass/max-min-classes.rs b/src/test/run-pass/max-min-classes.rs index 56c16d92874..58dcb24edf9 100644 --- a/src/test/run-pass/max-min-classes.rs +++ b/src/test/run-pass/max-min-classes.rs @@ -9,7 +9,7 @@ // except according to those terms. trait Product { - fn product() -> int; + fn product(&self) -> int; } struct Foo { @@ -18,13 +18,13 @@ struct Foo { } pub impl Foo { - fn sum() -> int { + fn sum(&self) -> int { self.x + self.y } } impl Product for Foo { - fn product() -> int { + fn product(&self) -> int { self.x * self.y } } diff --git a/src/test/run-pass/method-attributes.rs b/src/test/run-pass/method-attributes.rs index 20cd9643b08..db7440738da 100644 --- a/src/test/run-pass/method-attributes.rs +++ b/src/test/run-pass/method-attributes.rs @@ -13,20 +13,20 @@ #[frobable] trait frobable { #[frob_attr] - fn frob(); + fn frob(&self); #[defrob_attr] - fn defrob(); + fn defrob(&self); } #[int_frobable] impl frobable for int { #[frob_attr1] - fn frob() { + fn frob(&self) { #[frob_attr2]; } #[defrob_attr1] - fn defrob() { + fn defrob(&self) { #[defrob_attr2]; } } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index b21b3b6c7fb..9b864257d4b 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -11,11 +11,11 @@ // xfail-fast trait vec_monad<A> { - fn bind<B:Copy>(f: &fn(&A) -> ~[B]) -> ~[B]; + fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B]; } impl<A> vec_monad<A> for ~[A] { - fn bind<B:Copy>(f: &fn(&A) -> ~[B]) -> ~[B] { + fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B] { let mut r = ~[]; for self.each |elt| { r += f(elt); } r @@ -23,11 +23,11 @@ impl<A> vec_monad<A> for ~[A] { } trait option_monad<A> { - fn bind<B>(f: &fn(&A) -> Option<B>) -> Option<B>; + fn bind<B>(&self, f: &fn(&A) -> Option<B>) -> Option<B>; } impl<A> option_monad<A> for Option<A> { - fn bind<B>(f: &fn(&A) -> Option<B>) -> Option<B> { + fn bind<B>(&self, f: &fn(&A) -> Option<B>) -> Option<B> { match self { Some(ref a) => { f(a) } None => { None } diff --git a/src/test/run-pass/monomorphize-trait-in-fn-at.rs b/src/test/run-pass/monomorphize-trait-in-fn-at.rs index 6e5d92da1cb..a591c3034d2 100644 --- a/src/test/run-pass/monomorphize-trait-in-fn-at.rs +++ b/src/test/run-pass/monomorphize-trait-in-fn-at.rs @@ -17,11 +17,11 @@ fn mk_nil<C:ty_ops>(cx: C) -> uint { } trait ty_ops { - fn mk() -> uint; + fn mk(&self) -> uint; } impl ty_ops for () { - fn mk() -> uint { 22u } + fn mk(&self) -> uint { 22u } } pub fn main() { diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index ecf30b206c5..90b3e623f5e 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -14,17 +14,17 @@ trait Serializer { } trait Serializable { - fn serialize<S:Serializer>(s: S); + fn serialize<S:Serializer>(&self, s: S); } impl Serializable for int { - fn serialize<S:Serializer>(_s: S) { } + fn serialize<S:Serializer>(&self, _s: S) { } } struct F<A> { a: A } impl<A:Copy + Serializable> Serializable for F<A> { - fn serialize<S:Serializer>(s: S) { + fn serialize<S:Serializer>(&self, s: S) { self.a.serialize(s); } } diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index eeda69e621d..6447d46ad89 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -15,7 +15,7 @@ pub fn main() { } pub impl b { - fn do_stuff() -> int { return 37; } + fn do_stuff(&self) -> int { return 37; } } fn b(i:int) -> b { diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index a7daa566480..3f02af3f71c 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -9,12 +9,12 @@ // except according to those terms. trait get { - fn get() -> int; + fn get(self) -> int; } // Note: impl on a slice impl get for &'self int { - fn get() -> int { + fn get(self) -> int { return *self; } } diff --git a/src/test/run-pass/rcvr-borrowed-to-slice.rs b/src/test/run-pass/rcvr-borrowed-to-slice.rs index f7f6b9b05e3..9328189c47c 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -9,12 +9,12 @@ // except according to those terms. trait sum { - fn sum() -> int; + fn sum(self) -> int; } // Note: impl on a slice impl sum for &'self [int] { - fn sum() -> int { + fn sum(self) -> int { let mut sum = 0; for vec::each(self) |e| { sum += *e; } return sum; diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 0f3f4db3bbf..5b3ba0d45ed 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -19,7 +19,7 @@ use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor}; /// Trait for visitor that wishes to reflect on data. trait movable_ptr { - fn move_ptr(adjustment: &fn(*c_void) -> *c_void); + fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void); } /// Helper function for alignment calculation. @@ -33,26 +33,26 @@ struct ptr_visit_adaptor<V>(Inner<V>); pub impl<V:TyVisitor + movable_ptr> ptr_visit_adaptor<V> { #[inline(always)] - fn bump(sz: uint) { + fn bump(&self, sz: uint) { do self.inner.move_ptr() |p| { ((p as uint) + sz) as *c_void }; } #[inline(always)] - fn align(a: uint) { + fn align(&self, a: uint) { do self.inner.move_ptr() |p| { align(p as uint, a) as *c_void }; } #[inline(always)] - fn align_to<T>() { + fn align_to<T>(&self) { self.align(sys::min_align_of::<T>()); } #[inline(always)] - fn bump_past<T>() { + fn bump_past<T>(&self) { self.bump(sys::size_of::<T>()); } @@ -479,13 +479,13 @@ struct Stuff { } pub impl my_visitor { - fn get<T>(f: &fn(T)) { + fn get<T>(&self, f: &fn(T)) { unsafe { f(*(self.ptr1 as *T)); } } - fn visit_inner(inner: *TyDesc) -> bool { + fn visit_inner(&self, inner: *TyDesc) -> bool { unsafe { let u = my_visitor(*self); let v = ptr_visit_adaptor::<my_visitor>(Inner {inner: u}); @@ -498,7 +498,7 @@ pub impl my_visitor { struct Inner<V> { inner: V } impl movable_ptr for my_visitor { - fn move_ptr(adjustment: &fn(*c_void) -> *c_void) { + fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void) { self.ptr1 = adjustment(self.ptr1); self.ptr2 = adjustment(self.ptr2); } diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 6b5634fbd50..2f4eefe5243 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -13,11 +13,11 @@ struct Clam<'self> { } trait get_chowder<'self> { - fn get_chowder() -> &'self int; + fn get_chowder(&self) -> &'self int; } impl<'self> get_chowder<'self> for Clam<'self> { - fn get_chowder() -> &'self int { return self.chowder; } + fn get_chowder(&self) -> &'self int { return self.chowder; } } pub fn main() { diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index cc12c1b7dd9..db8cfd1a865 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -11,13 +11,13 @@ struct Ctxt { v: uint } trait get_ctxt { - fn get_ctxt() -> &self/Ctxt; + fn get_ctxt(&self) -> &self/Ctxt; } struct HasCtxt { c: &'self Ctxt } impl get_ctxt<'self> for HasCtxt<'self> { - fn get_ctxt() -> &self/Ctxt { + fn get_ctxt(&self) -> &self/Ctxt { self.c } } diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index 074415375dc..db444f08fab 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -19,7 +19,7 @@ impl Drop for shrinky_pointer { } pub impl shrinky_pointer { - fn look_at() -> int { return **(self.i); } + fn look_at(&self) -> int { return **(self.i); } } fn shrinky_pointer(i: @@mut int) -> shrinky_pointer { diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 2ee6f631ea5..fe5a6bd2bd5 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -11,42 +11,42 @@ // xfail-fast pub trait plus { - fn plus() -> int; + fn plus(&self) -> int; } mod a { use plus; - impl plus for uint { fn plus() -> int { self as int + 20 } } + impl plus for uint { fn plus(&self) -> int { self as int + 20 } } } mod b { use plus; - impl plus for ~str { fn plus() -> int { 200 } } + impl plus for ~str { fn plus(&self) -> int { 200 } } } trait uint_utils { - fn str() -> ~str; - fn multi(f: &fn(uint)); + fn str(self) -> ~str; + fn multi(self, f: &fn(uint)); } impl uint_utils for uint { - fn str() -> ~str { uint::to_str(self) } - fn multi(f: &fn(uint)) { + fn str(self) -> ~str { uint::to_str(self) } + fn multi(self, f: &fn(uint)) { let mut c = 0u; while c < self { f(c); c += 1u; } } } trait vec_utils<T> { - fn length_() -> uint; - fn iter_(f: &fn(&T)); - fn map_<U:Copy>(f: &fn(&T) -> U) -> ~[U]; + fn length_(&self, ) -> uint; + fn iter_(&self, f: &fn(&T)); + fn map_<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U]; } impl<T> vec_utils<T> for ~[T] { - fn length_() -> uint { vec::len(self) } - fn iter_(f: &fn(&T)) { for self.each |x| { f(x); } } - fn map_<U:Copy>(f: &fn(&T) -> U) -> ~[U] { + fn length_(&self) -> uint { vec::len(self) } + fn iter_(&self, f: &fn(&T)) { for self.each |x| { f(x); } } + fn map_<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] { let mut r = ~[]; for self.each |elt| { r += ~[f(elt)]; } r diff --git a/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs index f51eb6e1ae2..1146412ec4f 100644 --- a/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs +++ b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs @@ -9,15 +9,15 @@ // except according to those terms. trait Deserializer { - fn read_int() -> int; + fn read_int(&self) -> int; } trait Deserializable<D:Deserializer> { - static fn deserialize(d: &D) -> Self; + static fn deserialize(&self, d: &D) -> Self; } impl<D:Deserializer> Deserializable<D> for int { - static fn deserialize(d: &D) -> int { + static fn deserialize(&self, d: &D) -> int { return d.read_int(); } } @@ -25,7 +25,7 @@ impl<D:Deserializer> Deserializable<D> for int { struct FromThinAir { dummy: () } impl Deserializer for FromThinAir { - fn read_int() -> int { 22 } + fn read_int(&self) -> int { 22 } } pub fn main() { diff --git a/src/test/run-pass/trait-bounds.rs b/src/test/run-pass/trait-bounds.rs index a07e5c6cf3f..6dcd2a41e07 100644 --- a/src/test/run-pass/trait-bounds.rs +++ b/src/test/run-pass/trait-bounds.rs @@ -9,22 +9,22 @@ // except according to those terms. trait connection { - fn read() -> int; + fn read(&self) -> int; } trait connection_factory<C:connection> { - fn create() -> C; + fn create(&self) -> C; } type my_connection = (); type my_connection_factory = (); impl connection for () { - fn read() -> int { 43 } + fn read(&self) -> int { 43 } } impl connection_factory<my_connection> for my_connection_factory { - fn create() -> my_connection { () } + fn create(&self) -> my_connection { () } } pub fn main() { diff --git a/src/test/run-pass/trait-composition-trivial.rs b/src/test/run-pass/trait-composition-trivial.rs index 56645b48218..328c0b6888c 100644 --- a/src/test/run-pass/trait-composition-trivial.rs +++ b/src/test/run-pass/trait-composition-trivial.rs @@ -9,11 +9,11 @@ // except according to those terms. trait Foo { - fn foo(); + fn foo(&self); } trait Bar : Foo { - fn bar(); + fn bar(&self); } pub fn main() {} diff --git a/src/test/run-pass/trait-default-method-bound-subst2.rs b/src/test/run-pass/trait-default-method-bound-subst2.rs index cba45c6bb23..ce72c7e9a44 100644 --- a/src/test/run-pass/trait-default-method-bound-subst2.rs +++ b/src/test/run-pass/trait-default-method-bound-subst2.rs @@ -11,7 +11,7 @@ // xfail-test trait A<T> { - fn g(x: T) -> T { x } + fn g(&self, x: T) -> T { x } } impl A<int> for int { } diff --git a/src/test/run-pass/trait-default-method-bound-subst3.rs b/src/test/run-pass/trait-default-method-bound-subst3.rs index 5a9b4fbb9e6..3c1e6a59d03 100644 --- a/src/test/run-pass/trait-default-method-bound-subst3.rs +++ b/src/test/run-pass/trait-default-method-bound-subst3.rs @@ -11,7 +11,7 @@ #[allow(default_methods)]; trait A { - fn g<T>(x: T, y: T) -> (T, T) { (x, y) } + fn g<T>(&self, x: T, y: T) -> (T, T) { (x, y) } } impl A for int { } diff --git a/src/test/run-pass/trait-default-method-bound-subst4.rs b/src/test/run-pass/trait-default-method-bound-subst4.rs index ee0feafa5c1..9ac66bfb737 100644 --- a/src/test/run-pass/trait-default-method-bound-subst4.rs +++ b/src/test/run-pass/trait-default-method-bound-subst4.rs @@ -11,7 +11,7 @@ #[allow(default_methods)]; trait A<T> { - fn g(x: uint) -> uint { x } + fn g(&self, x: uint) -> uint { x } } impl<T> A<T> for int { } diff --git a/src/test/run-pass/trait-default-method-bound.rs b/src/test/run-pass/trait-default-method-bound.rs index 4c2c030eaab..627bc96e6ae 100644 --- a/src/test/run-pass/trait-default-method-bound.rs +++ b/src/test/run-pass/trait-default-method-bound.rs @@ -11,7 +11,7 @@ #[allow(default_methods)]; trait A { - fn g() -> int { 10 } + fn g(&self) -> int { 10 } } impl A for int { } diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 7b8ebe6d34c..85e706c9fe5 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -11,23 +11,23 @@ // xfail-fast trait to_str { - fn to_str() -> ~str; + fn to_str(&self) -> ~str; } impl to_str for int { - fn to_str() -> ~str { int::to_str(self) } + fn to_str(&self) -> ~str { int::to_str(self) } } impl to_str for ~str { - fn to_str() -> ~str { copy self } + fn to_str(&self) -> ~str { copy self } } impl to_str for () { - fn to_str() -> ~str { ~"()" } + fn to_str(&self) -> ~str { ~"()" } } trait map<T> { - fn map<U:Copy>(f: &fn(&T) -> U) -> ~[U]; + fn map<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U]; } impl<T> map<T> for ~[T] { - fn map<U:Copy>(f: &fn(&T) -> U) -> ~[U] { + fn map<U:Copy>(&self, f: &fn(&T) -> U) -> ~[U] { let mut r = ~[]; for self.each |x| { r += ~[f(x)]; } r diff --git a/src/test/run-pass/trait-inheritance-auto.rs b/src/test/run-pass/trait-inheritance-auto.rs index efc4cfa6156..51a3168f6e8 100644 --- a/src/test/run-pass/trait-inheritance-auto.rs +++ b/src/test/run-pass/trait-inheritance-auto.rs @@ -12,17 +12,17 @@ // A is already a Foo Bar Baz impl<T:Foo + Bar + Baz> Quux for T { } -trait Foo { fn f() -> int; } -trait Bar { fn g() -> int; } -trait Baz { fn h() -> int; } +trait Foo { fn f(&self) -> int; } +trait Bar { fn g(&self) -> int; } +trait Baz { fn h(&self) -> int; } trait Quux: Foo + Bar + Baz { } struct A { x: int } -impl Foo for A { fn f() -> int { 10 } } -impl Bar for A { fn g() -> int { 20 } } -impl Baz for A { fn h() -> int { 30 } } +impl Foo for A { fn f(&self) -> int { 10 } } +impl Bar for A { fn g(&self) -> int { 20 } } +impl Baz for A { fn h(&self) -> int { 30 } } fn f<T:Quux>(a: &T) { fail_unless!(a.f() == 10); diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs index 75dea9c500a..dcc1deed846 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { fn f() -> int; } -trait Bar : Foo { fn g() -> int; } +trait Foo { fn f(&self) -> int; } +trait Bar : Foo { fn g(&self) -> int; } struct A { x: int } -impl Foo for A { fn f() -> int { 10 } } -impl Bar for A { fn g() -> int { 20 } } +impl Foo for A { fn f(&self) -> int { 10 } } +impl Bar for A { fn g(&self) -> int { 20 } } // Call a function on Foo, given a T: Bar fn gg<T:Bar>(a: &T) -> int { diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs index e8d553dae18..ad23cab016e 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { fn f() -> int; } -trait Bar : Foo { fn g() -> int; } -trait Baz : Bar { fn h() -> int; } +trait Foo { fn f(&self) -> int; } +trait Bar : Foo { fn g(&self) -> int; } +trait Baz : Bar { fn h(&self) -> int; } struct A { x: int } -impl Foo for A { fn f() -> int { 10 } } -impl Bar for A { fn g() -> int { 20 } } -impl Baz for A { fn h() -> int { 30 } } +impl Foo for A { fn f(&self) -> int { 10 } } +impl Bar for A { fn g(&self) -> int { 20 } } +impl Baz for A { fn h(&self) -> int { 30 } } // Call a function on Foo, given a T: Baz, // which is inherited via Bar diff --git a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs index 3447cbad84a..39565382118 100644 --- a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs +++ b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs @@ -12,11 +12,11 @@ // methods. Not testing supertrait methods trait Foo { - fn f() -> int; + fn f(&self) -> int; } trait Bar : Foo { - fn g() -> int; + fn g(&self) -> int; } struct A { @@ -24,11 +24,11 @@ struct A { } impl Foo for A { - fn f() -> int { 10 } + fn f(&self) -> int { 10 } } impl Bar for A { - fn g() -> int { 20 } + fn g(&self) -> int { 20 } } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call.rs b/src/test/run-pass/trait-inheritance-cross-trait-call.rs index 47b5f60233b..2cde60ecf58 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { fn f() -> int; } -trait Bar : Foo { fn g() -> int; } +trait Foo { fn f(&self) -> int; } +trait Bar : Foo { fn g(&self) -> int; } struct A { x: int } -impl Foo for A { fn f() -> int { 10 } } +impl Foo for A { fn f(&self) -> int { 10 } } impl Bar for A { // Testing that this impl can call the impl of Foo - fn g() -> int { self.f() } + fn g(&self) -> int { self.f() } } pub fn main() { diff --git a/src/test/run-pass/trait-inheritance-simple.rs b/src/test/run-pass/trait-inheritance-simple.rs index f56a50f1430..9ca3ccaa22c 100644 --- a/src/test/run-pass/trait-inheritance-simple.rs +++ b/src/test/run-pass/trait-inheritance-simple.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { fn f() -> int; } -trait Bar : Foo { fn g() -> int; } +trait Foo { fn f(&self) -> int; } +trait Bar : Foo { fn g(&self) -> int; } struct A { x: int } -impl Foo for A { fn f() -> int { 10 } } -impl Bar for A { fn g() -> int { 20 } } +impl Foo for A { fn f(&self) -> int { 10 } } +impl Bar for A { fn g(&self) -> int { 20 } } fn ff<T:Foo>(a: &T) -> int { a.f() diff --git a/src/test/run-pass/trait-inheritance-subst.rs b/src/test/run-pass/trait-inheritance-subst.rs index 5900805e957..c1ee7a2c00a 100644 --- a/src/test/run-pass/trait-inheritance-subst.rs +++ b/src/test/run-pass/trait-inheritance-subst.rs @@ -9,7 +9,7 @@ // except according to those terms. pub trait Add<RHS,Result> { - pure fn add(rhs: &RHS) -> Result; + pure fn add(&self, rhs: &RHS) -> Result; } trait MyNum : Add<Self,Self> { } @@ -17,7 +17,7 @@ trait MyNum : Add<Self,Self> { } struct MyInt { val: int } impl Add<MyInt, MyInt> for MyInt { - pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) } + pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) } } impl MyNum for MyInt; diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs index 77e15a802e4..20b7d529fae 100644 --- a/src/test/run-pass/trait-inheritance-subst2.rs +++ b/src/test/run-pass/trait-inheritance-subst2.rs @@ -9,11 +9,11 @@ // except according to those terms. trait Panda<T> { - fn chomp(bamboo: &T) -> T; + fn chomp(&self, bamboo: &T) -> T; } trait Add<RHS,Result>: Panda<RHS> { - fn add(rhs: &RHS) -> Result; + fn add(&self, rhs: &RHS) -> Result; } trait MyNum : Add<Self,Self> { } @@ -21,13 +21,13 @@ trait MyNum : Add<Self,Self> { } struct MyInt { val: int } impl Panda<MyInt> for MyInt { - fn chomp(bamboo: &MyInt) -> MyInt { + fn chomp(&self, bamboo: &MyInt) -> MyInt { mi(self.val + bamboo.val) } } impl Add<MyInt, MyInt> for MyInt { - fn add(other: &MyInt) -> MyInt { self.chomp(other) } + fn add(&self, other: &MyInt) -> MyInt { self.chomp(other) } } impl MyNum for MyInt; diff --git a/src/test/run-pass/trait-inheritance-visibility.rs b/src/test/run-pass/trait-inheritance-visibility.rs index 861e9c0c84a..c70c2ecf976 100644 --- a/src/test/run-pass/trait-inheritance-visibility.rs +++ b/src/test/run-pass/trait-inheritance-visibility.rs @@ -9,9 +9,9 @@ // except according to those terms. mod traits { - pub trait Foo { fn f() -> int; } + pub trait Foo { fn f(&self) -> int; } - impl Foo for int { fn f() -> int { 10 } } + impl Foo for int { fn f(&self) -> int { 10 } } } trait Quux: traits::Foo { } diff --git a/src/test/run-pass/trait-inheritance2.rs b/src/test/run-pass/trait-inheritance2.rs index 78e3b43730e..d18452f11fa 100644 --- a/src/test/run-pass/trait-inheritance2.rs +++ b/src/test/run-pass/trait-inheritance2.rs @@ -8,17 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { fn f() -> int; } -trait Bar { fn g() -> int; } -trait Baz { fn h() -> int; } +trait Foo { fn f(&self) -> int; } +trait Bar { fn g(&self) -> int; } +trait Baz { fn h(&self) -> int; } trait Quux: Foo + Bar + Baz { } struct A { x: int } -impl Foo for A { fn f() -> int { 10 } } -impl Bar for A { fn g() -> int { 20 } } -impl Baz for A { fn h() -> int { 30 } } +impl Foo for A { fn f(&self) -> int { 10 } } +impl Bar for A { fn g(&self) -> int { 20 } } +impl Baz for A { fn h(&self) -> int { 30 } } impl Quux for A; fn f<T:Quux + Foo + Bar + Baz>(a: &T) { diff --git a/src/test/run-pass/trait-region-pointer-simple.rs b/src/test/run-pass/trait-region-pointer-simple.rs index d55ca35fff2..1ce2cddc29b 100644 --- a/src/test/run-pass/trait-region-pointer-simple.rs +++ b/src/test/run-pass/trait-region-pointer-simple.rs @@ -9,7 +9,7 @@ // except according to those terms. trait Foo { - fn f() -> int; + fn f(&self) -> int; } struct A { @@ -17,7 +17,7 @@ struct A { } impl Foo for A { - fn f() -> int { + fn f(&self) -> int { io::println(~"Today's number is " + self.x.to_str()); return self.x; } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index 29de9d1df81..d5e1a1f2120 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -17,15 +17,15 @@ extern mod core; use core::{str, int, vec}; trait to_str { - fn to_str() -> ~str; + fn to_str(&self) -> ~str; } impl to_str for int { - fn to_str() -> ~str { int::to_str(self) } + fn to_str(&self) -> ~str { int::to_str(self) } } impl<T:to_str> to_str for ~[T] { - fn to_str() -> ~str { + fn to_str(&self) -> ~str { ~"[" + str::connect(vec::map(self, |e| e.to_str() ), ~", ") + ~"]" } } diff --git a/src/test/run-pass/traits-default-method-macro.rs b/src/test/run-pass/traits-default-method-macro.rs index f3f20cc50be..21e05aba27b 100644 --- a/src/test/run-pass/traits-default-method-macro.rs +++ b/src/test/run-pass/traits-default-method-macro.rs @@ -11,7 +11,7 @@ #[allow(default_methods)]; trait Foo { - fn bar() -> ~str { + fn bar(&self) -> ~str { fmt!("test") } } diff --git a/src/test/run-pass/traits-default-method-trivial.rs b/src/test/run-pass/traits-default-method-trivial.rs index fbfce37242d..8edb83ce60e 100644 --- a/src/test/run-pass/traits-default-method-trivial.rs +++ b/src/test/run-pass/traits-default-method-trivial.rs @@ -11,16 +11,16 @@ #[allow(default_methods)]; trait Cat { - fn meow() -> bool; - fn scratch() -> bool; - fn purr() -> bool { true } + fn meow(&self) -> bool; + fn scratch(&self) -> bool; + fn purr(&self) -> bool { true } } impl Cat for int { - fn meow() -> bool { + fn meow(&self) -> bool { self.scratch() } - fn scratch() -> bool { + fn scratch(&self) -> bool { self.purr() } } diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index 87a62f81e6d..56b03bc4489 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -11,13 +11,13 @@ // Example from lkuper's intern talk, August 2012. trait Equal { - fn isEq(a: Self) -> bool; + fn isEq(&self, a: Self) -> bool; } enum Color { cyan, magenta, yellow, black } impl Equal for Color { - fn isEq(a: Color) -> bool { + fn isEq(&self, a: Color) -> bool { match (self, a) { (cyan, cyan) => { true } (magenta, magenta) => { true } @@ -34,7 +34,7 @@ enum ColorTree { } impl Equal for ColorTree { - fn isEq(a: ColorTree) -> bool { + fn isEq(&self, a: ColorTree) -> bool { match (self, a) { (leaf(x), leaf(y)) => { x.isEq(y) } (branch(l1, r1), branch(l2, r2)) => { diff --git a/src/test/run-pass/use-trait-before-def.rs b/src/test/run-pass/use-trait-before-def.rs index 1bd68bfa4b6..0b59ced98c9 100644 --- a/src/test/run-pass/use-trait-before-def.rs +++ b/src/test/run-pass/use-trait-before-def.rs @@ -10,6 +10,6 @@ // Issue #1761 -impl foo for int { fn foo() -> int { 10 } } -trait foo { fn foo() -> int; } +impl foo for int { fn foo(&self) -> int { 10 } } +trait foo { fn foo(&self) -> int; } pub fn main() {} |
