diff --git a/Cargo.toml b/Cargo.toml index 798230e..9d22434 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,15 +11,19 @@ repository = "https://github.com/phil-opp/linked-list-allocator" documentation = "https://docs.rs/crate/linked_list_allocator" homepage = "http://os.phil-opp.com/kernel-heap.html#a-better-allocator" +rust-version = "1.61" + [features] -default = ["use_spin_nightly"] +default = ["use_spin"] use_spin = ["spinning_top"] -use_spin_nightly = ["use_spin", "spinning_top/nightly", "const_mut_refs"] +# deprecated - use `use_spin` instead +use_spin_nightly = ["use_spin"] alloc_ref = [] +# deprecated - no effect const_mut_refs = [] [dependencies.spinning_top] -version = "0.2.3" +version = "0.2.5" optional = true [package.metadata.release] diff --git a/Changelog.md b/Changelog.md index ac3412d..a17a1d5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Unreleased +- Remove features const_mut_refs and use_spin_nightly. Since rust 1.61, the underlying const functions are available in stable rust, + and lock_api >= 0.4.7 automatically uses them. (Feature const_fn_trait_bound, https://github.com/rust-lang/rust/pull/93827) + To avoid a breaking change, the features are still listed in Cargo.toml, but have no effect and are marked as deprecated. + This bumps the minimum supported rust version to 1.61. + # 0.10.4 – 2022-10-10 - Fix [memory leak of small back paddings](https://github.com/rust-osdev/linked-list-allocator/issues/66) by considering regions that would result in such small back paddings as unsuitable ([#71](https://github.com/rust-osdev/linked-list-allocator/pull/71)) diff --git a/README.md b/README.md index c7ea32f..56ba834 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,6 @@ pub fn init_heap() { ## Features - **`use_spin`** (default): Provide a `LockedHeap` type that implements the [`GlobalAlloc`] trait by using a spinlock. -- **`const_mut_refs`** (default): Makes the `Heap::empty` function `const`; requires nightly Rust. -- **`use_spin_nightly`** (default): Makes the `LockedHeap::empty` function `const`, automatically enables `use_spin` and `const_mut_refs`; requires nightly Rust. - **`alloc_ref`**: Provide an implementation of the unstable [`AllocRef`] trait; requires nightly Rust. - Warning: The `AllocRef` trait is still regularly changed on the Rust side, so expect some regular breakage when using this feature. diff --git a/src/hole.rs b/src/hole.rs index c50195c..f7481bf 100644 --- a/src/hole.rs +++ b/src/hole.rs @@ -257,21 +257,6 @@ fn check_merge_bottom(node: NonNull, bottom: *mut u8) -> NonNull { impl HoleList { /// Creates an empty `HoleList`. - #[cfg(not(feature = "const_mut_refs"))] - pub fn empty() -> HoleList { - HoleList { - first: Hole { - size: 0, - next: None, - }, - bottom: null_mut(), - top: null_mut(), - pending_extend: 0, - } - } - - /// Creates an empty `HoleList`. - #[cfg(feature = "const_mut_refs")] pub const fn empty() -> HoleList { HoleList { first: Hole { diff --git a/src/lib.rs b/src/lib.rs index 5c82a00..9e85882 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -#![cfg_attr(feature = "const_mut_refs", feature(const_mut_refs))] #![cfg_attr( feature = "alloc_ref", feature(allocator_api, alloc_layout_extra, nonnull_slice_from_raw_parts) @@ -55,15 +54,6 @@ unsafe impl Send for Heap {} impl Heap { /// Creates an empty heap. All allocate calls will return `None`. - #[cfg(not(feature = "const_mut_refs"))] - pub fn empty() -> Heap { - Heap { - used: 0, - holes: HoleList::empty(), - } - } - - #[cfg(feature = "const_mut_refs")] pub const fn empty() -> Heap { Heap { used: 0, @@ -300,18 +290,10 @@ pub struct LockedHeap(Spinlock); #[cfg(feature = "use_spin")] impl LockedHeap { - /// Creates an empty heap. All allocate calls will return `None`. - #[cfg(feature = "use_spin_nightly")] pub const fn empty() -> LockedHeap { LockedHeap(Spinlock::new(Heap::empty())) } - /// Creates an empty heap. All allocate calls will return `None`. - #[cfg(not(feature = "use_spin_nightly"))] - pub fn empty() -> LockedHeap { - LockedHeap(Spinlock::new(Heap::empty())) - } - /// Creates a new heap with the given `bottom` and `size`. /// /// The `heap_bottom` pointer is automatically aligned, so the [`bottom()`][Heap::bottom]