Skip to content

Commit 7309158

Browse files
committed
auto merge of #10135 : alexcrichton/rust/snapshots, r=thestinger
Plus some migration from `let mut this = self` to `mut self` (yay!)
2 parents 671ab42 + 2290131 commit 7309158

File tree

8 files changed

+98
-119
lines changed

8 files changed

+98
-119
lines changed

src/libextra/future.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ impl<A:Clone> Future<A> {
5151

5252
impl<A> Future<A> {
5353
/// Gets the value from this future, forcing evaluation.
54-
pub fn unwrap(self) -> A {
55-
let mut this = self;
56-
this.get_ref();
57-
let state = replace(&mut this.state, Evaluating);
54+
pub fn unwrap(mut self) -> A {
55+
self.get_ref();
56+
let state = replace(&mut self.state, Evaluating);
5857
match state {
5958
Forced(v) => v,
6059
_ => fail!( "Logic error." ),

src/libstd/rt/comm.rs

+17-23
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<T> ChanOne<T> {
113113

114114
// 'do_resched' configures whether the scheduler immediately switches to
115115
// the receiving task, or leaves the sending task still running.
116-
fn try_send_inner(self, val: T, do_resched: bool) -> bool {
116+
fn try_send_inner(mut self, val: T, do_resched: bool) -> bool {
117117
if do_resched {
118118
rtassert!(!rt::in_sched_context());
119119
}
@@ -129,9 +129,8 @@ impl<T> ChanOne<T> {
129129
sched.maybe_yield();
130130
}
131131

132-
let mut this = self;
133132
let mut recvr_active = true;
134-
let packet = this.packet();
133+
let packet = self.packet();
135134

136135
unsafe {
137136

@@ -150,15 +149,15 @@ impl<T> ChanOne<T> {
150149
// done with the packet. NB: In case of do_resched, this *must*
151150
// happen before waking up a blocked task (or be unkillable),
152151
// because we might get a kill signal during the reschedule.
153-
this.suppress_finalize = true;
152+
self.suppress_finalize = true;
154153

155154
match oldstate {
156155
STATE_BOTH => {
157156
// Port is not waiting yet. Nothing to do
158157
}
159158
STATE_ONE => {
160159
// Port has closed. Need to clean up.
161-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
160+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
162161
recvr_active = false;
163162
}
164163
task_as_state => {
@@ -202,22 +201,20 @@ impl<T> PortOne<T> {
202201
}
203202

204203
/// As `recv`, but returns `None` if the send end is closed rather than failing.
205-
pub fn try_recv(self) -> Option<T> {
206-
let mut this = self;
207-
204+
pub fn try_recv(mut self) -> Option<T> {
208205
// Optimistic check. If data was sent already, we don't even need to block.
209206
// No release barrier needed here; we're not handing off our task pointer yet.
210-
if !this.optimistic_check() {
207+
if !self.optimistic_check() {
211208
// No data available yet.
212209
// Switch to the scheduler to put the ~Task into the Packet state.
213210
let sched: ~Scheduler = Local::take();
214211
do sched.deschedule_running_task_and_then |sched, task| {
215-
this.block_on(sched, task);
212+
self.block_on(sched, task);
216213
}
217214
}
218215

219216
// Task resumes.
220-
this.recv_ready()
217+
self.recv_ready()
221218
}
222219
}
223220

@@ -325,9 +322,8 @@ impl<T> SelectInner for PortOne<T> {
325322
impl<T> Select for PortOne<T> { }
326323

327324
impl<T> SelectPortInner<T> for PortOne<T> {
328-
fn recv_ready(self) -> Option<T> {
329-
let mut this = self;
330-
let packet = this.packet();
325+
fn recv_ready(mut self) -> Option<T> {
326+
let packet = self.packet();
331327

332328
// No further memory barrier is needed here to access the
333329
// payload. Some scenarios:
@@ -348,9 +344,9 @@ impl<T> SelectPortInner<T> for PortOne<T> {
348344
let payload = (*packet).payload.take();
349345

350346
// The sender has closed up shop. Drop the packet.
351-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
347+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
352348
// Suppress the synchronizing actions in the finalizer. We're done with the packet.
353-
this.suppress_finalize = true;
349+
self.suppress_finalize = true;
354350
return payload;
355351
}
356352
}
@@ -378,18 +374,17 @@ impl<T> Drop for ChanOne<T> {
378374
if self.suppress_finalize { return }
379375

380376
unsafe {
381-
let this = cast::transmute_mut(self);
382-
let oldstate = (*this.packet()).state.swap(STATE_ONE, SeqCst);
377+
let oldstate = (*self.packet()).state.swap(STATE_ONE, SeqCst);
383378
match oldstate {
384379
STATE_BOTH => {
385380
// Port still active. It will destroy the Packet.
386381
},
387382
STATE_ONE => {
388-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
383+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
389384
},
390385
task_as_state => {
391386
// The port is blocked waiting for a message we will never send. Wake it.
392-
rtassert!((*this.packet()).payload.is_none());
387+
rtassert!((*self.packet()).payload.is_none());
393388
let recvr = BlockedTask::cast_from_uint(task_as_state);
394389
do recvr.wake().map |woken_task| {
395390
Scheduler::run_task(woken_task);
@@ -406,14 +401,13 @@ impl<T> Drop for PortOne<T> {
406401
if self.suppress_finalize { return }
407402

408403
unsafe {
409-
let this = cast::transmute_mut(self);
410-
let oldstate = (*this.packet()).state.swap(STATE_ONE, SeqCst);
404+
let oldstate = (*self.packet()).state.swap(STATE_ONE, SeqCst);
411405
match oldstate {
412406
STATE_BOTH => {
413407
// Chan still active. It will destroy the packet.
414408
},
415409
STATE_ONE => {
416-
let _packet: ~Packet<T> = cast::transmute(this.void_packet);
410+
let _packet: ~Packet<T> = cast::transmute(self.void_packet);
417411
}
418412
task_as_state => {
419413
// This case occurs during unwinding, when the blocked

0 commit comments

Comments
 (0)