Skip to content

Commit

Permalink
librustc: Allow the new UFCS explicit self in trait definitions, and
Browse files Browse the repository at this point in the history
remove `~self` from the test suite.
  • Loading branch information
pcwalton committed Jul 17, 2014
1 parent fe49cbe commit 00c70d1
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Expand Up @@ -1003,7 +1003,7 @@ impl Clean<Item> for ty::Method {
};
let s = match s {
ty::ByReferenceExplicitSelfCategory(..) => {
match ty::get(*self.fty.sig.inputs[0]).sty {
match ty::get(self.fty.sig.inputs[0]).sty {
ty::ty_rptr(r, mt) => {
SelfBorrowed(r.clean(), mt.mutbl.clean())
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-5153.rs
Expand Up @@ -11,11 +11,11 @@
// error-pattern: type `&Foo` does not implement any method in scope named `foo`

trait Foo {
fn foo(~self);
fn foo(self: Box<Self>);
}

impl Foo for int {
fn foo(~self) { }
fn foo(self: Box<int>) { }
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/lint-unused-mut-self.rs
Expand Up @@ -16,7 +16,7 @@
struct Foo;
impl Foo {
fn foo(mut self) {} //~ ERROR: variable does not need to be mutable
fn bar(mut ~self) {} //~ ERROR: variable does not need to be mutable
fn bar(mut self: Box<Foo>) {} //~ ERROR: variable does not need to be mutable
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/object-pointer-types.rs
Expand Up @@ -13,7 +13,7 @@ trait Foo {
fn borrowed(&self);
fn borrowed_mut(&mut self);

fn owned(~self);
fn owned(self: Box<Self>);
}

fn borrowed_receiver(x: &Foo) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/generic-method-on-generic-struct.rs
Expand Up @@ -134,7 +134,7 @@ impl<T1> Struct<T1> {
arg1
}

fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int {
fn self_owned<T2>(self: Box<Struct<T1>>, arg1: int, arg2: T2) -> int {
zzz(); // #break
arg1
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-enum.rs
Expand Up @@ -136,7 +136,7 @@ impl Enum {
arg1 + arg2
}

fn self_owned(~self, arg1: int, arg2: int) -> int {
fn self_owned(self: Box<Enum>, arg1: int, arg2: int) -> int {
zzz(); // #break
arg1 + arg2
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-generic-struct.rs
Expand Up @@ -134,7 +134,7 @@ impl<T> Struct<T> {
arg1 + arg2
}

fn self_owned(~self, arg1: int, arg2: int) -> int {
fn self_owned(self: Box<Struct<T>>, arg1: int, arg2: int) -> int {
zzz(); // #break
arg1 + arg2
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-struct.rs
Expand Up @@ -133,7 +133,7 @@ impl Struct {
self.x + arg1 + arg2
}

fn self_owned(~self, arg1: int, arg2: int) -> int {
fn self_owned(self: Box<Struct>, arg1: int, arg2: int) -> int {
zzz(); // #break
self.x + arg1 + arg2
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/debuginfo/method-on-trait.rs
Expand Up @@ -124,7 +124,7 @@ struct Struct {
trait Trait {
fn self_by_ref(&self, arg1: int, arg2: int) -> int;
fn self_by_val(self, arg1: int, arg2: int) -> int;
fn self_owned(~self, arg1: int, arg2: int) -> int;
fn self_owned(self: Box<Self>, arg1: int, arg2: int) -> int;
}

impl Trait for Struct {
Expand All @@ -139,7 +139,7 @@ impl Trait for Struct {
self.x + arg1 + arg2
}

fn self_owned(~self, arg1: int, arg2: int) -> int {
fn self_owned(self: Box<Struct>, arg1: int, arg2: int) -> int {
zzz(); // #break
self.x + arg1 + arg2
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/method-on-tuple-struct.rs
Expand Up @@ -131,7 +131,7 @@ impl TupleStruct {
arg1 + arg2
}

fn self_owned(~self, arg1: int, arg2: int) -> int {
fn self_owned(self: Box<TupleStruct>, arg1: int, arg2: int) -> int {
zzz(); // #break
arg1 + arg2
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/self-in-default-method.rs
Expand Up @@ -133,7 +133,7 @@ trait Trait {
arg1 + arg2
}

fn self_owned(~self, arg1: int, arg2: int) -> int {
fn self_owned(self: Box<Self>, arg1: int, arg2: int) -> int {
zzz(); // #break
arg1 + arg2
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/self-in-generic-default-method.rs
Expand Up @@ -134,7 +134,7 @@ trait Trait {
arg1
}

fn self_owned<T>(~self, arg1: int, arg2: T) -> int {
fn self_owned<T>(self: Box<Self>, arg1: int, arg2: T) -> int {
zzz(); // #break
arg1
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/autoderef-method-on-trait.rs
Expand Up @@ -10,11 +10,11 @@


trait double {
fn double(~self) -> uint;
fn double(self: Box<Self>) -> uint;
}

impl double for uint {
fn double(~self) -> uint { *self * 2u }
fn double(self: Box<uint>) -> uint { *self * 2u }
}

pub fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/autoderef-method-twice-but-not-thrice.rs
Expand Up @@ -10,11 +10,11 @@


trait double {
fn double(~self) -> uint;
fn double(self: Box<Self>) -> uint;
}

impl double for Box<uint> {
fn double(~self) -> uint { **self * 2u }
fn double(self: Box<Box<uint>>) -> uint { **self * 2u }
}

pub fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/autoderef-method-twice.rs
Expand Up @@ -9,11 +9,11 @@
// except according to those terms.

trait double {
fn double(~self) -> uint;
fn double(self: Box<Self>) -> uint;
}

impl double for uint {
fn double(~self) -> uint { *self * 2u }
fn double(self: Box<uint>) -> uint { *self * 2u }
}

pub fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/autoderef-method.rs
Expand Up @@ -9,11 +9,11 @@
// except according to those terms.

trait double {
fn double(~self) -> uint;
fn double(self: Box<Self>) -> uint;
}

impl double for uint {
fn double(~self) -> uint { *self * 2u }
fn double(self: Box<uint>) -> uint { *self * 2u }
}

pub fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/explicit-self-objects-uniq.rs
Expand Up @@ -10,15 +10,15 @@


trait Foo {
fn f(~self);
fn f(self: Box<Self>);
}

struct S {
x: int
}

impl Foo for S {
fn f(~self) {
fn f(self: Box<S>) {
assert_eq!(self.x, 3);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/explicit-self.rs
Expand Up @@ -57,7 +57,7 @@ fn thing(x: A) -> thing {
}

impl thing {
pub fn bar(~self) -> int { self.x.a }
pub fn bar(self: Box<thing>) -> int { self.x.a }
pub fn quux(&self) -> int { self.x.a }
pub fn baz<'a>(&'a self) -> &'a A { &self.x }
pub fn spam(self) -> int { self.x.a }
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/issue-7320.rs
Expand Up @@ -10,7 +10,7 @@


trait Foo {
fn foo(~self) { bar(self as Box<Foo>); }
fn foo(self: Box<Self>) { bar(self as Box<Foo>); }
}

fn bar(_b: Box<Foo>) { }
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/objects-owned-object-owned-method.rs
Expand Up @@ -14,15 +14,15 @@


trait FooTrait {
fn foo(~self) -> uint;
fn foo(self: Box<Self>) -> uint;
}

struct BarStruct {
x: uint
}

impl FooTrait for BarStruct {
fn foo(~self) -> uint {
fn foo(self: Box<BarStruct>) -> uint {
self.x
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/self-in-mut-slot-default-method.rs
Expand Up @@ -19,7 +19,7 @@ trait Changer {
self
}

fn change_again(mut ~self) -> Box<Self> {
fn change_again(mut self: Box<Self>) -> Box<Self> {
self.set_to(45);
self
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/uniq-self-in-mut-slot.rs
Expand Up @@ -14,11 +14,11 @@ struct X {
}

trait Changer {
fn change(mut ~self) -> Box<Self>;
fn change(mut self: Box<Self>) -> Box<Self>;
}

impl Changer for X {
fn change(mut ~self) -> Box<X> {
fn change(mut self: Box<X>) -> Box<X> {
self.a = 55;
self
}
Expand Down

5 comments on commit 00c70d1

@bors
Copy link
Contributor

@bors bors commented on 00c70d1 Jul 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pnkfelix
at pcwalton@00c70d1

@bors
Copy link
Contributor

@bors bors commented on 00c70d1 Jul 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging pcwalton/rust/explicit-self = 00c70d1 into auto

@bors
Copy link
Contributor

@bors bors commented on 00c70d1 Jul 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pcwalton/rust/explicit-self = 00c70d1 merged ok, testing candidate = 32cb44b

@bors
Copy link
Contributor

@bors bors commented on 00c70d1 Jul 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 32cb44b

Please sign in to comment.