diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8eff309..e2260f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,17 +152,16 @@ jobs: - name: Test with Itanium backend run: LITHIUM_BACKEND=itanium cargo valgrind test - # TODO: Restore this when strict provenance APIs are in stable. - # test_stable: - # runs-on: ubuntu-latest - # if: success() || failure() - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - # - name: Install Rust - # run: rustup update stable && rustup default stable - # - name: Test with panic backend - # run: cargo test + test_stable: + runs-on: ubuntu-latest + if: success() || failure() + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust + run: rustup update stable && rustup default stable + - name: Test with panic backend + run: cargo test lint: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 4579c8a..d2a5b57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,6 +201,7 @@ dependencies = [ "criterion", "replace_with", "rustc_version", + "sptr", "typeid", ] @@ -346,6 +347,12 @@ dependencies = [ "serde", ] +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + [[package]] name = "syn" version = "2.0.85" diff --git a/Cargo.toml b/Cargo.toml index b9266fc..f457482 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ edition = "2021" links = "rustlithium" # Force uniqueness of crate version [dependencies] +sptr = "0.3.2" typeid = "1.0.2" [dev-dependencies] diff --git a/src/heterogeneous_stack/array.rs b/src/heterogeneous_stack/array.rs index 9aa922c..210fcb1 100644 --- a/src/heterogeneous_stack/array.rs +++ b/src/heterogeneous_stack/array.rs @@ -2,6 +2,12 @@ use super::align::assert_aligned; use core::cell::{Cell, UnsafeCell}; use core::mem::MaybeUninit; +#[allow( + unused_imports, + reason = "XXX: remove when strict provenance is stabilized" +)] +use sptr::Strict; + /// A thread-unsafe array-backed stack allocator. /// /// This allocator can allocate values with sizes that are multiples of `align_of::()`, @@ -49,7 +55,9 @@ impl Stack { if n == 0 { // Dangling pointers to ZSTs are always valid and unique. Creating `*mut AlignAs` // instead of *mut u8` forces alignment. - return Some(core::ptr::dangling_mut::().cast()); + // XXX: Replace with `return Some(core::ptr::dangling_mut::().cast());` when + // strict provenance is stabilized + return Some(align_of::() as *mut u8); } // SAFETY: len <= CAPACITY is an invariant diff --git a/src/heterogeneous_stack/heap.rs b/src/heterogeneous_stack/heap.rs index f00b048..52893db 100644 --- a/src/heterogeneous_stack/heap.rs +++ b/src/heterogeneous_stack/heap.rs @@ -3,6 +3,12 @@ use alloc::alloc; use core::alloc::Layout; use core::marker::PhantomData; +#[allow( + unused_imports, + reason = "XXX: remove when strict provenance is stabilized" +)] +use sptr::Strict; + /// A heap-backed allocator. /// /// This allocator can allocate values with sizes that are multiples of `align_of::()`, diff --git a/src/heterogeneous_stack/unbounded.rs b/src/heterogeneous_stack/unbounded.rs index 8bbad77..269fd55 100644 --- a/src/heterogeneous_stack/unbounded.rs +++ b/src/heterogeneous_stack/unbounded.rs @@ -1,5 +1,11 @@ use super::{align::assert_aligned, array::Stack as BoundedStack, heap::Heap}; +#[allow( + unused_imports, + reason = "XXX: remove when strict provenance is stabilized" +)] +use sptr::Strict; + /// A thread-unsafe heterogeneous stack, using statically allocated space when possible. /// /// Although the stack doesn't track runtime types, all elements are considered independent. Stack diff --git a/src/lib.rs b/src/lib.rs index b4a94b1..defa3c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,6 +140,10 @@ clippy::inline_always, reason = "I'm not an idiot, this is a result of benchmarking/profiling" )] +#![allow( + unstable_name_collisions, + reason = "XXX: remove when strict provenance is stabilized" +)] extern crate alloc;