Skip to content

Commit 6089a84

Browse files
committed
---
yaml --- r: 46543 b: refs/heads/auto c: 4a9d4aa h: refs/heads/master i: 46541: 2b8ab80 46539: ff05822 46535: 59986d7 46527: 6dadc60 v: v3
1 parent 2b491ad commit 6089a84

File tree

80 files changed

+300
-531
lines changed

Some content is hidden

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

80 files changed

+300
-531
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 42b0bacd76a9242fd44b2ec3e982d42f81dec6e8
17+
refs/heads/auto: 4a9d4aa52e70eba52dad0719ed6e1eca95f1a2cc

branches/auto/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ let mut x = 5;
556556
loop {
557557
x += x - 3;
558558
if x % 5 == 0 { break; }
559-
io::println(int::to_str(x));
559+
io::println(int::str(x));
560560
}
561561
~~~~
562562

branches/auto/src/libstd/cell.rs renamed to branches/auto/src/libcore/cell.rs

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

11-
use core::option;
12-
use core::prelude::*;
11+
use option;
12+
use prelude::*;
1313

1414
/// A dynamic, mutable location.
1515
///

branches/auto/src/libcore/core.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Implicitly, all crates behave as if they included the following prologue:
5151
#[warn(vecs_implicitly_copyable)];
5252
#[deny(non_camel_case_types)];
5353
#[allow(deprecated_self)];
54+
#[allow(deprecated_mutable_fields)];
5455

5556
/* The Prelude. */
5657

@@ -142,6 +143,7 @@ pub mod dlist;
142143
#[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"]
143144
pub mod dlist_iter;
144145
pub mod hashmap;
146+
pub mod cell;
145147

146148

147149
/* Tasks and communication */

