Skip to content

Commit 366812a

Browse files
committed
librustc: Change self as a type to Self everywhere. r=brson
1 parent 63b2b9c commit 366812a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+87
-90
lines changed

doc/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,10 +1993,10 @@ trait, `self` is a type, and in an impl, `self` is a value. The
19931993
following trait describes types that support an equality operation:
19941994

19951995
~~~~
1996-
// In a trait, `self` refers both to the self argument
1997-
// and to the type implementing the trait
1996+
// In a trait, `self` refers to the self argument.
1997+
// `Self` refers to the type implementing the trait.
19981998
trait Eq {
1999-
fn equals(&self, other: &self) -> bool;
1999+
fn equals(&self, other: &Self) -> bool;
20002000
}
20012001
20022002
// In an impl, `self` refers just to the value of the receiver
@@ -2015,7 +2015,7 @@ the method name with the trait name.
20152015
The compiler will use type inference to decide which implementation to call.
20162016

20172017
~~~~
2018-
trait Shape { static fn new(area: float) -> self; }
2018+
trait Shape { static fn new(area: float) -> Self; }
20192019
# use float::consts::pi;
20202020
# use float::sqrt;
20212021
struct Circle { radius: float }

src/libcore/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Clonable types are copied with the clone method
1313
*/
1414
pub trait Clone {
15-
fn clone(&self) -> self;
15+
fn clone(&self) -> Self;
1616
}
1717

1818
impl (): Clone {

src/libcore/cmp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ and `Eq` to overload the `==` and `!=` operators.
3737
*/
3838
#[lang="eq"]
3939
pub trait Eq {
40-
pure fn eq(&self, other: &self) -> bool;
41-
pure fn ne(&self, other: &self) -> bool;
40+
pure fn eq(&self, other: &Self) -> bool;
41+
pure fn ne(&self, other: &Self) -> bool;
4242
}
4343

4444
/**
@@ -53,10 +53,10 @@ pub trait Eq {
5353
*/
5454
#[lang="ord"]
5555
pub trait Ord {
56-
pure fn lt(&self, other: &self) -> bool;
57-
pure fn le(&self, other: &self) -> bool;
58-
pure fn ge(&self, other: &self) -> bool;
59-
pure fn gt(&self, other: &self) -> bool;
56+
pure fn lt(&self, other: &Self) -> bool;
57+
pure fn le(&self, other: &Self) -> bool;
58+
pure fn ge(&self, other: &Self) -> bool;
59+
pure fn gt(&self, other: &Self) -> bool;
6060
}
6161

6262
#[inline(always)]

src/libcore/container.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ pub trait Set<T>: Mutable {
6868

6969
/// Return true if the set has no elements in common with `other`.
7070
/// This is equivalent to checking for an empty intersection.
71-
pure fn is_disjoint(&self, other: &self) -> bool;
71+
pure fn is_disjoint(&self, other: &Self) -> bool;
7272

7373
/// Return true if the set is a subset of another
74-
pure fn is_subset(&self, other: &self) -> bool;
74+
pure fn is_subset(&self, other: &Self) -> bool;
7575

7676
/// Return true if the set is a superset of another
77-
pure fn is_superset(&self, other: &self) -> bool;
77+
pure fn is_superset(&self, other: &Self) -> bool;
7878

7979
/// Visit the values representing the difference
80-
pure fn difference(&self, other: &self, f: fn(&T) -> bool);
80+
pure fn difference(&self, other: &Self, f: fn(&T) -> bool);
8181

8282
/// Visit the values representing the symmetric difference
83-
pure fn symmetric_difference(&self, other: &self, f: fn(&T) -> bool);
83+
pure fn symmetric_difference(&self, other: &Self, f: fn(&T) -> bool);
8484

8585
/// Visit the values representing the intersection
86-
pure fn intersection(&self, other: &self, f: fn(&T) -> bool);
86+
pure fn intersection(&self, other: &Self, f: fn(&T) -> bool);
8787

8888
/// Visit the values representing the union
89-
pure fn union(&self, other: &self, f: fn(&T) -> bool);
89+
pure fn union(&self, other: &Self, f: fn(&T) -> bool);
9090
}

src/libcore/from_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
use option::Option;
1818

1919
pub trait FromStr {
20-
static pure fn from_str(s: &str) -> Option<self>;
20+
static pure fn from_str(s: &str) -> Option<Self>;
2121
}
2222

src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub trait Buildable<A> {
8585
* onto the sequence being constructed.
8686
*/
8787
static pure fn build_sized(size: uint,
88-
builder: fn(push: pure fn(A))) -> self;
88+
builder: fn(push: pure fn(A))) -> Self;
8989
}
9090

