mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 05:08:19 +00:00
cargo clippy --fix
This commit is contained in:
@@ -211,27 +211,27 @@ fn function_new() -> Result<(), String> {
|
||||
let mut store = Store::default();
|
||||
let function = Function::new_typed(&mut store, || {});
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![], vec![])
|
||||
);
|
||||
let function = Function::new_typed(&mut store, |_a: i32| {});
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![Type::I32], vec![])
|
||||
);
|
||||
let function = Function::new_typed(&mut store, |_a: i32, _b: i64, _c: f32, _d: f64| {});
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![])
|
||||
);
|
||||
let function = Function::new_typed(&mut store, || -> i32 { 1 });
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![], vec![Type::I32])
|
||||
);
|
||||
let function = Function::new_typed(&mut store, || -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) });
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64])
|
||||
);
|
||||
Ok(())
|
||||
@@ -247,13 +247,13 @@ fn function_new_env() -> Result<(), String> {
|
||||
let env = FunctionEnv::new(&mut store, my_env);
|
||||
let function = Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut<MyEnv>| {});
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![], vec![])
|
||||
);
|
||||
let function =
|
||||
Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut<MyEnv>, _a: i32| {});
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![Type::I32], vec![])
|
||||
);
|
||||
let function = Function::new_typed_with_env(
|
||||
@@ -262,13 +262,13 @@ fn function_new_env() -> Result<(), String> {
|
||||
|_env: FunctionEnvMut<MyEnv>, _a: i32, _b: i64, _c: f32, _d: f64| {},
|
||||
);
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![])
|
||||
);
|
||||
let function =
|
||||
Function::new_typed_with_env(&mut store, &env, |_env: FunctionEnvMut<MyEnv>| -> i32 { 1 });
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![], vec![Type::I32])
|
||||
);
|
||||
let function = Function::new_typed_with_env(
|
||||
@@ -277,7 +277,7 @@ fn function_new_env() -> Result<(), String> {
|
||||
|_env: FunctionEnvMut<MyEnv>| -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) },
|
||||
);
|
||||
assert_eq!(
|
||||
function.ty(&mut store).clone(),
|
||||
function.ty(&mut store),
|
||||
FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64])
|
||||
);
|
||||
Ok(())
|
||||
@@ -294,35 +294,35 @@ fn function_new_dynamic() -> Result<(), String> {
|
||||
&function_type,
|
||||
|_values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![Type::I32], vec![]);
|
||||
let function = Function::new(
|
||||
&mut store,
|
||||
&function_type,
|
||||
|_values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]);
|
||||
let function = Function::new(
|
||||
&mut store,
|
||||
&function_type,
|
||||
|_values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![], vec![Type::I32]);
|
||||
let function = Function::new(
|
||||
&mut store,
|
||||
&function_type,
|
||||
|_values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]);
|
||||
let function = Function::new(
|
||||
&mut store,
|
||||
&function_type,
|
||||
|_values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
|
||||
// Using array signature
|
||||
let function_type = ([Type::V128], [Type::I32, Type::F32, Type::F64]);
|
||||
@@ -356,7 +356,7 @@ fn function_new_dynamic_env() -> Result<(), String> {
|
||||
&function_type,
|
||||
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![Type::I32], vec![]);
|
||||
let function = Function::new_with_env(
|
||||
&mut store,
|
||||
@@ -364,7 +364,7 @@ fn function_new_dynamic_env() -> Result<(), String> {
|
||||
&function_type,
|
||||
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]);
|
||||
let function = Function::new_with_env(
|
||||
&mut store,
|
||||
@@ -372,7 +372,7 @@ fn function_new_dynamic_env() -> Result<(), String> {
|
||||
&function_type,
|
||||
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![], vec![Type::I32]);
|
||||
let function = Function::new_with_env(
|
||||
&mut store,
|
||||
@@ -380,7 +380,7 @@ fn function_new_dynamic_env() -> Result<(), String> {
|
||||
&function_type,
|
||||
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]);
|
||||
let function = Function::new_with_env(
|
||||
&mut store,
|
||||
@@ -388,7 +388,7 @@ fn function_new_dynamic_env() -> Result<(), String> {
|
||||
&function_type,
|
||||
|_env: FunctionEnvMut<MyEnv>, _values: &[Value]| unimplemented!(),
|
||||
);
|
||||
assert_eq!(function.ty(&mut store).clone(), function_type);
|
||||
assert_eq!(function.ty(&mut store), function_type);
|
||||
|
||||
// Using array signature
|
||||
let function_type = ([Type::V128], [Type::I32, Type::F32, Type::F64]);
|
||||
|
||||
@@ -367,7 +367,7 @@ pub mod reference_types {
|
||||
let global: &Global = instance.exports.get_global("global")?;
|
||||
{
|
||||
let er = ExternRef::new(&mut store, 3usize);
|
||||
global.set(&mut store, Value::ExternRef(Some(er.clone())))?;
|
||||
global.set(&mut store, Value::ExternRef(Some(er)))?;
|
||||
}
|
||||
let get_from_global: TypedFunction<(), Option<ExternRef>> = instance
|
||||
.exports
|
||||
@@ -398,7 +398,7 @@ pub mod reference_types {
|
||||
|
||||
let er = ExternRef::new(&mut store, 3usize);
|
||||
|
||||
let result = pass_extern_ref.call(&mut store, Some(er.clone()));
|
||||
let result = pass_extern_ref.call(&mut store, Some(er));
|
||||
assert!(result.is_err());
|
||||
|
||||
Ok(())
|
||||
@@ -442,7 +442,7 @@ pub mod reference_types {
|
||||
let result = grow_table_with_ref.call(&mut store, Some(er1.clone()), 10_000)?;
|
||||
assert_eq!(result, -1);
|
||||
|
||||
let result = grow_table_with_ref.call(&mut store, Some(er1.clone()), 8)?;
|
||||
let result = grow_table_with_ref.call(&mut store, Some(er1), 8)?;
|
||||
assert_eq!(result, 2);
|
||||
|
||||
for i in 2..10 {
|
||||
@@ -454,7 +454,7 @@ pub mod reference_types {
|
||||
}
|
||||
|
||||
{
|
||||
fill_table_with_ref.call(&mut store, Some(er2.clone()), 0, 2)?;
|
||||
fill_table_with_ref.call(&mut store, Some(er2), 0, 2)?;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -462,7 +462,7 @@ pub mod reference_types {
|
||||
table2.set(&mut store, 1, Value::ExternRef(Some(er3.clone())))?;
|
||||
table2.set(&mut store, 2, Value::ExternRef(Some(er3.clone())))?;
|
||||
table2.set(&mut store, 3, Value::ExternRef(Some(er3.clone())))?;
|
||||
table2.set(&mut store, 4, Value::ExternRef(Some(er3.clone())))?;
|
||||
table2.set(&mut store, 4, Value::ExternRef(Some(er3)))?;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -357,7 +357,7 @@ impl VMMemory {
|
||||
///
|
||||
/// This creates a `Memory` with owned metadata: this can be used to create a memory
|
||||
/// that will be imported into Wasm modules.
|
||||
pub fn new(memory: &MemoryType, style: &MemoryStyle) -> Result<VMMemory, MemoryError> {
|
||||
pub fn new(memory: &MemoryType, style: &MemoryStyle) -> Result<Self, MemoryError> {
|
||||
Ok(Self(Box::new(VMOwnedMemory::new(memory, style)?)))
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ impl VMMemory {
|
||||
memory: &MemoryType,
|
||||
style: &MemoryStyle,
|
||||
vm_memory_location: NonNull<VMMemoryDefinition>,
|
||||
) -> Result<VMMemory, MemoryError> {
|
||||
) -> Result<Self, MemoryError> {
|
||||
Ok(Self(Box::new(VMOwnedMemory::from_definition(
|
||||
memory,
|
||||
style,
|
||||
@@ -384,9 +384,9 @@ impl VMMemory {
|
||||
/// are natively supported
|
||||
/// - VMOwnedMemory -> VMMemory
|
||||
/// - Box<dyn LinearMemory + 'static> -> VMMemory
|
||||
pub fn from_custom<IntoVMMemory>(memory: IntoVMMemory) -> VMMemory
|
||||
pub fn from_custom<IntoVMMemory>(memory: IntoVMMemory) -> Self
|
||||
where
|
||||
IntoVMMemory: Into<VMMemory>,
|
||||
IntoVMMemory: Into<Self>,
|
||||
{
|
||||
memory.into()
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ fn test_stdin() {
|
||||
// Let's call the `_start` function, which is our `main` function in Rust.
|
||||
let start = instance.exports.get_function("_start").unwrap();
|
||||
let result = start.call(&mut store, &[]);
|
||||
assert!(!result.is_err());
|
||||
assert!(result.is_ok());
|
||||
|
||||
// We assure stdin is now empty
|
||||
let mut buf = Vec::new();
|
||||
|
||||
@@ -277,7 +277,7 @@ fn create_obj(args: Vec<&'static str>, keyword_needle: &str, keyword: &str) -> a
|
||||
let object_path = operating_dir.join("wasm.obj");
|
||||
|
||||
let output: Vec<u8> = WasmerCreateObj {
|
||||
current_dir: operating_dir.clone(),
|
||||
current_dir: operating_dir,
|
||||
wasm_path,
|
||||
output_object_path: object_path.clone(),
|
||||
compiler: Compiler::Cranelift,
|
||||
@@ -292,7 +292,7 @@ fn create_obj(args: Vec<&'static str>, keyword_needle: &str, keyword: &str) -> a
|
||||
"create-obj successfully completed but object output file `{}` missing",
|
||||
object_path.display()
|
||||
);
|
||||
let mut object_header_path = object_path.clone();
|
||||
let mut object_header_path = object_path;
|
||||
object_header_path.set_extension("h");
|
||||
assert!(
|
||||
object_header_path.exists(),
|
||||
|
||||
@@ -40,9 +40,9 @@ mod tests {
|
||||
*/
|
||||
let command_success = command.status.success();
|
||||
let test_success = !stderr.contains("** TEST FAILED **");
|
||||
let success = command_success && test_success;
|
||||
|
||||
success
|
||||
|
||||
command_success && test_success
|
||||
}
|
||||
|
||||
fn remove_existing_artificats() -> Output {
|
||||
|
||||
@@ -143,7 +143,7 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
|
||||
#llvm_compiler_test
|
||||
}
|
||||
};
|
||||
x.into()
|
||||
x
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user