Skip to content

Commit 6b75e92

Browse files
committed
UnsafeArc methods return unsafe pointers, so are not themselves unsafe.
1 parent fa8102a commit 6b75e92

File tree

3 files changed

+127
-128
lines changed

3 files changed

+127
-128
lines changed

src/libextra/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<T:Freeze+Send> Arc<T> {
136136
*/
137137
pub fn unwrap(self) -> T {
138138
let Arc { x: x } = self;
139-
unsafe { x.unwrap() }
139+
x.unwrap()
140140
}
141141
}
142142

@@ -250,7 +250,7 @@ impl<T:Send> MutexArc<T> {
250250
*/
251251
pub fn unwrap(self) -> T {
252252
let MutexArc { x: x } = self;
253-
let inner = unsafe { x.unwrap() };
253+
let inner = x.unwrap();
254254
let MutexArcInner { failed: failed, data: data, _ } = inner;
255255
if failed {
256256
fail!(~"Can't unwrap poisoned MutexArc - another task failed inside!");
@@ -469,7 +469,7 @@ impl<T:Freeze + Send> RWArc<T> {
469469
*/
470470
pub fn unwrap(self) -> T {
471471
let RWArc { x: x, _ } = self;
472-
let inner = unsafe { x.unwrap() };
472+
let inner = x.unwrap();
473473
let RWArcInner { failed: failed, data: data, _ } = inner;
474474
if failed {
475475
fail!(~"Can't unwrap poisoned RWArc - another task failed inside!")

src/libstd/rt/kill.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl KillHandle {
328328
}
329329

330330
// Try to see if all our children are gone already.
331-
match unsafe { self.try_unwrap() } {
331+
match self.try_unwrap() {
332332
// Couldn't unwrap; children still alive. Reparent entire handle as
333333
// our own tombstone, to be unwrapped later.
334334
Left(this) => {
@@ -340,7 +340,7 @@ impl KillHandle {
340340
// Prefer to check tombstones that were there first,
341341
// being "more fair" at the expense of tail-recursion.
342342
others.take().map_consume_default(true, |f| f()) && {
343-
let mut inner = unsafe { this.take().unwrap() };
343+
let mut inner = this.take().unwrap();
344344
(!inner.any_child_failed) &&
345345
inner.child_tombstones.take_map_default(true, |f| f())
346346
}
@@ -429,7 +429,7 @@ impl Death {
429429
do self.on_exit.take_map |on_exit| {
430430
if success {
431431
// We succeeded, but our children might not. Need to wait for them.
432-
let mut inner = unsafe { self.kill_handle.take_unwrap().unwrap() };
432+
let mut inner = self.kill_handle.take_unwrap().unwrap();
433433
if inner.any_child_failed {
434434
success = false;
435435
} else {
@@ -555,7 +555,7 @@ mod test {
555555

556556
// Without another handle to child, the try unwrap should succeed.
557557
child.reparent_children_to(&mut parent);
558-
let mut parent_inner = unsafe { parent.unwrap() };
558+
let mut parent_inner = parent.unwrap();
559559
assert!(parent_inner.child_tombstones.is_none());
560560
assert!(parent_inner.any_child_failed == false);
561561
}
@@ -570,7 +570,7 @@ mod test {
570570
child.notify_immediate_failure();
571571
// Without another handle to child, the try unwrap should succeed.
572572
child.reparent_children_to(&mut parent);
573-
let mut parent_inner = unsafe { parent.unwrap() };
573+
let mut parent_inner = parent.unwrap();
574574
assert!(parent_inner.child_tombstones.is_none());
575575
// Immediate failure should have been propagated.
576576
assert!(parent_inner.any_child_failed);
@@ -592,7 +592,7 @@ mod test {
592592
// Otherwise, due to 'link', it would try to tombstone.
593593
child2.reparent_children_to(&mut parent);
594594
// Should successfully unwrap even though 'link' is still alive.
595-
let mut parent_inner = unsafe { parent.unwrap() };
595+
let mut parent_inner = parent.unwrap();
596596
assert!(parent_inner.child_tombstones.is_none());
597597
// Immediate failure should have been propagated by first child.
598598
assert!(parent_inner.any_child_failed);
@@ -611,7 +611,7 @@ mod test {
611611
// Let parent collect tombstones.
612612
util::ignore(link);
613613
// Must have created a tombstone
614-
let mut parent_inner = unsafe { parent.unwrap() };
614+
let mut parent_inner = parent.unwrap();
615615
assert!(parent_inner.child_tombstones.take_unwrap()());
616616
assert!(parent_inner.any_child_failed == false);
617617
}
@@ -630,7 +630,7 @@ mod test {
630630
// Let parent collect tombstones.
631631
util::ignore(link);
632632
// Must have created a tombstone
633-
let mut parent_inner = unsafe { parent.unwrap() };
633+
let mut parent_inner = parent.unwrap();
634634
// Failure must be seen in the tombstone.
635635
assert!(parent_inner.child_tombstones.take_unwrap()() == false);
636636
assert!(parent_inner.any_child_failed == false);
@@ -650,7 +650,7 @@ mod test {
650650
// Let parent collect tombstones.
651651
util::ignore(link);
652652
// Must have created a tombstone
653-
let mut parent_inner = unsafe { parent.unwrap() };
653+
let mut parent_inner = parent.unwrap();
654654
assert!(parent_inner.child_tombstones.take_unwrap()());
655655
assert!(parent_inner.any_child_failed == false);
656656
}
@@ -671,7 +671,7 @@ mod test {
671671
// Let parent collect tombstones.
672672
util::ignore(link);
673673
// Must have created a tombstone
674-
let mut parent_inner = unsafe { parent.unwrap() };
674+
let mut parent_inner = parent.unwrap();
675675
// Failure must be seen in the tombstone.
676676
assert!(parent_inner.child_tombstones.take_unwrap()() == false);
677677
assert!(parent_inner.any_child_failed == false);

0 commit comments

Comments
 (0)