Skip to content

Commit

Permalink
Avoid intermediate slice reference in uninitialized_array (fixes #54)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc committed Jan 9, 2023
1 parent afbe7b7 commit 80d469e
Show file tree
Hide file tree
Showing 2 changed files with 12 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 @@ -62,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.36.0
- uses: dtolnay/rust-toolchain@1.41.0
# Can't run tests because we have ed2021 crates in the dev-dependency
# graph, which old cargo can't parse. It seems likely that tests would
# pass on older versions if the crate builds and they pass on stable,
Expand All @@ -89,13 +89,12 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- run: cargo doc --all-features

# FIXME (currently fails)
# miri:
# name: Miri
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@nightly
# with:
# components: miri, rust-src
# - run: cargo miri test --all-features
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri, rust-src
- run: cargo miri test --all-features
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ use core::cell::RefCell;
use core::cmp;
use core::iter;
use core::mem;
use core::ptr;
use core::slice;
use core::str;

Expand Down Expand Up @@ -403,7 +404,7 @@ impl<T> Arena<T> {
// Go through pointers, to make sure we never create a reference to uninitialized T.
let start = chunks.current.as_mut_ptr().offset(next_item_index as isize);
let start_uninit = start as *mut MaybeUninit<T>;
slice::from_raw_parts_mut(start_uninit, len) as *mut _
ptr::slice_from_raw_parts_mut(start_uninit, len)
}
}

Expand Down

0 comments on commit 80d469e

Please sign in to comment.