Skip to content

Commit 493b5fd

Browse files
committed
Make some auto-refs in std explicit
1 parent 561dfaf commit 493b5fd

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

library/alloc/src/collections/btree/node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ unsafe fn slice_insert<T>(slice: &mut [MaybeUninit<T>], idx: usize, val: T) {
16991699
if len > idx + 1 {
17001700
ptr::copy(slice_ptr.add(idx), slice_ptr.add(idx + 1), len - idx - 1);
17011701
}
1702-
(*slice_ptr.add(idx)).write(val);
1702+
slice_ptr.add(idx).cast::<T>().write(val);
17031703
}
17041704
}
17051705

@@ -1713,7 +1713,7 @@ unsafe fn slice_remove<T>(slice: &mut [MaybeUninit<T>], idx: usize) -> T {
17131713
let len = slice.len();
17141714
debug_assert!(idx < len);
17151715
let slice_ptr = slice.as_mut_ptr();
1716-
let ret = (*slice_ptr.add(idx)).assume_init_read();
1716+
let ret = slice_ptr.add(idx).cast::<T>().read();
17171717
ptr::copy(slice_ptr.add(idx + 1), slice_ptr.add(idx), len - idx - 1);
17181718
ret
17191719
}

library/alloc/src/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,7 @@ impl Drop for Drain<'_> {
29092909
unsafe {
29102910
// Use Vec::drain. "Reaffirm" the bounds checks to avoid
29112911
// panic code being inserted again.
2912-
let self_vec = (*self.string).as_mut_vec();
2912+
let self_vec = (&mut *self.string).as_mut_vec();
29132913
if self.start <= self.end && self.end <= self_vec.len() {
29142914
self_vec.drain(self.start..self.end);
29152915
}

library/alloc/src/vec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ impl<T, A: Allocator> Vec<T, A> {
19421942
#[cfg(not(no_global_oom_handling))]
19431943
#[inline]
19441944
unsafe fn append_elements(&mut self, other: *const [T]) {
1945-
let count = unsafe { (*other).len() };
1945+
let count = other.len();
19461946
self.reserve(count);
19471947
let len = self.len();
19481948
unsafe { ptr::copy_nonoverlapping(other as *const T, self.as_mut_ptr().add(len), count) };

library/proc_macro/src/bridge/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Env;
1919
impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> {
2020
fn from(f: &'a mut F) -> Self {
2121
unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: *mut Env, arg: A) -> R {
22-
(*(env as *mut _ as *mut F))(arg)
22+
(&mut *(env as *mut _ as *mut F))(arg)
2323
}
2424
Closure { call: call::<A, R, F>, env: f as *mut _ as *mut Env, _marker: PhantomData }
2525
}

library/std/src/sync/mpsc/oneshot.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<T> Packet<T> {
8686
NothingSent => {}
8787
_ => panic!("sending on a oneshot that's already sent on "),
8888
}
89-
assert!((*self.data.get()).is_none());
89+
assert!((&*self.data.get()).is_none());
9090
ptr::write(self.data.get(), Some(t));
9191
ptr::write(self.upgrade.get(), SendUsed);
9292

@@ -289,7 +289,7 @@ impl<T> Packet<T> {
289289
// We then need to check to see if there was an upgrade requested,
290290
// and if so, the upgraded port needs to have its selection aborted.
291291
DISCONNECTED => unsafe {
292-
if (*self.data.get()).is_some() {
292+
if (&*self.data.get()).is_some() {
293293
Ok(true)
294294
} else {
295295
match ptr::replace(self.upgrade.get(), SendUsed) {

library/std/src/sys/unix/stack_overflow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mod imp {
8181
_data: *mut libc::c_void,
8282
) {
8383
let guard = thread_info::stack_guard().unwrap_or(0..0);
84-
let addr = (*info).si_addr() as usize;
84+
let addr = (&*info).si_addr() as usize;
8585

8686
// If the faulting address is within the guard page, then we print a
8787
// message saying so and abort.

library/std/src/thread/local.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ mod lazy {
799799
// the inner cell nor mutable reference to the Option<T> inside said
800800
// cell. This make it safe to hand a reference, though the lifetime
801801
// of 'static is itself unsafe, making the get method unsafe.
802-
unsafe { (*self.inner.get()).as_ref() }
802+
unsafe { (&*self.inner.get()).as_ref() }
803803
}
804804

805805
/// The caller must ensure that no reference is active: this method
@@ -853,7 +853,7 @@ mod lazy {
853853
#[allow(unused)]
854854
pub unsafe fn take(&mut self) -> Option<T> {
855855
// SAFETY: See doc comment for this method.
856-
unsafe { (*self.inner.get()).take() }
856+
unsafe { (&mut *self.inner.get()).take() }
857857
}
858858
}
859859
}

0 commit comments

Comments
 (0)