-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #162 - thomcc:maybe-uninit, r=emilio
Use MaybeUninit for storage of inline items Fixes #126 I didn't see a PR open for this, and was poking around so I figured I'd do it. Sorry if I stepped on anyone's toes. This should remove the use of mem::uninitialized, and ensure that all values used directly or via references are initialized. (e.g. T and &T are always initialized, but `*const T` and `*mut T` may not be, which is fine). With these changes, `miri` passes. I also changed the CI to run `miri`, hopefully. That said, this includes three breaking changes, so it will require a min version bump. 1. The functions on the `Array` trait `ptr` and `ptr_mut` have been removed. Because these took a `&self`/`&mut self` argument, there's no way for us to call them when we only have a `MaybeUninit<A>`. Now, we just use the memory of the object directly. This limits the flexibility of custom implementations of `Array`, as they can no longer return pointers to values other than themselves, but hopefully nobody does that (IMO there's a pretty good case for sealing `Array`...) 2. `SmallVec::from_buf_and_len_unchecked` now takes a MaybeUninit<A> and not an A. This means that callers have the option of only partially initializing said array without risking nasal demons. I can undo this change if desired, as it's 3. Rust 1.36.0 is required to use MaybeUninit, so this bumps the MSRV from 1.20.0 to 1.36.0. It seems tricky to make the use of MaybeUninit optional here, at least without a bunch or work (ignoring the fact that doing so would require adding a build.rs which parses `rustc -Vv` to tell us the version). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/162) <!-- Reviewable:end -->
- Loading branch information
Showing
3 changed files
with
73 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/bash | ||
|
||
set -ex | ||
|
||
# Clean out our target dir, which may have artifacts compiled by a version of | ||
# rust different from the one we're about to download. | ||
cargo clean | ||
|
||
# Install and run the latest version of nightly where miri built successfully. | ||
# Taken from: https://github.com/rust-lang/miri#running-miri-on-ci | ||
|
||
MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri) | ||
echo "Installing latest nightly with Miri: $MIRI_NIGHTLY" | ||
rustup default "$MIRI_NIGHTLY" | ||
|
||
rustup component add miri | ||
cargo miri setup | ||
|
||
cargo miri test --verbose -- -- -Zunstable-options --exclude-should-panic | ||
cargo miri test --verbose --features union -- -- -Zunstable-options --exclude-should-panic | ||
cargo miri test --verbose --all-features -- -- -Zunstable-options --exclude-should-panic |