cranelift-interpreter: Propagate traps across calls (#6156)

* cranelift-interpreter: Propagate traps from call's

* cranelift-interpreter: Make `unwrap_return` only available in tests

This is a footgun for normal use in the interpreter (#6156) but it
still has uses in the tests, so enable it only there.
This commit is contained in:
Afonso Bordado
2023-04-05 20:09:48 +01:00
committed by GitHub
parent 05eef95770
commit 064968b01d
2 changed files with 66 additions and 8 deletions

View File

@@ -1397,6 +1397,7 @@ pub enum ControlFlow<'a, V> {
impl<'a, V> ControlFlow<'a, V> {
/// For convenience, we can unwrap the [ControlFlow] state assuming that it is a
/// [ControlFlow::Return], panicking otherwise.
#[cfg(test)]
pub fn unwrap_return(self) -> Vec<V> {
if let ControlFlow::Return(values) = self {
values.into_vec()
@@ -1407,6 +1408,7 @@ impl<'a, V> ControlFlow<'a, V> {
/// For convenience, we can unwrap the [ControlFlow] state assuming that it is a
/// [ControlFlow::Trap], panicking otherwise.
#[cfg(test)]
pub fn unwrap_trap(self) -> CraneliftTrap {
if let ControlFlow::Trap(trap) = self {
trap