Skip to content

Commit 48153a0

Browse files
committed
chore: prefer raw keyword instead of addr_of* since it is soft deprecated
1 parent 4b5ce32 commit 48153a0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

core/string/src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
marker::PhantomData,
1010
mem::ManuallyDrop,
1111
ops::{Add, AddAssign},
12-
ptr::{self, addr_of_mut, NonNull},
12+
ptr::{self, NonNull},
1313
str::{self},
1414
};
1515

@@ -143,7 +143,7 @@ impl<D: Copy> JsStringBuilder<D> {
143143
unsafe fn data(&self) -> *mut D {
144144
// SAFETY:
145145
// Caller should ensure that the inner is allocated.
146-
unsafe { addr_of_mut!((*self.inner.as_ptr()).data).cast() }
146+
unsafe { (&raw mut (*self.inner.as_ptr()).data).cast() }
147147
}
148148

149149
/// Allocates when there is not sufficient capacity.

core/string/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use std::{
4545
iter::Peekable,
4646
mem::ManuallyDrop,
4747
process::abort,
48-
ptr::{self, addr_of, addr_of_mut, NonNull},
48+
ptr::{self, NonNull},
4949
str::FromStr,
5050
};
5151

@@ -347,9 +347,9 @@ impl JsString {
347347
let ptr = if (*h).refcount.read_only == 0 {
348348
let h = h.cast::<StaticJsString>();
349349
(*h).ptr
350-
} else {
350+
} else {
351351
(&raw const (*h).data).cast::<u8>()
352-
};
352+
};
353353

354354
if is_latin1 {
355355
JsStr::latin1(std::slice::from_raw_parts(ptr, len))
@@ -394,7 +394,7 @@ impl JsString {
394394

395395
let string = {
396396
// SAFETY: `allocate_inner` guarantees that `ptr` is a valid pointer.
397-
let mut data = unsafe { addr_of_mut!((*ptr.as_ptr()).data).cast::<u8>() };
397+
let mut data = unsafe { (&raw mut (*ptr.as_ptr()).data).cast::<u8>() };
398398
for &string in strings {
399399
// SAFETY:
400400
// The sum of all `count` for each `string` equals `full_count`, and since we're
@@ -801,7 +801,7 @@ impl JsString {
801801
let ptr = Self::allocate_inner(count, string.is_latin1());
802802

803803
// SAFETY: `allocate_inner` guarantees that `ptr` is a valid pointer.
804-
let data = unsafe { addr_of_mut!((*ptr.as_ptr()).data).cast::<u8>() };
804+
let data = unsafe { (&raw mut (*ptr.as_ptr()).data).cast::<u8>() };
805805

806806
// SAFETY:
807807
// - We read `count = data.len()` elements from `data`, which is within the bounds of the slice.

0 commit comments

Comments
 (0)