branches/auto/src/libcore/num/int-template.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ pub pure fn to_str_radix(num: T, radix: uint) -> ~str {
265265
buf
266266
}
267267
268+
/// Convert to a string.
269+
/// *Deprecated*, use to_str() instead.
270+
#[inline(always)]
271+
pub pure fn str(i: T) -> ~str { to_str(i) }
272+
268273
impl ToStr for T {
269274
#[inline(always)]
270275
pure fn to_str(&self) -> ~str {

branches/auto/src/libcore/num/uint-template.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ pub pure fn to_str_radix(num: T, radix: uint) -> ~str {
229229
buf
230230
}
231231
232+
/// Convert to a string.
233+
/// *Deprecated*, use to_str() instead.
234+
#[inline(always)]
235+
pub pure fn str(i: T) -> ~str { to_str(i) }
236+
232237
impl ToStr for T {
233238
#[inline(always)]
234239
pure fn to_str(&self) -> ~str {

branches/auto/src/libcore/pipes.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ bounded and unbounded protocols allows for less code duplication.
8686

8787
use cmp::Eq;
8888
use cast::{forget, reinterpret_cast, transmute};
89+
use cell::Cell;
8990
use either::{Either, Left, Right};
9091
use kinds::Owned;
9192
use libc;
@@ -917,11 +918,9 @@ pub fn spawn_service<T:Owned,Tb:Owned>(
917918
918919
// This is some nasty gymnastics required to safely move the pipe
919920
// into a new task.
920-
let server = ~mut Some(server);
921-
do task::spawn || {
922-
let mut server_ = None;
923-
server_ <-> *server;
924-
service(option::unwrap(server_))
921+
let server = Cell(server);
922+
do task::spawn {
923+
service(server.take());
925924
}
926925
927926
client
@@ -941,11 +940,9 @@ pub fn spawn_service_recv<T:Owned,Tb:Owned>(
941940
942941
// This is some nasty gymnastics required to safely move the pipe
943942
// into a new task.
944-
let server = ~mut Some(server);
945-
do task::spawn || {
946-
let mut server_ = None;
947-
server_ <-> *server;
948-
service(option::unwrap(server_))
943+
let server = Cell(server);
944+
do task::spawn {
945+
service(server.take())
949946
}
950947
951948
client

branches/auto/src/libcore/private.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool {
107107
* Shared state & exclusive ARC
108108
****************************************************************************/
109109

110+
struct UnwrapProtoInner {
111+
contents: Option<(comm::ChanOne<()>, comm::PortOne<bool>)>,
112+
}
113+
110114
// An unwrapper uses this protocol to communicate with the "other" task that
111115
// drops the last refcount on an arc. Unfortunately this can't be a proper
112116
// pipe protocol because the unwrapper has to access both stages at once.
113-
type UnwrapProto = ~mut Option<(comm::ChanOne<()>, comm::PortOne<bool>)>;
117+
type UnwrapProto = ~UnwrapProtoInner;
114118

115119
struct ArcData<T> {
116120
mut count: libc::intptr_t,
@@ -139,9 +143,10 @@ struct ArcDestruct<T> {
139143
// reference. In effect, being here means we're the only
140144
// *awake* task with the data.
141145
if data.unwrapper != 0 {
142-
let p: UnwrapProto =
146+
let mut p: UnwrapProto =
143147
cast::reinterpret_cast(&data.unwrapper);
144-
let (message, response) = option::swap_unwrap(p);
148+
let (message, response) =
149+
option::swap_unwrap(&mut p.contents);
145150
// Send 'ready' and wait for a response.
146151
comm::send_one(message, ());
147152
// Unkillable wait. Message guaranteed to come.
@@ -196,7 +201,9 @@ pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>)
196201
let ptr: ~ArcData<T> = cast::reinterpret_cast(&rc.data);
197202
let (p1,c1) = comm::oneshot(); // ()
198203
let (p2,c2) = comm::oneshot(); // bool
199-
let server: UnwrapProto = ~mut Some((c1,p2));
204+
let mut server: UnwrapProto = ~UnwrapProtoInner {
205+
contents: Some((c1,p2))
206+
};
200207
let serverp: int = cast::transmute(server);
201208
// Try to put our server end in the unwrapper slot.
202209
if compare_and_swap(&mut ptr.unwrapper, 0, serverp) {
@@ -409,8 +416,9 @@ pub fn unwrap_exclusive<T:Owned>(arc: Exclusive<T>) -> T {
409416
pub mod tests {
410417
use core::option::{None, Some};
411418
412-
use option;
419+
use cell::Cell;
413420
use comm;
421+
use option;
414422
use private::{exclusive, unwrap_exclusive};
415423
use result;
416424
use task;
@@ -423,7 +431,7 @@ pub mod tests {
423431
let num_tasks = 10;
424432
let count = 10;
425433
426-
let total = exclusive(~mut 0);
434+
let total = exclusive(~0);
427435
428436
for uint::range(0, num_tasks) |_i| {
429437
let total = total.clone();
@@ -472,21 +480,20 @@ pub mod tests {
472480
#[test]
473481
pub fn exclusive_unwrap_contended() {
474482
let x = exclusive(~~"hello");
475-
let x2 = ~mut Some(x.clone());
476-
do task::spawn || {
477-
let x2 = option::swap_unwrap(x2);
483+
let x2 = Cell(x.clone());
484+
do task::spawn {
485+
let x2 = x2.take();
478486
do x2.with |_hello| { }
479487
task::yield();
480488
}
481489
assert unwrap_exclusive(x) == ~~"hello";
482490
483491
// Now try the same thing, but with the child task blocking.
484492
let x = exclusive(~~"hello");
485-
let x2 = ~mut Some(x.clone());
493+
let x2 = Cell(x.clone());
486494
let mut res = None;
487-
do task::task().future_result(|+r| res = Some(r)).spawn
488-
|| {
489-
let x2 = option::swap_unwrap(x2);
495+
do task::task().future_result(|+r| res = Some(r)).spawn {
496+
let x2 = x2.take();
490497
assert unwrap_exclusive(x2) == ~~"hello";
491498
}
492499
// Have to get rid of our reference before blocking.
@@ -498,11 +505,10 @@ pub mod tests {
498505
#[test] #[should_fail] #[ignore(cfg(windows))]
499506
pub fn exclusive_unwrap_conflict() {
500507
let x = exclusive(~~"hello");
501-
let x2 = ~mut Some(x.clone());
508+
let x2 = Cell(x.clone());
502509
let mut res = None;
503-
do task::task().future_result(|+r| res = Some(r)).spawn
504-
|| {
505-
let x2 = option::swap_unwrap(x2);
510+
do task::task().future_result(|+r| res = Some(r)).spawn {
511+
let x2 = x2.take();
506512
assert unwrap_exclusive(x2) == ~~"hello";
507513
}
508514
assert unwrap_exclusive(x) == ~~"hello";

branches/auto/src/libcore/private/weak_task.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ it is running, sending a notification to the task that the runtime
1818
is trying to shut down.
1919
*/
2020

21+
use cell::Cell;
22+
use comm::{GenericSmartChan, stream};
23+
use comm::{Port, Chan, SharedChan, GenericChan, GenericPort};
24+
use hashmap::linear::LinearMap;
25+
use ops::Drop;
2126
use option::{Some, None, swap_unwrap};
2227
use private::at_exit::at_exit;
23-
use private::global::global_data_clone_create;
2428
use private::finally::Finally;
25-
use comm::{Port, Chan, SharedChan, GenericChan,
26-
GenericPort, GenericSmartChan, stream};
27-
use task::{Task, task, spawn};
29+
use private::global::global_data_clone_create;
2830
use task::rt::{task_id, get_task_id};
29-
use hashmap::linear::LinearMap;
30-
use ops::Drop;
31+
use task::{Task, task, spawn};
3132

3233
type ShutdownMsg = ();
3334

@@ -37,14 +38,13 @@ pub unsafe fn weaken_task(f: &fn(Port<ShutdownMsg>)) {
3738
let service = global_data_clone_create(global_data_key,
3839
create_global_service);
3940
let (shutdown_port, shutdown_chan) = stream::<ShutdownMsg>();
40-
let shutdown_port = ~mut Some(shutdown_port);
41+
let shutdown_port = Cell(shutdown_port);
4142
let task = get_task_id();
4243
// Expect the weak task service to be alive
4344
assert service.try_send(RegisterWeakTask(task, shutdown_chan));
4445
unsafe { rust_dec_kernel_live_count(); }
4546
do fn&() {
46-
let shutdown_port = swap_unwrap(&mut *shutdown_port);
47-
f(shutdown_port)
47+
f(shutdown_port.take())
4848
}.finally || {
4949
unsafe { rust_inc_kernel_live_count(); }
5050
// Service my have already exited
@@ -67,16 +67,15 @@ fn create_global_service() -> ~WeakTaskService {
6767

6868
debug!("creating global weak task service");
6969
let (port, chan) = stream::<ServiceMsg>();
70-
let port = ~mut Some(port);
70+
let port = Cell(port);
7171
let chan = SharedChan(chan);
7272
let chan_clone = chan.clone();
7373

7474
do task().unlinked().spawn {
7575
debug!("running global weak task service");
76-
let port = swap_unwrap(&mut *port);
77-
let port = ~mut Some(port);
76+
let port = Cell(port.take());
7877
do fn&() {
79-
let port = swap_unwrap(&mut *port);
78+
let port = port.take();
8079
// The weak task service is itself a weak task
8180
debug!("weakening the weak service task");
8281
unsafe { rust_dec_kernel_live_count(); }

branches/auto/src/libcore/repr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ fn test_repr() {
602602
exact_test(&(@10), "@10");
603603
exact_test(&(@mut 10), "@10");
604604
exact_test(&(~10), "~10");
605-
exact_test(&(~mut 10), "~mut 10");
606605
exact_test(&(&10), "&10");
607606
let mut x = 10;
608607
exact_test(&(&mut x), "&mut 10");

branches/auto/src/libcore/task/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
*/
3535

3636
use cast;
37+
use cell::Cell;
3738
use cmp;
3839
use cmp::Eq;
3940
use iter;
@@ -397,9 +398,9 @@ impl TaskBuilder {
397398
}
398399
/// Runs a task, while transfering ownership of one argument to the child.
399400
fn spawn_with<A:Owned>(arg: A, f: fn~(v: A)) {
400-
let arg = ~mut Some(arg);
401-
do self.spawn || {
402-
f(option::swap_unwrap(arg))
401+
let arg = Cell(arg);
402+
do self.spawn {
403+
f(arg.take());
403404
}
404405
}
405406

branches/auto/src/libcore/task/spawn.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#[doc(hidden)]; // FIXME #3538
7474

7575
use cast;
76+
use cell::Cell;
7677
use container::Map;
7778
use option;
7879
use comm::{Chan, GenericChan, GenericPort, Port, stream};
@@ -530,11 +531,11 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
530531
gen_child_taskgroup(opts.linked, opts.supervised);
531532

532533
unsafe {
533-
let child_data = ~mut Some((child_tg, ancestors, f));
534+
let child_data = Cell((child_tg, ancestors, f));
534535
// Being killed with the unsafe task/closure pointers would leak them.
535536
do unkillable {
536537
// Agh. Get move-mode items into the closure. FIXME (#2829)
537-
let (child_tg, ancestors, f) = option::swap_unwrap(child_data);
538+
let (child_tg, ancestors, f) = child_data.take();
538539
// Create child task.
539540
let new_task = match opts.sched.mode {
540541
DefaultScheduler => rt::new_task(),
@@ -571,10 +572,10 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
571572
ancestors: AncestorList, is_main: bool,
572573
notify_chan: Option<Chan<TaskResult>>,
573574
f: fn~()) -> fn~() {
574-
let child_data = ~mut Some((child_arc, ancestors));
575+
let child_data = Cell((child_arc, ancestors));
575576
return fn~() {
576577
// Agh. Get move-mode items into the closure. FIXME (#2829)
577-
let mut (child_arc, ancestors) = option::swap_unwrap(child_data);
578+
let mut (child_arc, ancestors) = child_data.take();
578579
// Child task runs this code.
579580

580581
// Even if the below code fails to kick the child off, we must

branches/auto/src/libfuzzer/fuzzer.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub fn check_variants_T<T: Copy>(
290290

291291
if L < 100 {
292292
do under(uint::min(L, 20)) |i| {
293-
log(error, ~"Replacing... #" + uint::to_str(i));
293+
log(error, ~"Replacing... #" + uint::str(i));
294294
let fname = str::from_slice(filename.to_str());
295295
do under(uint::min(L, 30)) |j| {
296296
log(error, ~"With... " + stringifier(@things[j], intr));
@@ -415,7 +415,7 @@ pub fn check_running(exe_filename: &Path) -> happiness {
415415
}
416416
rc => {
417417
failed(~"Rust program ran but exited with status " +
418-
int::to_str(rc))
418+
int::str(rc))
419419
}
420420
}
421421
}

branches/auto/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) {
307307
w.write_char('p');
308308
w.write_str((cx.ds)(did));
309309
w.write_char('|');
310-
w.write_str(uint::to_str(id));
310+
w.write_str(uint::str(id));
311311
}
312312
ty::ty_self => {
313313
w.write_char('s');

branches/auto/src/librustc/middle/freevars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) ->
117117
118118
pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
119119
match tcx.freevars.find(&fid) {
120-
None => fail!(~"get_freevars: "+int::to_str(fid)+~" has no freevars"),
120+
None => fail!(~"get_freevars: " + int::str(fid) + ~" has no freevars"),
121121
Some(d) => return d
122122
}
123123
}

0 commit comments

Comments
 (0)