diff --git a/lib/c-api/src/wasm_c_api/engine.rs b/lib/c-api/src/wasm_c_api/engine.rs index d7c3f20c5..24daf409c 100644 --- a/lib/c-api/src/wasm_c_api/engine.rs +++ b/lib/c-api/src/wasm_c_api/engine.rs @@ -136,7 +136,7 @@ cfg_if! { #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { let compiler_config: Box = get_default_compiler_config(); - let engine: Arc = Arc::new(JIT::new(*compiler_config).engine()); + let engine: Arc = Arc::new(JIT::new(compiler_config).engine()); Box::new(wasm_engine_t { inner: engine }) } } @@ -154,7 +154,7 @@ cfg_if! { #[no_mangle] pub extern "C" fn wasm_engine_new() -> Box { let mut compiler_config: Box = get_default_compiler_config(); - let engine: Arc = Arc::new(Native::new( *compiler_config).engine()); + let engine: Arc = Arc::new(Native::new(compiler_config).engine()); Box::new(wasm_engine_t { inner: engine }) } } @@ -243,7 +243,7 @@ pub extern "C" fn wasm_engine_new_with_config( wasmer_engine_t::JIT => { cfg_if! { if #[cfg(feature = "jit")] { - Arc::new(JIT::new(*compiler_config).engine()) + Arc::new(JIT::new(compiler_config).engine()) } else { return return_with_error("Wasmer has not been compiled with the `jit` feature."); } @@ -252,7 +252,7 @@ pub extern "C" fn wasm_engine_new_with_config( wasmer_engine_t::NATIVE => { cfg_if! { if #[cfg(feature = "native")] { - Arc::new(Native::new( *compiler_config).engine()) + Arc::new(Native::new(compiler_config).engine()) } else { return return_with_error("Wasmer has not been compiled with the `native` feature."); } diff --git a/lib/engine-jit/src/builder.rs b/lib/engine-jit/src/builder.rs index 9e4feffa0..0703f018c 100644 --- a/lib/engine-jit/src/builder.rs +++ b/lib/engine-jit/src/builder.rs @@ -11,9 +11,9 @@ pub struct JIT { impl JIT { /// Create a new JIT - pub fn new(compiler_config: impl CompilerConfig + 'static) -> Self { + pub fn new(compiler_config: T) -> Self where T: Into> { Self { - compiler_config: Some(Box::new(compiler_config)), + compiler_config: Some(compiler_config.into()), target: None, features: None, } diff --git a/lib/engine-native/src/builder.rs b/lib/engine-native/src/builder.rs index b24840cf9..4ff08b2de 100644 --- a/lib/engine-native/src/builder.rs +++ b/lib/engine-native/src/builder.rs @@ -11,11 +11,12 @@ pub struct Native { impl Native { #[cfg(feature = "compiler")] /// Create a new Native - pub fn new(mut compiler_config: impl CompilerConfig + 'static) -> Self { + pub fn new(compiler_config: T) -> Self where T: Into> { + let mut compiler_config = compiler_config.into(); compiler_config.enable_pic(); Self { - compiler_config: Some(Box::new(compiler_config)), + compiler_config: Some(compiler_config), target: None, features: None, } diff --git a/lib/engine-object-file/src/builder.rs b/lib/engine-object-file/src/builder.rs index c9aec71bc..4d6b2be3f 100644 --- a/lib/engine-object-file/src/builder.rs +++ b/lib/engine-object-file/src/builder.rs @@ -11,11 +11,12 @@ pub struct ObjectFile { impl ObjectFile { #[cfg(feature = "compiler")] /// Create a new ObjectFile - pub fn new(mut compiler_config: impl CompilerConfig + 'static) -> Self { + pub fn new(compiler_config: T) -> Self where T: Into> { + let mut compiler_config = compiler_config.into(); compiler_config.enable_pic(); Self { - compiler_config: Some(Box::new(compiler_config)), + compiler_config: Some(compiler_config), target: None, features: None, }