about summary refs log tree commit diff
path: root/compiler/rustc_arena
diff options
context:
space:
mode:
authorJohn Bobbo <johnbobbo59@gmail.com>2023-04-27 19:48:37 -0700
committerJohn Bobbo <johnbobbo59@gmail.com>2023-04-27 19:48:37 -0700
commit618841b8156a85ff937b755626eae0983c05da25 (patch)
treefecf64f32a76c99ff089cbe2680f45af79ce4177 /compiler/rustc_arena
parent1a6ae3d692cfb52b21d0f45ba50b659486e53d6c (diff)
downloadrust-618841b8156a85ff937b755626eae0983c05da25.tar.gz
rust-618841b8156a85ff937b755626eae0983c05da25.zip
Use `NonNull::new_unchecked` and `NonNull::len` in
`rustc_arena`.
Diffstat (limited to 'compiler/rustc_arena')
-rw-r--r--compiler/rustc_arena/src/lib.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs
index 345e058e113..236bdb99709 100644
--- a/compiler/rustc_arena/src/lib.rs
+++ b/compiler/rustc_arena/src/lib.rs
@@ -74,7 +74,7 @@ impl<T> ArenaChunk<T> {
     #[inline]
     unsafe fn new(capacity: usize) -> ArenaChunk<T> {
         ArenaChunk {
-            storage: NonNull::new(Box::into_raw(Box::new_uninit_slice(capacity))).unwrap(),
+            storage: NonNull::new_unchecked(Box::into_raw(Box::new_uninit_slice(capacity))),
             entries: 0,
         }
     }
@@ -85,7 +85,7 @@ impl<T> ArenaChunk<T> {
         // The branch on needs_drop() is an -O1 performance optimization.
         // Without the branch, dropping TypedArena<u8> takes linear time.
         if mem::needs_drop::<T>() {
-            let slice = &mut *(self.storage.as_mut());
+            let slice = self.storage.as_mut();
             ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut slice[..len]));
         }
     }
@@ -104,7 +104,7 @@ impl<T> ArenaChunk<T> {
                 // A pointer as large as possible for zero-sized elements.
                 ptr::invalid_mut(!0)
             } else {
-                self.start().add((*self.storage.as_ptr()).len())
+                self.start().add(self.storage.len())
             }
         }
     }
@@ -288,7 +288,7 @@ impl<T> TypedArena<T> {
                 // If the previous chunk's len is less than HUGE_PAGE
                 // bytes, then this chunk will be least double the previous
                 // chunk's size.
-                new_cap = (*last_chunk.storage.as_ptr()).len().min(HUGE_PAGE / elem_size / 2);
+                new_cap = last_chunk.storage.len().min(HUGE_PAGE / elem_size / 2);
                 new_cap *= 2;
             } else {
                 new_cap = PAGE / elem_size;
@@ -396,7 +396,7 @@ impl DroplessArena {
                 // If the previous chunk's len is less than HUGE_PAGE
                 // bytes, then this chunk will be least double the previous
                 // chunk's size.
-                new_cap = (*last_chunk.storage.as_ptr()).len().min(HUGE_PAGE / 2);
+                new_cap = last_chunk.storage.len().min(HUGE_PAGE / 2);
                 new_cap *= 2;
             } else {
                 new_cap = PAGE;