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

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ enum extended_decode_ctxt {
7777
}
7878

7979
trait tr {
80-
fn tr(xcx: extended_decode_ctxt) -> self;
80+
fn tr(xcx: extended_decode_ctxt) -> Self;
8181
}
8282

8383
trait tr_intern {

src/librustc/middle/resolve.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3581,8 +3581,6 @@ pub impl Resolver {
35813581
// Create a new rib for the self type.
35823582
let self_type_rib = @Rib(NormalRibKind);
35833583
(*self.type_ribs).push(self_type_rib);
3584-
self_type_rib.bindings.insert(self.self_ident,
3585-
dl_def(def_self_ty(item.id)));
35863584
self_type_rib.bindings.insert(self.type_self_ident,
35873585
dl_def(def_self_ty(item.id)));
35883586

src/librustc/middle/typeck/infer/lattice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ use middle::typeck::infer::to_str::InferStr;
5050
use std::list;
5151

5252
pub trait LatticeValue {
53-
static fn sub(cf: &CombineFields, a: &self, b: &self) -> ures;
54-
static fn lub(cf: &CombineFields, a: &self, b: &self) -> cres<self>;
55-
static fn glb(cf: &CombineFields, a: &self, b: &self) -> cres<self>;
53+
static fn sub(cf: &CombineFields, a: &Self, b: &Self) -> ures;
54+
static fn lub(cf: &CombineFields, a: &Self, b: &Self) -> cres<Self>;
55+
static fn glb(cf: &CombineFields, a: &Self, b: &Self) -> cres<Self>;
5656
}
5757

5858
pub type LatticeOp<T> = &fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;

src/librustc/middle/typeck/infer/unify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct Node<V, T> {
3939

4040
pub trait UnifyVid<T> {
4141
static fn appropriate_vals_and_bindings(infcx: &v/InferCtxt)
42-
-> &v/ValsAndBindings<self, T>;
42+
-> &v/ValsAndBindings<Self, T>;
4343
}
4444

4545
pub impl InferCtxt {
@@ -136,7 +136,7 @@ pub impl InferCtxt {
136136
// doesn't have a subtyping relationship we need to worry about.
137137

138138
pub trait SimplyUnifiable {
139-
static fn to_type_err(expected_found<self>) -> ty::type_err;
139+
static fn to_type_err(expected_found<Self>) -> ty::type_err;
140140
}
141141

142142
pub fn mk_err<T: SimplyUnifiable>(+a_is_expected: bool,

src/libstd/cmp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use core::float;
1818
const fuzzy_epsilon: float = 1.0e-6;
1919

2020
pub trait FuzzyEq {
21-
pure fn fuzzy_eq(&self, other: &self) -> bool;
22-
pure fn fuzzy_eq_eps(&self, other: &self, epsilon: &self) -> bool;
21+
pure fn fuzzy_eq(&self, other: &Self) -> bool;
22+
pure fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Self) -> bool;
2323
}
2424

2525
impl float: FuzzyEq {

src/libstd/flatpipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,11 @@ pub mod flatteners {
467467
}
468468

469469
pub trait FromReader {
470-
static fn from_reader(r: Reader) -> self;
470+
static fn from_reader(r: Reader) -> Self;
471471
}
472472

473473
pub trait FromWriter {
474-
static fn from_writer(w: Writer) -> self;
474+
static fn from_writer(w: Writer) -> Self;
475475
}
476476

477477
impl json::Decoder: FromReader {

src/libstd/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub trait Encodable<S: Encoder> {
111111
}
112112

113113
pub trait Decodable<D: Decoder> {
114-
static fn decode(&self, d: &D) -> self;
114+
static fn decode(&self, d: &D) -> Self;
115115
}
116116

117117
pub impl<S: Encoder> uint: Encodable<S> {

src/libsyntax/codemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use core::vec;
3434
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
3535

3636
pub trait Pos {
37-
static pure fn from_uint(n: uint) -> self;
37+
static pure fn from_uint(n: uint) -> Self;
3838
pure fn to_uint(&self) -> uint;
3939
}
4040

src/test/auxiliary/static-methods-crate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#[crate_type = "lib"];
1515

1616
pub trait read {
17-
static fn readMaybe(s: ~str) -> Option<self>;
17+
static fn readMaybe(s: ~str) -> Option<Self>;
1818
}
1919

2020
impl int: read {

src/test/auxiliary/static_fn_inline_xc_aux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
pub mod num {
1313
pub trait Num2 {
14-
static pure fn from_int2(n: int) -> self;
14+
static pure fn from_int2(n: int) -> Self;
1515
}
1616
}
1717

src/test/auxiliary/static_fn_trait_xc_aux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub mod num {
22
pub trait Num2 {
3-
static pure fn from_int2(n: int) -> self;
3+
static pure fn from_int2(n: int) -> Self;
44
}
55
}
66

src/test/auxiliary/trait_inheritance_overloading_xc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use cmp::Eq;
1212

13-
pub trait MyNum : Add<self,self> Sub<self,self> Mul<self,self> Eq {
13+
pub trait MyNum : Add<Self,Self> Sub<Self,Self> Mul<Self,Self> Eq {
1414
}
1515

1616
pub struct MyInt {

src/test/compile-fail/infinite-instantiation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// issue 2258
1313

1414
trait to_opt {
15-
fn to_option() -> Option<self>;
15+
fn to_option() -> Option<Self>;
1616
}
1717

1818
impl uint: to_opt {

src/test/compile-fail/missing-derivable-attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
trait MyEq {
12-
pure fn eq(&self, other: &self) -> bool;
12+
pure fn eq(&self, other: &Self) -> bool;
1313
}
1414

1515
struct A {

src/test/compile-fail/selftype-astparam.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
trait add {
12-
fn plus(++x: self) -> self;
12+
fn plus(++x: Self) -> Self;
1313
}
1414

1515
impl int: add {

src/test/compile-fail/selftype-traittype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
trait add {
12-
fn plus(x: self) -> self;
12+
fn plus(x: Self) -> Self;
1313
}
1414

1515
fn do_add(x: add, y: add) -> add {

src/test/compile-fail/trait-impl-different-num-params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
trait foo {
12-
fn bar(x: uint) -> self;
12+
fn bar(x: uint) -> Self;
1313
}
1414
impl int: foo {
1515
fn bar() -> int {

src/test/compile-fail/trait-test-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
trait bar { fn dup() -> self; fn blah<X>(); }
11+
trait bar { fn dup() -> Self; fn blah<X>(); }
1212
impl int: bar { fn dup() -> int { self } fn blah<X>() {} }
1313
impl uint: bar { fn dup() -> uint { self } fn blah<X>() {} }
1414

0 commit comments

Comments
 (0)