diff --git a/src/lib.rs b/src/lib.rs index d0cba39..2446dbd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -137,7 +137,7 @@ extern crate libm; #[derive(Debug)] pub struct Trap { // Needs to be `pub(crate)` to allow `if let` matching in tests - pub(crate) kind: TrapKind, + kind: TrapKind, } impl Trap { diff --git a/src/tests/host.rs b/src/tests/host.rs index e0ce0b9..99b7416 100644 --- a/src/tests/host.rs +++ b/src/tests/host.rs @@ -338,21 +338,24 @@ fn resume_call_host_func_type_mismatch() { } assert!(invocation.is_resumable()); - match invocation - .resume_execution(val, &mut env) - .unwrap_err() - { - ResumableError::Trap(Trap { - kind: TrapKind::UnexpectedSignature, - }) => { - // success + let err = invocation.resume_execution(val, &mut env).unwrap_err(); + + match &err { + ResumableError::Trap(trap) => { + if let TrapKind::UnexpectedSignature = trap.kind() { + return; + } } - other => panic!( - "Expected `ResumableError::Trap(Trap {{ kind: \ - TrapKind::UnexpectedSignature, }})`, got `{:?}`", - other - ), - }; + _ => {} + } + + // If didn't return in the previous `match`... + + panic!( + "Expected `ResumableError::Trap(Trap {{ kind: \ + TrapKind::UnexpectedSignature, }})`, got `{:?}`", + err + ) } resume_with_val(None);