From c7b83e8ef902c3f03bd7d8c5a2f6543ae8c9b5f6 Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Tue, 25 Apr 2023 07:15:53 -0700 Subject: [PATCH] wasmtime: remove `drop(&mut ...)` used to silence warnings (#6278) The `Config` needs to be mutable while building a compiler, but in a build configuration without a compiler, declaring it as `mut` produces a warning since nothing else needs that. I found the existing workaround for this warning confusing, so this PR removes `mut` from the binding for `config` and instead re-binds the variable in builds where we call `build_compiler`. --- crates/wasmtime/src/config.rs | 4 ++-- crates/wasmtime/src/engine.rs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index 504d8d22b0..99b7ca8604 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -1520,7 +1520,7 @@ impl Config { } #[cfg(compiler)] - pub(crate) fn build_compiler(&mut self) -> Result> { + pub(crate) fn build_compiler(mut self) -> Result<(Self, Box)> { let mut compiler = match self.compiler_config.strategy { #[cfg(feature = "cranelift")] Strategy::Auto => wasmtime_cranelift::builder(), @@ -1614,7 +1614,7 @@ impl Config { compiler.enable_incremental_compilation(cache_store.clone())?; } - compiler.build() + Ok((self, compiler.build()?)) } /// Internal setting for whether adapter modules for components will have diff --git a/crates/wasmtime/src/engine.rs b/crates/wasmtime/src/engine.rs index 2db8602fc7..31eddbe5d2 100644 --- a/crates/wasmtime/src/engine.rs +++ b/crates/wasmtime/src/engine.rs @@ -81,12 +81,11 @@ impl Engine { debug_builtins::ensure_exported(); let registry = SignatureRegistry::new(); - let mut config = config.clone(); + let config = config.clone(); config.validate()?; #[cfg(compiler)] - let compiler = config.build_compiler()?; - drop(&mut config); // silence warnings without `cfg(compiler)` + let (config, compiler) = config.build_compiler()?; let allocator = config.build_allocator()?; let profiler = config.build_profiler()?;