Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run miri on CI #82

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ jobs:
command: test
args: ${{ matrix.features }}

miri:
name: Miri
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
features:
- --all-features
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
components: miri
- uses: actions-rs/cargo@v1
with:
command: miri
args: test ${{ matrix.features }}

test-msrv:
name: Test Suite
runs-on: ubuntu-latest
Expand Down
23 changes: 6 additions & 17 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ where
E: StdError + Send + Sync + 'static,
{
// Attach ErrorImpl<E>'s native StdError vtable. The StdError impl is below.
mem::transmute::<Box<ErrorImpl<()>>, Box<ErrorImpl<E>>>(e)
let unerased: Box<ErrorImpl<E>> = Box::from_raw(Box::into_raw(e).cast());
unerased
}

// Safety: requires layout of *e to match ErrorImpl<E>.
Expand Down Expand Up @@ -611,16 +612,10 @@ where
// Called after downcasting by value to either the D or the E and doing a
// ptr::read to take ownership of that value.
if TypeId::of::<D>() == target {
let unerased = mem::transmute::<
Box<ErrorImpl<()>>,
Box<ErrorImpl<ContextError<ManuallyDrop<D>, E>>>,
>(e);
let unerased: Box<ErrorImpl<ContextError<ManuallyDrop<D>, E>>> = Box::from_raw(Box::into_raw(e).cast());
drop(unerased);
} else {
let unerased = mem::transmute::<
Box<ErrorImpl<()>>,
Box<ErrorImpl<ContextError<D, ManuallyDrop<E>>>>,
>(e);
let unerased: Box<ErrorImpl<ContextError<D, ManuallyDrop<E>>>> = Box::from_raw(Box::into_raw(e).cast());
drop(unerased);
}
}
Expand Down Expand Up @@ -649,17 +644,11 @@ where
// Called after downcasting by value to either the D or one of the causes
// and doing a ptr::read to take ownership of that value.
if TypeId::of::<D>() == target {
let unerased = mem::transmute::<
Box<ErrorImpl<()>>,
Box<ErrorImpl<ContextError<ManuallyDrop<D>, Report>>>,
>(e);
let unerased: Box<ErrorImpl<ContextError<ManuallyDrop<D>, Report>>> = Box::from_raw(Box::into_raw(e).cast());
// Drop the entire rest of the data structure rooted in the next Report.
drop(unerased);
} else {
let unerased = mem::transmute::<
Box<ErrorImpl<()>>,
Box<ErrorImpl<ContextError<D, ManuallyDrop<Report>>>>,
>(e);
let unerased: Box<ErrorImpl<ContextError<D, ManuallyDrop<Report>>>> = Box::from_raw(Box::into_raw(e).cast());
// Read out a ManuallyDrop<Box<ErrorImpl<()>>> from the next error.
let inner = ptr::read(&unerased._object.error.inner);
drop(unerased);
Expand Down
1 change: 1 addition & 0 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[rustversion::attr(not(nightly), ignore)]
#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
Expand Down
4 changes: 4 additions & 0 deletions tests/test_location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl eyre::EyreHandler for LocationHandler {
}
}

#[cfg_attr(miri, ignore)]
#[test]
fn test_wrap_err() {
let _ = eyre::set_hook(Box::new(|_e| {
Expand All @@ -54,6 +55,7 @@ fn test_wrap_err() {
println!("{:?}", err);
}

#[cfg_attr(miri, ignore)]
#[test]
fn test_wrap_err_with() {
let _ = eyre::set_hook(Box::new(|_e| {
Expand All @@ -69,6 +71,7 @@ fn test_wrap_err_with() {
println!("{:?}", err);
}

#[cfg_attr(miri, ignore)]
#[test]
fn test_context() {
let _ = eyre::set_hook(Box::new(|_e| {
Expand All @@ -84,6 +87,7 @@ fn test_context() {
println!("{:?}", err);
}

#[cfg_attr(miri, ignore)]
#[test]
fn test_with_context() {
let _ = eyre::set_hook(Box::new(|_e| {
Expand Down
1 change: 1 addition & 0 deletions tests/test_pyo3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fn h() -> Result<()> {
g().wrap_err("g failed")
}

#[cfg_attr(miri, ignore)]
#[test]
fn test_pyo3_exception_contents() {
use pyo3::types::IntoPyDict;
Expand Down