Skip to content

Commit

Permalink
Merge pull request #44 from dtolnay/miri
Browse files Browse the repository at this point in the history
Add a miri test job in CI
  • Loading branch information
dtolnay authored May 24, 2021
2 parents 1742a76 + 3c917d5 commit edc57bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ jobs:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@clippy
- run: cargo clippy -- -Dclippy::all -Dclippy::pedantic

miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- run: cargo miri test
5 changes: 3 additions & 2 deletions src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Any {

// This is unsafe -- caller is responsible that T is the correct type.
pub(crate) fn view<T>(&mut self) -> &mut T {
if self.fingerprint != Fingerprint::of::<T>() {
if cfg!(not(miri)) && self.fingerprint != Fingerprint::of::<T>() {
self.invalid_cast_to::<T>();
}

Expand All @@ -100,7 +100,7 @@ impl Any {

// This is unsafe -- caller is responsible that T is the correct type.
pub(crate) fn take<T>(mut self) -> T {
if self.fingerprint != Fingerprint::of::<T>() {
if cfg!(not(miri)) && self.fingerprint != Fingerprint::of::<T>() {
self.invalid_cast_to::<T>();
}

Expand Down Expand Up @@ -168,6 +168,7 @@ impl Fingerprint {
}
}

#[cfg(not(miri))]
#[test]
fn test_fingerprint() {
assert_eq!(Fingerprint::of::<usize>(), Fingerprint::of::<usize>());
Expand Down

0 comments on commit edc57bb

Please sign in to comment.