Skip to content

Commit

Permalink
Make it compile on stable
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesyringa committed Oct 30, 2024
1 parent 5923d7e commit aded19b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 12 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ edition = "2021"
links = "rustlithium" # Force uniqueness of crate version

[dependencies]
sptr = "0.3.2"
typeid = "1.0.2"

[dev-dependencies]
Expand Down
10 changes: 9 additions & 1 deletion src/heterogeneous_stack/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<AlignAs>()`,
Expand Down Expand Up @@ -49,7 +55,9 @@ impl<AlignAs, const CAPACITY: usize> Stack<AlignAs, CAPACITY> {
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::<AlignAs>().cast());
// XXX: Replace with `return Some(core::ptr::dangling_mut::<AlignAs>().cast());` when
// strict provenance is stabilized
return Some(align_of::<AlignAs>() as *mut u8);
}

// SAFETY: len <= CAPACITY is an invariant
Expand Down
6 changes: 6 additions & 0 deletions src/heterogeneous_stack/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<AlignAs>()`,
Expand Down
6 changes: 6 additions & 0 deletions src/heterogeneous_stack/unbounded.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit aded19b

Please sign in to comment.