Skip to content

Commit 81f99db

Browse files
authored
Merge pull request #731 from clarfonthey/core-layout
Use core for Layout instead of alloc
2 parents b53fea6 + 0786213 commit 81f99db

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/alloc.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ pub(crate) use self::inner::{Allocator, Global, do_alloc};
88
// This is used when building for `std`.
99
#[cfg(feature = "nightly")]
1010
mod inner {
11+
use core::alloc::Layout;
1112
use core::ptr::NonNull;
1213
#[cfg(test)]
1314
pub(crate) use stdalloc::alloc::AllocError;
14-
use stdalloc::alloc::Layout;
1515
pub(crate) use stdalloc::alloc::{Allocator, Global};
1616

1717
pub(crate) fn do_alloc<A: Allocator>(alloc: &A, layout: Layout) -> Result<NonNull<[u8]>, ()> {
@@ -33,8 +33,8 @@ mod inner {
3333
#[cfg(test)]
3434
pub(crate) use allocator_api2::alloc::AllocError;
3535
pub(crate) use allocator_api2::alloc::{Allocator, Global};
36+
use core::alloc::Layout;
3637
use core::ptr::NonNull;
37-
use stdalloc::alloc::Layout;
3838

3939
pub(crate) fn do_alloc<A: Allocator>(alloc: &A, layout: Layout) -> Result<NonNull<[u8]>, ()> {
4040
match alloc.allocate(layout) {
@@ -54,8 +54,9 @@ mod inner {
5454
// or `nightly` without disturbing users that don't want to use it.
5555
#[cfg(not(any(feature = "nightly", feature = "allocator-api2")))]
5656
mod inner {
57+
use core::alloc::Layout;
5758
use core::ptr::NonNull;
58-
use stdalloc::alloc::{Layout, alloc, dealloc};
59+
use stdalloc::alloc::{alloc, dealloc};
5960

6061
#[expect(clippy::missing_safety_doc)] // not exposed outside of this crate
6162
pub unsafe trait Allocator {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub enum TryReserveError {
168168
/// The memory allocator returned an error
169169
AllocError {
170170
/// The layout of the allocation request that failed.
171-
layout: stdalloc::alloc::Layout,
171+
layout: core::alloc::Layout,
172172
},
173173
}
174174

src/raw.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ use crate::TryReserveError;
22
use crate::control::{BitMaskIter, Group, Tag, TagSliceExt};
33
use crate::scopeguard::{ScopeGuard, guard};
44
use crate::util::{invalid_mut, likely, unlikely};
5+
use core::alloc::Layout;
56
use core::array;
67
use core::iter::FusedIterator;
78
use core::marker::PhantomData;
89
use core::mem;
910
use core::ptr;
1011
use core::ptr::NonNull;
1112
use core::slice;
12-
use stdalloc::alloc::{Layout, handle_alloc_error};
13+
use stdalloc::alloc::handle_alloc_error;
1314

1415
#[cfg(test)]
1516
use crate::alloc::AllocError;

0 commit comments

Comments
 (0)