diff options
| author | bors <bors@rust-lang.org> | 2013-04-23 18:27:48 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-04-23 18:27:48 -0700 |
| commit | 706096b31960143fb1eb957a882f170ae4a8b4e9 (patch) | |
| tree | b4e4afd8a3c0c6efa7965cb5dd6d0b8342c16d87 /src/libstd | |
| parent | 8708e0c099400f363a5b95806847bd12d780000a (diff) | |
| parent | 0c2ab662b71377efd2da7dced4f56e75cb68f540 (diff) | |
| download | rust-706096b31960143fb1eb957a882f170ae4a8b4e9.tar.gz rust-706096b31960143fb1eb957a882f170ae4a8b4e9.zip | |
auto merge of #6038 : alexcrichton/rust/more-unsafe, r=pcwalton
Because unsafe functions are never warned about, then all `unsafe` blocks in unsafe functions should definitely be warned about (no need to be redundant). This fixes this case, adds tests, cleans up remaining cases, and then fixes a few other import warnings being spit out.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arc.rs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 8abe0262314..33aa6171de4 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -177,15 +177,13 @@ pub impl<T:Owned> MutexARC<T> { */ #[inline(always)] unsafe fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U { - unsafe { - let state = get_shared_mutable_state(&self.x); - // Borrowck would complain about this if the function were - // not already unsafe. See borrow_rwlock, far below. - do (&(*state).lock).lock { - check_poison(true, (*state).failed); - let _z = PoisonOnFail(&mut (*state).failed); - blk(&mut (*state).data) - } + let state = get_shared_mutable_state(&self.x); + // Borrowck would complain about this if the function were + // not already unsafe. See borrow_rwlock, far below. + do (&(*state).lock).lock { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data) } } @@ -195,16 +193,14 @@ pub impl<T:Owned> MutexARC<T> { &self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { - unsafe { - let state = get_shared_mutable_state(&self.x); - do (&(*state).lock).lock_cond |cond| { - check_poison(true, (*state).failed); - let _z = PoisonOnFail(&mut (*state).failed); - blk(&mut (*state).data, - &Condvar {is_mutex: true, - failed: &mut (*state).failed, - cond: cond }) - } + let state = get_shared_mutable_state(&self.x); + do (&(*state).lock).lock_cond |cond| { + check_poison(true, (*state).failed); + let _z = PoisonOnFail(&mut (*state).failed); + blk(&mut (*state).data, + &Condvar {is_mutex: true, + failed: &mut (*state).failed, + cond: cond }) } } } |
