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`.
This commit is contained in:
@@ -1520,7 +1520,7 @@ impl Config {
|
||||
}
|
||||
|
||||
#[cfg(compiler)]
|
||||
pub(crate) fn build_compiler(&mut self) -> Result<Box<dyn wasmtime_environ::Compiler>> {
|
||||
pub(crate) fn build_compiler(mut self) -> Result<(Self, Box<dyn wasmtime_environ::Compiler>)> {
|
||||
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
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
Reference in New Issue
Block a user