Skip to content

Commit

Permalink
Remove as _ casts
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Apr 11, 2024
1 parent dee1f89 commit 3c86e9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion portable-atomic-util/src/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ impl<T> Arc<[mem::MaybeUninit<T>]> {
let md_self = mem::ManuallyDrop::new(self);
// SAFETY: [MaybeUninit<T>] has the same layout as [T], and
// the caller must ensure data is initialized.
unsafe { Arc::from_ptr(md_self.ptr.as_ptr() as _) }
unsafe { Arc::from_ptr(md_self.ptr.as_ptr() as *mut ArcInner<[T]>) }
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/tests/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ macro_rules! __test_atomic_ptr {
let x = &mut 1;
for &order in &test_helper::SWAP_ORDERINGS {
assert_eq!(a.swap(x, order), ptr::null_mut());
assert_eq!(a.swap(ptr::null_mut(), order), x as _);
assert_eq!(a.swap(ptr::null_mut(), order), x as *mut _);
}
}
#[test]
Expand All @@ -1357,12 +1357,12 @@ macro_rules! __test_atomic_ptr {
a.compare_exchange(ptr::null_mut(), x, success, failure),
Ok(ptr::null_mut()),
);
assert_eq!(a.load(Ordering::Relaxed), x as _);
assert_eq!(a.load(Ordering::Relaxed), x as *mut _);
assert_eq!(
a.compare_exchange(ptr::null_mut(), ptr::null_mut(), success, failure),
Err(x as _),
Err(x as *mut _),
);
assert_eq!(a.load(Ordering::Relaxed), x as _);
assert_eq!(a.load(Ordering::Relaxed), x as *mut _);
}
}
#[test]
Expand All @@ -1382,7 +1382,7 @@ macro_rules! __test_atomic_ptr {
Err(x) => old = x,
}
}
assert_eq!(a.load(Ordering::Relaxed), x as _);
assert_eq!(a.load(Ordering::Relaxed), x as *mut _);
}
}
};
Expand Down Expand Up @@ -2193,7 +2193,7 @@ macro_rules! __stress_test_acquire_release {
s.spawn(|_| {
for i in 0..n {
b.store(i, Ordering::Relaxed);
a.$write(i as _, Ordering::$store_order);
a.$write(i as $int_type, Ordering::$store_order);
}
});
loop {
Expand Down
10 changes: 5 additions & 5 deletions tests/api-test/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ macro_rules! __test_atomic_ptr {
let x = &mut 1;
for &order in &test_helper::SWAP_ORDERINGS {
assert_eq!(a.swap(x, order), core::ptr::null_mut());
assert_eq!(a.swap(core::ptr::null_mut(), order), x as _);
assert_eq!(a.swap(core::ptr::null_mut(), order), x as *mut _);
}
}
__run_test!(compare_exchange);
Expand All @@ -752,17 +752,17 @@ macro_rules! __test_atomic_ptr {
a.compare_exchange(core::ptr::null_mut(), x, success, failure),
Ok(core::ptr::null_mut()),
);
assert_eq!(a.load(Ordering::Relaxed), x as _);
assert_eq!(a.load(Ordering::Relaxed), x as *mut _);
assert_eq!(
a.compare_exchange(
core::ptr::null_mut(),
core::ptr::null_mut(),
success,
failure
),
Err(x as _),
Err(x as *mut _),
);
assert_eq!(a.load(Ordering::Relaxed), x as _);
assert_eq!(a.load(Ordering::Relaxed), x as *mut _);
}
}
__run_test!(compare_exchange_weak);
Expand All @@ -781,7 +781,7 @@ macro_rules! __test_atomic_ptr {
Err(x) => old = x,
}
}
assert_eq!(a.load(Ordering::Relaxed), x as _);
assert_eq!(a.load(Ordering::Relaxed), x as *mut _);
}
}
__run_test!(fetch_update);
Expand Down

0 comments on commit 3c86e9c

Please sign in to comment.