9191
#[inline(always)]

src/libcore/num.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@
1212
1313
pub trait Num {
1414
// FIXME: Trait composition. (#2616)
15-
pure fn add(&self, other: &self) -> self;
16-
pure fn sub(&self, other: &self) -> self;
17-
pure fn mul(&self, other: &self) -> self;
18-
pure fn div(&self, other: &self) -> self;
19-
pure fn modulo(&self, other: &self) -> self;
20-
pure fn neg(&self) -> self;
15+
pure fn add(&self, other: &Self) -> Self;
16+
pure fn sub(&self, other: &Self) -> Self;
17+
pure fn mul(&self, other: &Self) -> Self;
18+
pure fn div(&self, other: &Self) -> Self;
19+
pure fn modulo(&self, other: &Self) -> Self;
20+
pure fn neg(&self) -> Self;
2121

2222
pure fn to_int(&self) -> int;
23-
static pure fn from_int(n: int) -> self;
23+
static pure fn from_int(n: int) -> Self;
2424
}
2525

2626
pub trait IntConvertible {
2727
pure fn to_int(&self) -> int;
28-
static pure fn from_int(n: int) -> self;
28+
static pure fn from_int(n: int) -> Self;
2929
}
3030

3131
pub trait Zero {
32-
static pure fn zero() -> self;
32+
static pure fn zero() -> Self;
3333
}
3434

3535
pub trait One {
36-
static pure fn one() -> self;
36+
static pure fn one() -> Self;
3737
}

src/libcore/path.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,27 @@ pub pure fn PosixPath(s: &str) -> PosixPath {
4848
}
4949

5050
pub trait GenericPath {
51-
52-
static pure fn from_str(&str) -> self;
51+
static pure fn from_str(&str) -> Self;
5352

5453
pure fn dirname() -> ~str;
5554
pure fn filename() -> Option<~str>;
5655
pure fn filestem() -> Option<~str>;
5756
pure fn filetype() -> Option<~str>;
5857

59-
pure fn with_dirname((&str)) -> self;
60-
pure fn with_filename((&str)) -> self;
61-
pure fn with_filestem((&str)) -> self;
62-
pure fn with_filetype((&str)) -> self;
58+
pure fn with_dirname((&str)) -> Self;
59+
pure fn with_filename((&str)) -> Self;
60+
pure fn with_filestem((&str)) -> Self;
61+
pure fn with_filetype((&str)) -> Self;
6362

64-
pure fn dir_path() -> self;
65-
pure fn file_path() -> self;
63+
pure fn dir_path() -> Self;
64+
pure fn file_path() -> Self;
6665

67-
pure fn push((&str)) -> self;
68-
pure fn push_rel((&self)) -> self;
69-
pure fn push_many((&[~str])) -> self;
70-
pure fn pop() -> self;
66+
pure fn push((&str)) -> Self;
67+
pure fn push_rel((&Self)) -> Self;
68+
pure fn push_many((&[~str])) -> Self;
69+
pure fn pop() -> Self;
7170

72-
pure fn normalize() -> self;
71+
pure fn normalize() -> Self;
7372
}
7473

7574
#[cfg(windows)]

src/libcore/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub pure fn ref_eq<T>(thing: &a/T, other: &b/T) -> bool {
187187
pub trait Ptr<T> {
188188
pure fn is_null() -> bool;
189189
pure fn is_not_null() -> bool;
190-
pure fn offset(count: uint) -> self;
190+
pure fn offset(count: uint) -> Self;
191191
}
192192

193193
#[cfg(stage0)]

src/libcore/str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,9 +2119,9 @@ pub mod raw {
21192119
}
21202120

21212121
pub trait Trimmable {
2122-
pure fn trim() -> self;
2123-
pure fn trim_left() -> self;
2124-
pure fn trim_right() -> self;
2122+
pure fn trim() -> Self;
2123+
pure fn trim_left() -> Self;
2124+
pure fn trim_right() -> Self;
21252125
}
21262126

21272127
/// Extension methods for strings

0 commit comments

Comments
 (0)