diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ae83d1..6d1cd01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,6 +72,12 @@ jobs: - name: "Run cargo test without features on stable" run: cargo +stable test --no-default-features + - name: "Build with `use_spin` feature on stable" + run: cargo +stable build --no-default-features --features use_spin + + - name: "Run cargo test with `use_spin` feature on stable" + run: cargo +stable test --no-default-features --features use_spin + test-unstable: name: "Test unstable features" diff --git a/Cargo.toml b/Cargo.toml index 370eaa7..9e4778f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,11 +15,10 @@ homepage = "http://os.phil-opp.com/kernel-heap.html#a-better-allocator" default = ["use_spin", "const_mut_refs"] use_spin = ["spinning_top"] alloc_ref = [] -const_mut_refs = [] +const_mut_refs = ["spinning_top/nightly"] [dependencies.spinning_top] version = "0.1.0" -features = ["nightly"] optional = true [package.metadata.release] diff --git a/Changelog.md b/Changelog.md index 9958a69..5113416 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Don't require nightly for `use_spin` feature ([#46](https://github.com/phil-opp/linked-list-allocator/pull/46)) + # 0.8.8 – 2020-12-16 - Do not require alloc crate ([#44](https://github.com/phil-opp/linked-list-allocator/pull/44)) diff --git a/src/lib.rs b/src/lib.rs index 99a4378..dbadb18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -194,10 +194,17 @@ pub struct LockedHeap(Spinlock); #[cfg(feature = "use_spin")] impl LockedHeap { /// Creates an empty heap. All allocate calls will return `None`. + #[cfg(feature = "const_mut_refs")] pub const fn empty() -> LockedHeap { LockedHeap(Spinlock::new(Heap::empty())) } + /// Creates an empty heap. All allocate calls will return `None`. + #[cfg(not(feature = "const_mut_refs"))] + pub fn empty() -> LockedHeap { + LockedHeap(Spinlock::new(Heap::empty())) + } + /// Creates a new heap with the given `bottom` and `size`. The bottom address must be valid /// and the memory in the `[heap_bottom, heap_bottom + heap_size)` range must not be used for /// anything else. This function is unsafe because it can cause undefined behavior if the