librustc: Remove implicit self from the language, except for old-style drop blocks.
This commit is contained in:
parent
a410652bc9
commit
8fa66e8e07
133 changed files with 339 additions and 395 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// error-pattern:missing method `eat`
|
||||
trait animal {
|
||||
fn eat();
|
||||
fn eat(&self);
|
||||
}
|
||||
|
||||
struct cat {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
|
|||
|
|
@ -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); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ mod my_mod {
|
|||
MyStruct {priv_field: 4}
|
||||
}
|
||||
pub impl MyStruct {
|
||||
priv fn happyfun() {}
|
||||
priv fn happyfun(&self) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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>`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ struct cat {
|
|||
}
|
||||
|
||||
pub impl cat {
|
||||
fn eat() {
|
||||
fn eat(&self) {
|
||||
self.how_hungry -= 5;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ mod a {
|
|||
}
|
||||
|
||||
pub impl Foo {
|
||||
priv fn foo() {}
|
||||
priv fn foo(&self) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue