|
6 | 6 |
|
7 | 7 | use core::marker::PhantomData;
|
8 | 8 | use core::mem::{ManuallyDrop, MaybeUninit, SizedTypeProperties};
|
9 |
| -use core::ptr::{self, NonNull, Unique}; |
| 9 | +use core::ptr::{self, Alignment, NonNull, Unique}; |
10 | 10 | use core::{cmp, hint};
|
11 | 11 |
|
12 | 12 | #[cfg(not(no_global_oom_handling))]
|
@@ -177,7 +177,7 @@ impl<T, A: Allocator> RawVec<T, A> {
|
177 | 177 | /// the returned `RawVec`.
|
178 | 178 | #[inline]
|
179 | 179 | pub(crate) const fn new_in(alloc: A) -> Self {
|
180 |
| - Self { inner: RawVecInner::new_in(alloc, align_of::<T>()), _marker: PhantomData } |
| 180 | + Self { inner: RawVecInner::new_in(alloc, Alignment::of::<T>()), _marker: PhantomData } |
181 | 181 | }
|
182 | 182 |
|
183 | 183 | /// Like `with_capacity`, but parameterized over the choice of
|
@@ -409,7 +409,8 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec<T, A> {
|
409 | 409 |
|
410 | 410 | impl<A: Allocator> RawVecInner<A> {
|
411 | 411 | #[inline]
|
412 |
| - const fn new_in(alloc: A, align: usize) -> Self { |
| 412 | + const fn new_in(alloc: A, align: Alignment) -> Self { |
| 413 | + // SAFETY: `Alignment` is non-zero. |
413 | 414 | let ptr = unsafe { core::mem::transmute(align) };
|
414 | 415 | // `cap: 0` means "unallocated". zero-sized types are ignored.
|
415 | 416 | Self { ptr, cap: ZERO_CAP, alloc }
|
@@ -465,7 +466,7 @@ impl<A: Allocator> RawVecInner<A> {
|
465 | 466 |
|
466 | 467 | // Don't allocate here because `Drop` will not deallocate when `capacity` is 0.
|
467 | 468 | if layout.size() == 0 {
|
468 |
| - return Ok(Self::new_in(alloc, elem_layout.align())); |
| 469 | + return Ok(Self::new_in(alloc, elem_layout.alignment())); |
469 | 470 | }
|
470 | 471 |
|
471 | 472 | if let Err(err) = alloc_guard(layout.size()) {
|
|
0 commit comments