mirror of https://github.com/rust-lang/rust.git
librustc: Allow the new UFCS explicit self in trait definitions, and
remove `~self` from the test suite.
This commit is contained in:
parent
fe49cbeb82
commit
00c70d1a80
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
trait Foo {
|
||||
fn f(~self);
|
||||
fn f(self: Box<Self>);
|
||||
}
|
||||
|
||||
struct S {
|
||||
|
@ -18,7 +18,7 @@ struct S {
|
|||
}
|
||||
|
||||
impl Foo for S {
|
||||
fn f(~self) {
|
||||
fn f(self: Box<S>) {
|
||||
assert_eq!(self.x, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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>) { }
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
trait FooTrait {
|
||||
fn foo(~self) -> uint;
|
||||
fn foo(self: Box<Self>) -> uint;
|
||||
}
|
||||
|
||||
struct BarStruct {
|
||||
|
@ -22,7 +22,7 @@ struct BarStruct {
|
|||
}
|
||||
|
||||
impl FooTrait for BarStruct {
|
||||
fn foo(~self) -> uint {
|
||||
fn foo(self: Box<BarStruct>) -> uint {
|
||||
self.x
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue