Skip to content

Commit 2a13628

Browse files
committed
Refactor
1 parent d4c3550 commit 2a13628

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

library/alloc/src/raw_rc.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,13 +1134,10 @@ impl<T, A> RawRc<[T], A> {
11341134
{
11351135
fn drop(&mut self) {
11361136
unsafe {
1137-
let length = self.tail.sub_ptr(self.uninit_rc.uninit_rc.as_ptr().cast());
1137+
let head = self.uninit_rc.uninit_rc.as_ptr().cast();
1138+
let length = self.tail.sub_ptr(head);
11381139

1139-
NonNull::<[T]>::slice_from_raw_parts(
1140-
self.uninit_rc.uninit_rc.as_ptr().cast(),
1141-
length,
1142-
)
1143-
.drop_in_place();
1140+
NonNull::<[T]>::slice_from_raw_parts(head, length).drop_in_place();
11441141
}
11451142
}
11461143
}
@@ -1308,7 +1305,7 @@ where
13081305
T: Default,
13091306
{
13101307
fn spec_default() -> Self {
1311-
unsafe fn spec_default_impl<T, const N: usize>() -> RawRc<T, Global>
1308+
fn spec_default_impl<T, const N: usize>() -> RawRc<T, Global>
13121309
where
13131310
T: Default,
13141311
{
@@ -1360,7 +1357,7 @@ where
13601357
}
13611358

13621359
#[cfg(target_pointer_width = "16")]
1363-
let selected_impl: unsafe fn() -> Self = const {
1360+
let selected_impl: fn() -> Self = const {
13641361
select_impl![
13651362
0x0000, // (1 << 0) - 1
13661363
0x0001, // (1 << 1) - 1
@@ -1380,7 +1377,7 @@ where
13801377
};
13811378

13821379
#[cfg(target_pointer_width = "32")]
1383-
let selected_impl: unsafe fn() -> Self = const {
1380+
let selected_impl: fn() -> Self = const {
13841381
select_impl![
13851382
0x00000000, // (1 << 0) - 1
13861383
0x00000001, // (1 << 1) - 1
@@ -1415,7 +1412,7 @@ where
14151412
};
14161413

14171414
#[cfg(target_pointer_width = "64")]
1418-
let selected_impl: unsafe fn() -> Self = const {
1415+
let selected_impl: fn() -> Self = const {
14191416
select_impl![
14201417
0x0000000000000000, // (1 << 0) - 1
14211418
0x0000000000000001, // (1 << 1) - 1
@@ -1480,7 +1477,7 @@ where
14801477
]
14811478
};
14821479

1483-
unsafe { selected_impl() }
1480+
selected_impl()
14841481
}
14851482
}
14861483

0 commit comments

Comments
 (0)