Skip to content

Commit 6ca6a3b

Browse files
committed
rewrite arc to use region & expressions (also making it pass borrowck)
1 parent 4fec4cd commit 6ca6a3b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/libstd/arc.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export arc, get, clone;
66
#[abi = "cdecl"]
77
native mod rustrt {
88
#[rust_stack]
9-
fn rust_atomic_increment(p: *mut libc::intptr_t)
9+
fn rust_atomic_increment(p: &mut libc::intptr_t)
1010
-> libc::intptr_t;
1111

1212
#[rust_stack]
13-
fn rust_atomic_decrement(p: *mut libc::intptr_t)
13+
fn rust_atomic_decrement(p: &mut libc::intptr_t)
1414
-> libc::intptr_t;
1515
}
1616

@@ -21,7 +21,7 @@ type arc_data<T> = {
2121

2222
resource arc_destruct<T>(data: *arc_data<T>) {
2323
unsafe {
24-
let ptr = ptr::mut_addr_of((*data).count);
24+
let ptr = &mut (*data).count;
2525

2626
let new_count = rustrt::rust_atomic_decrement(ptr);
2727
assert new_count >= 0;
@@ -52,8 +52,7 @@ fn get<T>(rc: &a.arc<T>) -> &a.T {
5252
fn clone<T>(rc: &arc<T>) -> arc<T> {
5353
let data = **rc;
5454
unsafe {
55-
rustrt::rust_atomic_increment(
56-
ptr::mut_addr_of((*data).count));
55+
rustrt::rust_atomic_increment(&mut (*data).count);
5756
}
5857
arc_destruct(**rc)
5958
}

0 commit comments

Comments
 (0)