Skip to content

Commit

Permalink
wasmtime: remove drop(&mut ...) used to silence warnings (bytecodea…
Browse files Browse the repository at this point in the history
…lliance#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`.
  • Loading branch information
jameysharp authored and eduardomourar committed Apr 28, 2023
1 parent b23a13d commit 318830f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/wasmtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions crates/wasmtime/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit 318830f

Please sign in to comment.