Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create exe tests #3487

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/api/src/sys/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ impl Imports {
/// Resolve and return a vector of imports in the order they are defined in the `module`'s source code.
///
/// This means the returned `Vec<Extern>` might be a subset of the imports contained in `self`.
#[allow(clippy::result_large_err)]
pub fn imports_for_module(&self, module: &Module) -> Result<Vec<Extern>, LinkError> {
let mut ret = vec![];
for import in module.imports() {
Expand Down
2 changes: 2 additions & 0 deletions lib/api/src/sys/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl Instance {
/// Those are, as defined by the spec:
/// * Link errors that happen when plugging the imports into the instance
/// * Runtime errors that happen when running the module `start` function.
#[allow(clippy::result_large_err)]
pub fn new(
store: &mut impl AsStoreMut,
module: &Module,
Expand Down Expand Up @@ -158,6 +159,7 @@ impl Instance {
/// Those are, as defined by the spec:
/// * Link errors that happen when plugging the imports into the instance
/// * Runtime errors that happen when running the module `start` function.
#[allow(clippy::result_large_err)]
pub fn new_by_index(
store: &mut impl AsStoreMut,
module: &Module,
Expand Down
1 change: 1 addition & 0 deletions lib/api/src/sys/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ impl Module {
}
}

#[allow(clippy::result_large_err)]
#[cfg(feature = "compiler")]
pub(crate) fn instantiate(
&self,
Expand Down
10 changes: 5 additions & 5 deletions lib/c-api/src/wasm_c_api/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct wasm_config_t {
/// cbindgen:ignore
#[no_mangle]
pub extern "C" fn wasm_config_new() -> Box<wasm_config_t> {
Box::new(wasm_config_t::default())
Box::<wasm_config_t>::default()
}

/// Delete a Wasmer config object.
Expand Down Expand Up @@ -256,11 +256,11 @@ use wasmer_api::CompilerConfig;
fn get_default_compiler_config() -> Box<dyn CompilerConfig> {
cfg_if! {
if #[cfg(feature = "cranelift")] {
Box::new(wasmer_compiler_cranelift::Cranelift::default())
Box::<wasmer_compiler_cranelift::Cranelift>::default()
} else if #[cfg(feature = "llvm")] {
Box::new(wasmer_compiler_llvm::LLVM::default())
Box::<wasmer_compiler_llvm::LLVM>::default()
} else if #[cfg(feature = "singlepass")] {
Box::new(wasmer_compiler_singlepass::Singlepass::default())
Box::<wasmer_compiler_singlepass::Singlepass>::default()
} else {
compile_error!("Please enable one of the compiler backends")
}
Expand Down Expand Up @@ -368,7 +368,7 @@ pub extern "C" fn wasm_engine_new_with_config(
wasmer_compiler_t::CRANELIFT => {
cfg_if! {
if #[cfg(feature = "cranelift")] {
Box::new(wasmer_compiler_cranelift::Cranelift::default())
Box::<wasmer_compiler_cranelift::Cranelift>::default()
} else {
return return_with_error("Wasmer has not been compiled with the `cranelift` feature.");
}
Expand Down
4 changes: 2 additions & 2 deletions lib/c-api/src/wasm_c_api/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ pub unsafe extern "C" fn wasi_env_read_stdout(
buffer: *mut c_char,
buffer_len: usize,
) -> isize {
let inner_buffer = slice::from_raw_parts_mut(buffer as *mut _, buffer_len as usize);
let inner_buffer = slice::from_raw_parts_mut(buffer as *mut _, buffer_len);
let mut store_mut = env.store.store_mut();
let state = env.inner.data_mut(&mut store_mut).state();

Expand All @@ -365,7 +365,7 @@ pub unsafe extern "C" fn wasi_env_read_stderr(
buffer: *mut c_char,
buffer_len: usize,
) -> isize {
let inner_buffer = slice::from_raw_parts_mut(buffer as *mut _, buffer_len as usize);
let inner_buffer = slice::from_raw_parts_mut(buffer as *mut _, buffer_len);
let mut store_mut = env.store.store_mut();
let state = env.inner.data_mut(&mut store_mut).state();
if let Ok(mut stderr) = state.stderr() {
Expand Down
2 changes: 1 addition & 1 deletion lib/cache/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ToString for Hash {
/// Create the hexadecimal representation of the
/// stored hash.
fn to_string(&self) -> String {
hex::encode(&self.to_array())
hex::encode(self.to_array())
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::process::Command;
pub fn main() {
// Set WASMER_GIT_HASH
let git_hash = Command::new("git")
.args(&["rev-parse", "HEAD"])
.args(["rev-parse", "HEAD"])
.output()
.ok()
.and_then(|output| String::from_utf8(output.stdout).ok())
Expand Down
10 changes: 5 additions & 5 deletions lib/cli/src/commands/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ fn write_volume_obj(
object_name,
)?;

let mut writer = BufWriter::new(File::create(&output_path)?);
let mut writer = BufWriter::new(File::create(output_path)?);
volumes_object
.write_stream(&mut writer)
.map_err(|err| anyhow::anyhow!(err.to_string()))?;
Expand Down Expand Up @@ -1049,7 +1049,7 @@ pub(crate) fn create_header_files_in_dir(
&ModuleMetadataSymbolRegistry {
prefix: prefix.clone(),
},
metadata_length as usize,
metadata_length,
);

std::fs::write(&header_file_path, &header_file_src).map_err(|e| {
Expand Down Expand Up @@ -1194,7 +1194,7 @@ fn link_exe_from_dir(
.as_ref()
.ok_or_else(|| anyhow::anyhow!("could not find zig in $PATH {}", directory.display()))?;

let mut cmd = Command::new(&zig_binary_path);
let mut cmd = Command::new(zig_binary_path);
cmd.arg("build-exe");
cmd.arg("--verbose-cc");
cmd.arg("--verbose-link");
Expand Down Expand Up @@ -1875,7 +1875,7 @@ pub(super) mod utils {
let path_var = std::env::var("PATH").unwrap_or_default();
#[cfg(unix)]
let system_path_var = std::process::Command::new("getconf")
.args(&["PATH"])
.args(["PATH"])
.output()
.map(|output| output.stdout)
.unwrap_or_default();
Expand Down Expand Up @@ -2268,7 +2268,7 @@ mod http_fetch {

pub(crate) fn list_dir(target: &Path) -> Vec<PathBuf> {
use walkdir::WalkDir;
WalkDir::new(&target)
WalkDir::new(target)
.into_iter()
.filter_map(|e| e.ok())
.map(|entry| entry.path().to_path_buf())
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Init {
.collect::<Vec<_>>()
.join(NEWLINE);

std::fs::write(&path, &toml_string)
std::fs::write(path, &toml_string)
.with_context(|| format!("Unable to write to \"{}\"", path.display()))?;

Ok(())
Expand Down Expand Up @@ -493,7 +493,7 @@ fn construct_manifest(
}
fn parse_cargo_toml(manifest_path: &PathBuf) -> Result<MiniCargoTomlPackage, anyhow::Error> {
let mut metadata = MetadataCommand::new();
metadata.manifest_path(&manifest_path);
metadata.manifest_path(manifest_path);
metadata.no_deps();
metadata.features(CargoOpt::AllFeatures);

Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ fn append_path_to_tar_gz(
.metadata()
.map_err(|e| (normalized_path.clone(), e))?;
builder
.append_path_with_name(&normalized_path, &target_path)
.append_path_with_name(&normalized_path, target_path)
.map_err(|e| (normalized_path.clone(), e))?;
Ok(normalized_path)
}
Expand Down Expand Up @@ -386,7 +386,7 @@ fn apply_migration(conn: &mut Connection, migration_number: i32) -> Result<(), M
tx.execute_batch(migration_to_apply)
.map_err(|e| MigrationError::TransactionFailed(migration_number, format!("{}", e)))?;

tx.pragma_update(None, "user_version", &(migration_number + 1))
tx.pragma_update(None, "user_version", (migration_number + 1))
.map_err(|e| MigrationError::TransactionFailed(migration_number, format!("{}", e)))?;
tx.commit()
.map_err(|_| MigrationError::CommitFailed(migration_number))
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl RunWithPathBuf {
let default = HashMap::default();
let fs = manifest.fs.as_ref().unwrap_or(&default);
for (alias, real_dir) in fs.iter() {
let real_dir = self_clone.path.join(&real_dir);
let real_dir = self_clone.path.join(real_dir);
if !real_dir.exists() {
#[cfg(feature = "debug")]
if self_clone.debug {
Expand Down
13 changes: 4 additions & 9 deletions lib/compiler-llvm/src/abi/aarch64_systemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@ impl Abi for Aarch64SystemV {
// Given a function definition, retrieve the parameter that is the vmctx pointer.
fn get_vmctx_ptr_param<'ctx>(&self, func_value: &FunctionValue<'ctx>) -> PointerValue<'ctx> {
func_value
.get_nth_param(
fschutt marked this conversation as resolved.
Show resolved Hide resolved
if func_value
.get_nth_param(u32::from(
func_value
.get_enum_attribute(
AttributeLoc::Param(0),
Attribute::get_named_enum_kind_id("sret"),
)
.is_some()
{
1
} else {
0
},
)
.is_some(),
))
.unwrap()
.into_pointer_value()
}
Expand Down
13 changes: 4 additions & 9 deletions lib/compiler-llvm/src/abi/x86_64_systemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,14 @@ impl Abi for X86_64SystemV {
// Given a function definition, retrieve the parameter that is the vmctx pointer.
fn get_vmctx_ptr_param<'ctx>(&self, func_value: &FunctionValue<'ctx>) -> PointerValue<'ctx> {
func_value
.get_nth_param(
if func_value
fschutt marked this conversation as resolved.
Show resolved Hide resolved
.get_nth_param(u32::from(
func_value
.get_enum_attribute(
AttributeLoc::Param(0),
Attribute::get_named_enum_kind_id("sret"),
)
.is_some()
{
1
} else {
0
},
)
.is_some(),
))
.unwrap()
.into_pointer_value()
}
Expand Down
1 change: 1 addition & 0 deletions lib/compiler-llvm/src/translator/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
Ok(())
}

#[allow(clippy::unnecessary_cast)]
fschutt marked this conversation as resolved.
Show resolved Hide resolved
fn resolve_memory_ptr(
&mut self,
memory_index: MemoryIndex,
Expand Down
3 changes: 2 additions & 1 deletion lib/compiler-singlepass/src/arm64_decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::slice::Iter;
use wasmer_types::{CallingConvention, Type};

/// General-purpose registers.
#[allow(clippy::upper_case_acronyms)]
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum GPR {
Expand Down Expand Up @@ -48,7 +49,7 @@ pub enum GPR {
/// NEON registers.
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[allow(dead_code)]
#[allow(dead_code, clippy::upper_case_acronyms)]
pub enum NEON {
V0 = 0,
V1 = 1,
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler-singlepass/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ impl<'a, M: Machine> FuncGen<'a, M> {

let fsm = FunctionStateMap::new(
machine.new_machine_state(),
local_func_index.index() as usize,
local_func_index.index(),
32,
(0..local_types.len())
.map(|_| WasmAbstractValue::Runtime)
Expand Down Expand Up @@ -6057,7 +6057,7 @@ impl<'a, M: Machine> FuncGen<'a, M> {
.emit_call_register(this.machine.get_grp_for_call())
},
// [vmctx, func_index] -> funcref
iter::once(Location::Imm32(function_index as u32)),
iter::once(Location::Imm32(function_index)),
iter::once(WpType::I64),
)?;

Expand Down
Loading