Skip to content

Commit 5d3559e

Browse files
committed
librustc: Make self and static into keywords
1 parent 06ef889 commit 5d3559e

Some content is hidden

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

51 files changed

+700
-610
lines changed

src/libcore/cell.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ pub fn empty_cell<T>() -> Cell<T> {
4444
pub impl<T> Cell<T> {
4545
/// Yields the value, failing if the cell is empty.
4646
fn take(&self) -> T {
47-
let self = unsafe { transmute_mut(self) };
48-
if self.is_empty() {
47+
let this = unsafe { transmute_mut(self) };
48+
if this.is_empty() {
4949
fail!(~"attempt to take an empty cell");
5050
}
5151
52-
replace(&mut self.value, None).unwrap()
52+
replace(&mut this.value, None).unwrap()
5353
}
5454
5555
/// Returns the value, failing if the cell is full.
5656
fn put_back(&self, value: T) {
57-
let self = unsafe { transmute_mut(self) };
58-
if !self.is_empty() {
57+
let this = unsafe { transmute_mut(self) };
58+
if !this.is_empty() {
5959
fail!(~"attempt to put a value back into a full cell");
6060
}
61-
self.value = Some(value);
61+
this.value = Some(value);
6262
}
6363

6464
/// Returns true if the cell is empty and false if the cell is full.

src/libcore/old_iter.rs

+33-31
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ pub trait Buildable<A> {
116116
}
117117

118118
#[inline(always)]
119-
pub fn _eachi<A,IA:BaseIter<A>>(self: &IA, blk: &fn(uint, &A) -> bool) -> bool {
119+
pub fn _eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool {
120120
let mut i = 0;
121-
for self.each |a| {
122-
if !blk(i, a) { return false; }
121+
for this.each |a| {
122+
if !blk(i, a) {
123+
return false;
124+
}
123125
i += 1;
124126
}
125127
return true;
@@ -135,47 +137,47 @@ pub fn eachi<A,IA:BaseIter<A>>(self: &IA, blk: &fn(uint, &A) -> bool) -> bool {
135137
}
136138

137139
#[inline(always)]
138-
pub fn all<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool {
139-
for self.each |a| {
140+
pub fn all<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
141+
for this.each |a| {
140142
if !blk(a) { return false; }
141143
}
142144
return true;
143145
}
144146

145147
#[inline(always)]
146-
pub fn any<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool {
147-
for self.each |a| {
148+
pub fn any<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
149+
for this.each |a| {
148150
if blk(a) { return true; }
149151
}
150152
return false;
151153
}
152154

153155
#[inline(always)]
154-
pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(self: &IA,
156+
pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(this: &IA,
155157
prd: &fn(&A) -> bool)
156158
-> ~[A] {
157-
do vec::build_sized_opt(self.size_hint()) |push| {
158-
for self.each |a| {
159+
do vec::build_sized_opt(this.size_hint()) |push| {
160+
for this.each |a| {
159161
if prd(a) { push(*a); }
160162
}
161163
}
162164
}
163165

164166
#[inline(always)]
165-
pub fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA, op: &fn(&A) -> B) -> ~[B] {
166-
do vec::build_sized_opt(self.size_hint()) |push| {
167-
for self.each |a| {
167+
pub fn map_to_vec<A,B,IA:BaseIter<A>>(this: &IA, op: &fn(&A) -> B) -> ~[B] {
168+
do vec::build_sized_opt(this.size_hint()) |push| {
169+
for this.each |a| {
168170
push(op(a));
169171
}
170172
}
171173
}
172174

173175
#[inline(always)]
174-
pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(self: &IA,
176+
pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(this: &IA,
175177
op: &fn(&A) -> IB)
176178
-> ~[B] {
177179
do vec::build |push| {
178-
for self.each |a| {
180+
for this.each |a| {
179181
for op(a).each |&b| {
180182
push(b);
181183
}
@@ -184,31 +186,31 @@ pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(self: &IA,
184186
}
185187

186188
#[inline(always)]
187-
pub fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B, blk: &fn(&B, &A) -> B)
189+
pub fn foldl<A,B,IA:BaseIter<A>>(this: &IA, b0: B, blk: &fn(&B, &A) -> B)
188190
-> B {
189191
let mut b = b0;
190-
for self.each |a| {
192+
for this.each |a| {
191193
b = blk(&b, a);
192194
}
193195
b
194196
}
195197

196198
#[inline(always)]
197-
pub fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
198-
map_to_vec(self, |&x| x)
199+
pub fn to_vec<A:Copy,IA:BaseIter<A>>(this: &IA) -> ~[A] {
200+
map_to_vec(this, |&x| x)
199201
}
200202

201203
#[inline(always)]
202-
pub fn contains<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> bool {
203-
for self.each |a| {
204+
pub fn contains<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> bool {
205+
for this.each |a| {
204206
if *a == *x { return true; }
205207
}
206208
return false;
207209
}
208210

209211
#[inline(always)]
210-
pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
211-
do foldl(self, 0) |count, value| {
212+
pub fn count<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> uint {
213+
do foldl(this, 0) |count, value| {
212214
if *value == *x {
213215
*count + 1
214216
} else {
@@ -218,10 +220,10 @@ pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
218220
}
219221

220222
#[inline(always)]
221-
pub fn position<A,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
223+
pub fn position<A,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
222224
-> Option<uint> {
223225
let mut i = 0;
224-
for self.each |a| {
226+
for this.each |a| {
225227
if f(a) { return Some(i); }
226228
i += 1;
227229
}
@@ -253,8 +255,8 @@ pub fn repeat(times: uint, blk: &fn() -> bool) -> bool {
253255
}
254256

255257
#[inline(always)]
256-
pub fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
257-
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
258+
pub fn min<A:Copy + Ord,IA:BaseIter<A>>(this: &IA) -> A {
259+
match do foldl::<A,Option<A>,IA>(this, None) |a, b| {
258260
match a {
259261
&Some(ref a_) if *a_ < *b => {
260262
*(a)
@@ -268,8 +270,8 @@ pub fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
268270
}
269271
270272
#[inline(always)]
271-
pub fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
272-
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
273+
pub fn max<A:Copy + Ord,IA:BaseIter<A>>(this: &IA) -> A {
274+
match do foldl::<A,Option<A>,IA>(this, None) |a, b| {
273275
match a {
274276
&Some(ref a_) if *a_ > *b => {
275277
*(a)
@@ -283,9 +285,9 @@ pub fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
283285
}
284286

285287
#[inline(always)]
286-
pub fn find<A:Copy,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
288+
pub fn find<A:Copy,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
287289
-> Option<A> {
288-
for self.each |i| {
290+
for this.each |i| {
289291
if f(i) { return Some(*i) }
290292
}
291293
return None;

src/libcore/rt/sched/mod.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ pub impl Scheduler {
118118
fn resume_task_from_queue(~self) -> bool {
119119
assert!(!self.in_task_context());
120120

121-
let mut self = self;
122-
match self.task_queue.pop_front() {
121+
let mut this = self;
122+
match this.task_queue.pop_front() {
123123
Some(task) => {
124-
self.resume_task_immediately(task);
124+
this.resume_task_immediately(task);
125125
return true;
126126
}
127127
None => {
128128
rtdebug!("no tasks in queue");
129-
local_sched::put(self);
129+
local_sched::put(this);
130130
return false;
131131
}
132132
}
@@ -165,16 +165,16 @@ pub impl Scheduler {
165165
// Core scheduling ops
166166

167167
fn resume_task_immediately(~self, task: ~Task) {
168-
let mut self = self;
169-
assert!(!self.in_task_context());
168+
let mut this = self;
169+
assert!(!this.in_task_context());
170170

171171
rtdebug!("scheduling a task");
172172

173173
// Store the task in the scheduler so it can be grabbed later
174-
self.current_task = Some(task);
175-
self.enqueue_cleanup_job(DoNothing);
174+
this.current_task = Some(task);
175+
this.enqueue_cleanup_job(DoNothing);
176176

177-
local_sched::put(self);
177+
local_sched::put(this);
178178

179179
// Take pointers to both the task and scheduler's saved registers.
180180
unsafe {
@@ -203,17 +203,17 @@ pub impl Scheduler {
203203
/// running task. It gets transmuted to the scheduler's lifetime
204204
/// and called while the task is blocked.
205205
fn deschedule_running_task_and_then(~self, f: &fn(~Task)) {
206-
let mut self = self;
207-
assert!(self.in_task_context());
206+
let mut this = self;
207+
assert!(this.in_task_context());
208208

209209
rtdebug!("blocking task");
210210

211-
let blocked_task = self.current_task.swap_unwrap();
211+
let blocked_task = this.current_task.swap_unwrap();
212212
let f_fake_region = unsafe { transmute::<&fn(~Task), &fn(~Task)>(f) };
213213
let f_opaque = ClosureConverter::from_fn(f_fake_region);
214-
self.enqueue_cleanup_job(GiveTask(blocked_task, f_opaque));
214+
this.enqueue_cleanup_job(GiveTask(blocked_task, f_opaque));
215215

216-
local_sched::put(self);
216+
local_sched::put(this);
217217

218218
let sched = unsafe { local_sched::unsafe_borrow() };
219219
let (sched_context, last_task_context, _) = sched.get_contexts();
@@ -229,18 +229,18 @@ pub impl Scheduler {
229229
/// You would want to think hard about doing this, e.g. if there are
230230
/// pending I/O events it would be a bad idea.
231231
fn switch_running_tasks_and_then(~self, next_task: ~Task, f: &fn(~Task)) {
232-
let mut self = self;
233-
assert!(self.in_task_context());
232+
let mut this = self;
233+
assert!(this.in_task_context());
234234

235235
rtdebug!("switching tasks");
236236

237-
let old_running_task = self.current_task.swap_unwrap();
237+
let old_running_task = this.current_task.swap_unwrap();
238238
let f_fake_region = unsafe { transmute::<&fn(~Task), &fn(~Task)>(f) };
239239
let f_opaque = ClosureConverter::from_fn(f_fake_region);
240-
self.enqueue_cleanup_job(GiveTask(old_running_task, f_opaque));
241-
self.current_task = Some(next_task);
240+
this.enqueue_cleanup_job(GiveTask(old_running_task, f_opaque));
241+
this.current_task = Some(next_task);
242242

243-
local_sched::put(self);
243+
local_sched::put(this);
244244

245245
unsafe {
246246
let sched = local_sched::unsafe_borrow();

src/libcore/rt/uv/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ pub impl StreamWatcher {
141141

142142
fn close(self, cb: NullCallback) {
143143
{
144-
let mut self = self;
145-
let data = get_watcher_data(&mut self);
144+
let mut this = self;
145+
let data = get_watcher_data(&mut this);
146146
assert!(data.close_cb.is_none());
147147
data.close_cb = Some(cb);
148148
}

src/libcore/rt/uvio.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ pub impl UvEventLoop {
4343
impl Drop for UvEventLoop {
4444
fn finalize(&self) {
4545
// XXX: Need mutable finalizer
46-
let self = unsafe {
46+
let this = unsafe {
4747
transmute::<&UvEventLoop, &mut UvEventLoop>(self)
4848
};
49-
self.uvio.uv_loop().close();
49+
this.uvio.uv_loop().close();
5050
}
5151
}
5252

src/librustc/driver/driver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ pub fn build_session_options(binary: @~str,
632632
let extra_debuginfo = debugging_opts & session::extra_debug_info != 0;
633633
let debuginfo = debugging_opts & session::debug_info != 0 ||
634634
extra_debuginfo;
635-
let static = debugging_opts & session::static != 0;
635+
let statik = debugging_opts & session::statik != 0;
636636
let target =
637637
match target_opt {
638638
None => host_triple(),
@@ -660,7 +660,7 @@ pub fn build_session_options(binary: @~str,
660660
661661
let sopts = @session::options {
662662
crate_type: crate_type,
663-
is_static: static,
663+
is_static: statik,
664664
gc: gc,
665665
optimize: opt_level,
666666
debuginfo: debuginfo,

src/librustc/driver/session.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub static gc: uint = 1 << 18;
6262
pub static jit: uint = 1 << 19;
6363
pub static debug_info: uint = 1 << 20;
6464
pub static extra_debug_info: uint = 1 << 21;
65-
pub static static: uint = 1 << 22;
65+
pub static statik: uint = 1 << 22;
6666
pub static print_link_args: uint = 1 << 23;
6767

6868
pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
@@ -98,7 +98,7 @@ pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
9898
extra_debug_info),
9999
(~"debug-info", ~"Produce debug info (experimental)", debug_info),
100100
(~"static", ~"Use or produce static libraries or binaries " +
101-
"(experimental)", static)
101+
"(experimental)", statik)
102102
]
103103
}
104104

0 commit comments

Comments
 (0)