Skip to content

Commit 00c70d1

Browse files
committedJul 17, 2014
librustc: Allow the new UFCS explicit self in trait definitions, and
remove `~self` from the test suite.
1 parent fe49cbe commit 00c70d1

22 files changed

+31
-31
lines changed
 

‎src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ impl Clean<Item> for ty::Method {
10031003
};
10041004
let s = match s {
10051005
ty::ByReferenceExplicitSelfCategory(..) => {
1006-
match ty::get(*self.fty.sig.inputs[0]).sty {
1006+
match ty::get(self.fty.sig.inputs[0]).sty {
10071007
ty::ty_rptr(r, mt) => {
10081008
SelfBorrowed(r.clean(), mt.mutbl.clean())
10091009
}

‎src/test/compile-fail/issue-5153.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// error-pattern: type `&Foo` does not implement any method in scope named `foo`
1212

1313
trait Foo {
14-
fn foo(~self);
14+
fn foo(self: Box<Self>);
1515
}
1616

1717
impl Foo for int {
18-
fn foo(~self) { }
18+
fn foo(self: Box<int>) { }
1919
}
2020

2121
fn main() {

‎src/test/compile-fail/lint-unused-mut-self.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
struct Foo;
1717
impl Foo {
1818
fn foo(mut self) {} //~ ERROR: variable does not need to be mutable
19-
fn bar(mut ~self) {} //~ ERROR: variable does not need to be mutable
19+
fn bar(mut self: Box<Foo>) {} //~ ERROR: variable does not need to be mutable
2020
}
2121

2222
fn main() {}

‎src/test/compile-fail/object-pointer-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait Foo {
1313
fn borrowed(&self);
1414
fn borrowed_mut(&mut self);
1515

16-
fn owned(~self);
16+
fn owned(self: Box<Self>);
1717
}
1818

1919
fn borrowed_receiver(x: &Foo) {

‎src/test/debuginfo/generic-method-on-generic-struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl<T1> Struct<T1> {
134134
arg1
135135
}
136136

137-
fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int {
137+
fn self_owned<T2>(self: Box<Struct<T1>>, arg1: int, arg2: T2) -> int {
138138
zzz(); // #break
139139
arg1
140140
}

‎src/test/debuginfo/method-on-enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl Enum {
136136
arg1 + arg2
137137
}
138138

139-
fn self_owned(~self, arg1: int, arg2: int) -> int {
139+
fn self_owned(self: Box<Enum>, arg1: int, arg2: int) -> int {
140140
zzz(); // #break
141141
arg1 + arg2
142142
}

‎src/test/debuginfo/method-on-generic-struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl<T> Struct<T> {
134134
arg1 + arg2
135135
}
136136

137-
fn self_owned(~self, arg1: int, arg2: int) -> int {
137+
fn self_owned(self: Box<Struct<T>>, arg1: int, arg2: int) -> int {
138138
zzz(); // #break
139139
arg1 + arg2
140140
}

‎src/test/debuginfo/method-on-struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl Struct {
133133
self.x + arg1 + arg2
134134
}
135135

136-
fn self_owned(~self, arg1: int, arg2: int) -> int {
136+
fn self_owned(self: Box<Struct>, arg1: int, arg2: int) -> int {
137137
zzz(); // #break
138138
self.x + arg1 + arg2
139139
}

‎src/test/debuginfo/method-on-trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct Struct {
124124
trait Trait {
125125
fn self_by_ref(&self, arg1: int, arg2: int) -> int;
126126
fn self_by_val(self, arg1: int, arg2: int) -> int;
127-
fn self_owned(~self, arg1: int, arg2: int) -> int;
127+
fn self_owned(self: Box<Self>, arg1: int, arg2: int) -> int;
128128
}
129129

130130
impl Trait for Struct {
@@ -139,7 +139,7 @@ impl Trait for Struct {
139139
self.x + arg1 + arg2
140140
}
141141

142-
fn self_owned(~self, arg1: int, arg2: int) -> int {
142+
fn self_owned(self: Box<Struct>, arg1: int, arg2: int) -> int {
143143
zzz(); // #break
144144
self.x + arg1 + arg2
145145
}

‎src/test/debuginfo/method-on-tuple-struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl TupleStruct {
131131
arg1 + arg2
132132
}
133133

134-
fn self_owned(~self, arg1: int, arg2: int) -> int {
134+
fn self_owned(self: Box<TupleStruct>, arg1: int, arg2: int) -> int {
135135
zzz(); // #break
136136
arg1 + arg2
137137
}

‎src/test/debuginfo/self-in-default-method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ trait Trait {
133133
arg1 + arg2
134134
}
135135

136-
fn self_owned(~self, arg1: int, arg2: int) -> int {
136+
fn self_owned(self: Box<Self>, arg1: int, arg2: int) -> int {
137137
zzz(); // #break
138138
arg1 + arg2
139139
}

‎src/test/debuginfo/self-in-generic-default-method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ trait Trait {
134134
arg1
135135
}
136136

137-
fn self_owned<T>(~self, arg1: int, arg2: T) -> int {
137+
fn self_owned<T>(self: Box<Self>, arg1: int, arg2: T) -> int {
138138
zzz(); // #break
139139
arg1
140140
}

‎src/test/run-pass/autoderef-method-on-trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111

1212
trait double {
13-
fn double(~self) -> uint;
13+
fn double(self: Box<Self>) -> uint;
1414
}
1515

1616
impl double for uint {
17-
fn double(~self) -> uint { *self * 2u }
17+
fn double(self: Box<uint>) -> uint { *self * 2u }
1818
}
1919

2020
pub fn main() {

‎src/test/run-pass/autoderef-method-twice-but-not-thrice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111

1212
trait double {
13-
fn double(~self) -> uint;
13+
fn double(self: Box<Self>) -> uint;
1414
}
1515

1616
impl double for Box<uint> {
17-
fn double(~self) -> uint { **self * 2u }
17+
fn double(self: Box<Box<uint>>) -> uint { **self * 2u }
1818
}
1919

2020
pub fn main() {

‎src/test/run-pass/autoderef-method-twice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// except according to those terms.
1010

1111
trait double {
12-
fn double(~self) -> uint;
12+
fn double(self: Box<Self>) -> uint;
1313
}
1414

1515
impl double for uint {
16-
fn double(~self) -> uint { *self * 2u }
16+
fn double(self: Box<uint>) -> uint { *self * 2u }
1717
}
1818

1919
pub fn main() {

‎src/test/run-pass/autoderef-method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// except according to those terms.
1010

1111
trait double {
12-
fn double(~self) -> uint;
12+
fn double(self: Box<Self>) -> uint;
1313
}
1414

1515
impl double for uint {
16-
fn double(~self) -> uint { *self * 2u }
16+
fn double(self: Box<uint>) -> uint { *self * 2u }
1717
}
1818

1919
pub fn main() {

‎src/test/run-pass/explicit-self-objects-uniq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111

1212
trait Foo {
13-
fn f(~self);
13+
fn f(self: Box<Self>);
1414
}
1515

1616
struct S {
1717
x: int
1818
}
1919

2020
impl Foo for S {
21-
fn f(~self) {
21+
fn f(self: Box<S>) {
2222
assert_eq!(self.x, 3);
2323
}
2424
}

‎src/test/run-pass/explicit-self.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn thing(x: A) -> thing {
5757
}
5858

5959
impl thing {
60-
pub fn bar(~self) -> int { self.x.a }
60+
pub fn bar(self: Box<thing>) -> int { self.x.a }
6161
pub fn quux(&self) -> int { self.x.a }
6262
pub fn baz<'a>(&'a self) -> &'a A { &self.x }
6363
pub fn spam(self) -> int { self.x.a }

‎src/test/run-pass/issue-7320.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
trait Foo {
13-
fn foo(~self) { bar(self as Box<Foo>); }
13+
fn foo(self: Box<Self>) { bar(self as Box<Foo>); }
1414
}
1515

1616
fn bar(_b: Box<Foo>) { }

‎src/test/run-pass/objects-owned-object-owned-method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515

1616
trait FooTrait {
17-
fn foo(~self) -> uint;
17+
fn foo(self: Box<Self>) -> uint;
1818
}
1919

2020
struct BarStruct {
2121
x: uint
2222
}
2323

2424
impl FooTrait for BarStruct {
25-
fn foo(~self) -> uint {
25+
fn foo(self: Box<BarStruct>) -> uint {
2626
self.x
2727
}
2828
}

‎src/test/run-pass/self-in-mut-slot-default-method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait Changer {
1919
self
2020
}
2121

22-
fn change_again(mut ~self) -> Box<Self> {
22+
fn change_again(mut self: Box<Self>) -> Box<Self> {
2323
self.set_to(45);
2424
self
2525
}

‎src/test/run-pass/uniq-self-in-mut-slot.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ struct X {
1414
}
1515

1616
trait Changer {
17-
fn change(mut ~self) -> Box<Self>;
17+
fn change(mut self: Box<Self>) -> Box<Self>;
1818
}
1919

2020
impl Changer for X {
21-
fn change(mut ~self) -> Box<X> {
21+
fn change(mut self: Box<X>) -> Box<X> {
2222
self.a = 55;
2323
self
2424
}

0 commit comments

Comments
 (0)