Skip to content

Commit c78d51b

Browse files
committed
---
yaml --- r: 44758 b: refs/heads/master c: b79c4dc h: refs/heads/master v: v3
1 parent 30f2d58 commit c78d51b

Some content is hidden

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

69 files changed

+520
-258
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9b08cd4903f7b3b5bb193dec85b055f24ff09cb7
2+
refs/heads/master: b79c4dc262227f0d09706a13f76fdb347ca6d70d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/src/libcore/core.rc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ 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)];
5554

5655
/* The Prelude. */
5756

@@ -143,7 +142,6 @@ pub mod dlist;
143142
#[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"]
144143
pub mod dlist_iter;
145144
pub mod hashmap;
146-
pub mod cell;
147145

148146

149147
/* Tasks and communication */

trunk/src/libcore/pipes.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ 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;
9089
use either::{Either, Left, Right};
9190
use kinds::Owned;
9291
use libc;
@@ -918,9 +917,11 @@ pub fn spawn_service<T:Owned,Tb:Owned>(
918917
919918
// This is some nasty gymnastics required to safely move the pipe
920919
// into a new task.
921-
let server = Cell(server);
922-
do task::spawn {
923-
service(server.take());
920+
let server = ~mut Some(server);
921+
do task::spawn || {
922+
let mut server_ = None;
923+
server_ <-> *server;
924+
service(option::unwrap(server_))
924925
}
925926
926927
client
@@ -940,9 +941,11 @@ pub fn spawn_service_recv<T:Owned,Tb:Owned>(
940941
941942
// This is some nasty gymnastics required to safely move the pipe
942943
// into a new task.
943-
let server = Cell(server);
944-
do task::spawn {
945-
service(server.take())
944+
let server = ~mut Some(server);
945+
do task::spawn || {
946+
let mut server_ = None;
947+
server_ <-> *server;
948+
service(option::unwrap(server_))
946949
}
947950
948951
client

trunk/src/libcore/private.rs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,10 @@ 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-
114110
// An unwrapper uses this protocol to communicate with the "other" task that
115111
// drops the last refcount on an arc. Unfortunately this can't be a proper
116112
// pipe protocol because the unwrapper has to access both stages at once.
117-
type UnwrapProto = ~UnwrapProtoInner;
113+
type UnwrapProto = ~mut Option<(comm::ChanOne<()>, comm::PortOne<bool>)>;
118114

119115
struct ArcData<T> {
120116
mut count: libc::intptr_t,
@@ -143,10 +139,9 @@ struct ArcDestruct<T> {
143139
// reference. In effect, being here means we're the only
144140
// *awake* task with the data.
145141
if data.unwrapper != 0 {
146-
let mut p: UnwrapProto =
142+
let p: UnwrapProto =
147143
cast::reinterpret_cast(&data.unwrapper);
148-
let (message, response) =
149-
option::swap_unwrap(&mut p.contents);
144+
let (message, response) = option::swap_unwrap(p);
150145
// Send 'ready' and wait for a response.
151146
comm::send_one(message, ());
152147
// Unkillable wait. Message guaranteed to come.
@@ -201,9 +196,7 @@ pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>)
201196
let ptr: ~ArcData<T> = cast::reinterpret_cast(&rc.data);
202197
let (p1,c1) = comm::oneshot(); // ()
203198
let (p2,c2) = comm::oneshot(); // bool
204-
let mut server: UnwrapProto = ~UnwrapProtoInner {
205-
contents: Some((c1,p2))
206-
};
199+
let server: UnwrapProto = ~mut Some((c1,p2));
207200
let serverp: int = cast::transmute(server);
208201
// Try to put our server end in the unwrapper slot.
209202
if compare_and_swap(&mut ptr.unwrapper, 0, serverp) {
@@ -416,9 +409,8 @@ pub fn unwrap_exclusive<T:Owned>(arc: Exclusive<T>) -> T {
416409
pub mod tests {
417410
use core::option::{None, Some};
418411
419-
use cell::Cell;
420-
use comm;
421412
use option;
413+
use comm;
422414
use private::{exclusive, unwrap_exclusive};
423415
use result;
424416
use task;
@@ -431,7 +423,7 @@ pub mod tests {
431423
let num_tasks = 10;
432424
let count = 10;
433425
434-
let total = exclusive(~0);
426+
let total = exclusive(~mut 0);
435427
436428
for uint::range(0, num_tasks) |_i| {
437429
let total = total.clone();
@@ -480,20 +472,21 @@ pub mod tests {
480472
#[test]
481473
pub fn exclusive_unwrap_contended() {
482474
let x = exclusive(~~"hello");
483-
let x2 = Cell(x.clone());
484-
do task::spawn {
485-
let x2 = x2.take();
475+
let x2 = ~mut Some(x.clone());
476+
do task::spawn || {
477+
let x2 = option::swap_unwrap(x2);
486478
do x2.with |_hello| { }
487479
task::yield();
488480
}
489481
assert unwrap_exclusive(x) == ~~"hello";
490482
491483
// Now try the same thing, but with the child task blocking.
492484
let x = exclusive(~~"hello");
493-
let x2 = Cell(x.clone());
485+
let x2 = ~mut Some(x.clone());
494486
let mut res = None;
495-
do task::task().future_result(|+r| res = Some(r)).spawn {
496-
let x2 = x2.take();
487+
do task::task().future_result(|+r| res = Some(r)).spawn
488+
|| {
489+
let x2 = option::swap_unwrap(x2);
497490
assert unwrap_exclusive(x2) == ~~"hello";
498491
}
499492
// Have to get rid of our reference before blocking.
@@ -505,10 +498,11 @@ pub mod tests {
505498
#[test] #[should_fail] #[ignore(cfg(windows))]
506499
pub fn exclusive_unwrap_conflict() {
507500
let x = exclusive(~~"hello");
508-
let x2 = Cell(x.clone());
501+
let x2 = ~mut Some(x.clone());
509502
let mut res = None;
510-
do task::task().future_result(|+r| res = Some(r)).spawn {
511-
let x2 = x2.take();
503+
do task::task().future_result(|+r| res = Some(r)).spawn
504+
|| {
505+
let x2 = option::swap_unwrap(x2);
512506
assert unwrap_exclusive(x2) == ~~"hello";
513507
}
514508
assert unwrap_exclusive(x) == ~~"hello";

trunk/src/libcore/private/weak_task.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ 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;
2621
use option::{Some, None, swap_unwrap};
2722
use private::at_exit::at_exit;
28-
use private::finally::Finally;
2923
use private::global::global_data_clone_create;
30-
use task::rt::{task_id, get_task_id};
24+
use private::finally::Finally;
25+
use comm::{Port, Chan, SharedChan, GenericChan,
26+
GenericPort, GenericSmartChan, stream};
3127
use task::{Task, task, spawn};
28+
use task::rt::{task_id, get_task_id};
29+
use hashmap::linear::LinearMap;
30+
use ops::Drop;
3231

3332
type ShutdownMsg = ();
3433

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

6868
debug!("creating global weak task service");
6969
let (port, chan) = stream::<ServiceMsg>();
70-
let port = Cell(port);
70+
let port = ~mut Some(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 = Cell(port.take());
76+
let port = swap_unwrap(&mut *port);
77+
let port = ~mut Some(port);
7778
do fn&() {
78-
let port = port.take();
79+
let port = swap_unwrap(&mut *port);
7980
// The weak task service is itself a weak task
8081
debug!("weakening the weak service task");
8182
unsafe { rust_dec_kernel_live_count(); }

trunk/src/libcore/repr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ 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");
605606
exact_test(&(&10), "&10");
606607
let mut x = 10;
607608
exact_test(&(&mut x), "&mut 10");

trunk/src/libcore/task/mod.rs

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

3636
use cast;
37-
use cell::Cell;
3837
use cmp;
3938
use cmp::Eq;
4039
use iter;
@@ -398,9 +397,9 @@ impl TaskBuilder {
398397
}
399398
/// Runs a task, while transfering ownership of one argument to the child.
400399
fn spawn_with<A:Owned>(arg: A, f: fn~(v: A)) {
401-
let arg = Cell(arg);
402-
do self.spawn {
403-
f(arg.take());
400+
let arg = ~mut Some(arg);
401+
do self.spawn || {
402+
f(option::swap_unwrap(arg))
404403
}
405404
}
406405

trunk/src/libcore/task/spawn.rs

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

7575
use cast;
76-
use cell::Cell;
7776
use container::Map;
7877
use option;
7978
use comm::{Chan, GenericChan, GenericPort, Port, stream};
@@ -531,11 +530,11 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
531530
gen_child_taskgroup(opts.linked, opts.supervised);
532531

533532
unsafe {
534-
let child_data = Cell((child_tg, ancestors, f));
533+
let child_data = ~mut Some((child_tg, ancestors, f));
535534
// Being killed with the unsafe task/closure pointers would leak them.
536535
do unkillable {
537536
// Agh. Get move-mode items into the closure. FIXME (#2829)
538-
let (child_tg, ancestors, f) = child_data.take();
537+
let (child_tg, ancestors, f) = option::swap_unwrap(child_data);
539538
// Create child task.
540539
let new_task = match opts.sched.mode {
541540
DefaultScheduler => rt::new_task(),
@@ -572,10 +571,10 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
572571
ancestors: AncestorList, is_main: bool,
573572
notify_chan: Option<Chan<TaskResult>>,
574573
f: fn~()) -> fn~() {
575-
let child_data = Cell((child_arc, ancestors));
574+
let child_data = ~mut Some((child_arc, ancestors));
576575
return fn~() {
577576
// Agh. Get move-mode items into the closure. FIXME (#2829)
578-
let mut (child_arc, ancestors) = child_data.take();
577+
let mut (child_arc, ancestors) = option::swap_unwrap(child_data);
579578
// Child task runs this code.
580579

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

trunk/src/librustc/middle/check_match.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) {
101101
_ => { /* We assume only enum types can be uninhabited */ }
102102
}
103103
let arms = vec::concat(arms.filter_mapped(unguarded_pat));
104-
check_exhaustive(cx, ex.span, arms);
104+
if arms.is_empty() {
105+
cx.tcx.sess.span_err(ex.span, ~"non-exhaustive patterns");
106+
} else {
107+
check_exhaustive(cx, ex.span, arms);
108+
}
105109
}
106110
_ => ()
107111
}

trunk/src/librustc/middle/lint.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ pub enum lint {
8080
type_limits,
8181
default_methods,
8282
deprecated_self,
83-
deprecated_mutable_fields,
8483

8584
managed_heap_memory,
8685
owned_heap_memory,
@@ -255,13 +254,6 @@ pub fn get_lint_dict() -> LintDict {
255254
default: warn
256255
}),
257256

258-
(@~"deprecated_mutable_fields",
259-
@LintSpec {
260-
lint: deprecated_mutable_fields,
261-
desc: "deprecated mutable fields in structures",
262-
default: deny
263-
}),
264-
265257
/* FIXME(#3266)--make liveness warnings lintable
266258
(@~"unused_variable",
267259
@LintSpec {
@@ -494,7 +486,6 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
494486
check_item_type_limits(cx, i);
495487
check_item_default_methods(cx, i);
496488
check_item_deprecated_self(cx, i);
497-
check_item_deprecated_mutable_fields(cx, i);
498489
}
499490

500491
// Take a visitor, and modify it so that it will not proceed past subitems.
@@ -712,26 +703,6 @@ fn check_item_deprecated_self(cx: ty::ctxt, item: @ast::item) {
712703
}
713704
}
714705
715-
fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) {
716-
match item.node {
717-
ast::item_struct(struct_def, _) => {
718-
for struct_def.fields.each |field| {
719-
match field.node.kind {
720-
ast::named_field(_, ast::struct_mutable, _) => {
721-
cx.sess.span_lint(deprecated_mutable_fields,
722-
item.id,
723-
item.id,
724-
field.span,
725-
~"mutable fields are deprecated");
726-
}
727-
ast::named_field(*) | ast::unnamed_field => {}
728-
}
729-
}
730-
}
731-
_ => {}
732-
}
733-
}
734-
735706
fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
736707
let visit = item_stopping_visitor(
737708
visit::mk_simple_visitor(@visit::SimpleVisitor {

0 commit comments

Comments
 (0)