Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Use `ensure!(cond, ...)` instead of `if !cond { bail!(...) }` in config validation (#12068)

Nick Fitzgerald27a8591ca188
diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs
index fc74ad246c..af9e16eebd 100644
--- a/crates/wasmtime/src/config.rs
+++ b/crates/wasmtime/src/config.rs
@@ -2410,12 +2410,14 @@ impl Config {
};
if tunables.debug_guest {
- if !cfg!(feature = "debug") {
- bail!("debug instrumentation support was disabled at compile time");
- }
- if tunables.signals_based_traps {
- bail!("cannot use signals-based traps with guest debugging enabled");
- }
+ ensure!(
+ cfg!(feature = "debug"),
+ "debug instrumentation support was disabled at compile time"
+ );
+ ensure!(
+ !tunables.signals_based_traps,
+ "cannot use signals-based traps with guest debugging enabled"
+ );
}
Ok((tunables, features))