Skip to content

Commit

Permalink
Make "make lint" pass for Rust 1.63
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed Nov 17, 2022
1 parent 75d5af2 commit e3ea8b4
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 47 deletions.
15 changes: 11 additions & 4 deletions lib/cli/src/commands/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "http")]
use std::collections::BTreeMap;
use std::env;
use std::fmt::Write as _;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
Expand Down Expand Up @@ -912,7 +913,8 @@ impl CreateExe {
for atom_name in atom_names.iter() {
let atom_name = Self::normalize_atom_name(atom_name);

c_code_to_instantiate.push_str(&format!(
write!(
c_code_to_instantiate,
"
wasm_module_t *atom_{atom_name} = wasmer_object_module_new(store, \"{atom_name}\");
Expand All @@ -923,11 +925,16 @@ impl CreateExe {
return -1;
}}
"
));
deallocate_module.push_str(&format!("wasm_module_delete(atom_{atom_name});"));
)
.unwrap();
write!(deallocate_module, "wasm_module_delete(atom_{atom_name});").unwrap();
}

c_code_to_instantiate.push_str(&format!("wasm_module_t *module = atom_{atom_to_run};"));
write!(
c_code_to_instantiate,
"wasm_module_t *module = atom_{atom_to_run};"
)
.unwrap();

WASMER_STATIC_MAIN_C_SOURCE
.replace("#define WASI", "#define WASI\r\n#define WASI_PIRITA")
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl List {
if empty_table {
table.add_empty_row();
}
let _ = table.printstd();
table.printstd();

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler-cranelift/src/translator/func_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl ControlStackFrame {
/// Pop values from the value stack so that it is left at the
/// input-parameters to an else-block.
pub fn truncate_value_stack_to_else_params(&self, stack: &mut Vec<Value>) {
debug_assert!(matches!(self, &ControlStackFrame::If { .. }));
debug_assert!(matches!(self, &Self::If { .. }));
stack.truncate(self.original_stack_size());
}

Expand All @@ -202,7 +202,7 @@ impl ControlStackFrame {
// block can see the same number of parameters as the consequent block. As a matter of
// fact, we need to substract an extra number of parameter values for if blocks.
let num_duplicated_params = match self {
&ControlStackFrame::If {
&Self::If {
num_param_values, ..
} => {
debug_assert!(num_param_values <= self.original_stack_size());
Expand Down
6 changes: 3 additions & 3 deletions lib/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub fn query_command_from_registry(
})
}

#[derive(Debug, Clone, PartialEq, PartialOrd)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
pub enum QueryPackageError {
ErrorSendingQuery(String),
NoPackageFound {
Expand All @@ -329,7 +329,7 @@ impl fmt::Display for QueryPackageError {
}
}

#[derive(Debug, Clone, PartialEq, PartialOrd)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
pub enum GetIfPackageHasNewVersionResult {
// if version = Some(...) and the ~/.wasmer/checkouts/.../{version} exists, the package is already installed
UseLocalAlreadyInstalled {
Expand Down Expand Up @@ -860,7 +860,7 @@ pub fn test_if_registry_present(registry: &str) -> Result<bool, String> {
use graphql_client::GraphQLQuery;

let q = TestIfRegistryPresent::build_query(test_if_registry_present::Variables {});
let _ = crate::graphql::execute_query_modifier_inner_check_json(
crate::graphql::execute_query_modifier_inner_check_json(
registry,
"",
&q,
Expand Down
4 changes: 2 additions & 2 deletions lib/vfs/src/webc_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ where
pub memory: Arc<MemFileSystem>,
}

impl<'a, T> WebcFileSystem<T>
impl<T> WebcFileSystem<T>
where
T: std::fmt::Debug + Send + Sync + 'static,
T: Deref<Target = WebC<'static>>,
Expand Down Expand Up @@ -54,7 +54,7 @@ where
pub memory: Arc<MemFileSystem>,
}

impl<'a, T> FileOpener for WebCFileOpener<T>
impl<T> FileOpener for WebCFileOpener<T>
where
T: std::fmt::Debug + Send + Sync + 'static,
T: Deref<Target = WebC<'static>>,
Expand Down
8 changes: 4 additions & 4 deletions lib/vm/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ impl<T> MaybeInstanceOwned<T> {
/// Returns underlying pointer to the VM data.
pub fn as_ptr(&self) -> NonNull<T> {
match self {
MaybeInstanceOwned::Host(p) => unsafe { NonNull::new_unchecked(p.get()) },
MaybeInstanceOwned::Instance(p) => *p,
Self::Host(p) => unsafe { NonNull::new_unchecked(p.get()) },
Self::Instance(p) => *p,
}
}
}
Expand All @@ -273,12 +273,12 @@ where
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
MaybeInstanceOwned::Host(p) => {
Self::Host(p) => {
write!(f, "host(")?;
p.as_ref().fmt(f)?;
write!(f, ")")
}
MaybeInstanceOwned::Instance(p) => {
Self::Instance(p) => {
write!(f, "instance(")?;
unsafe { p.as_ref().fmt(f)? };
write!(f, ")")
Expand Down
8 changes: 4 additions & 4 deletions lib/vm/src/trap/traphandlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,14 +829,14 @@ enum UnwindReason {
impl UnwindReason {
fn into_trap(self) -> Trap {
match self {
UnwindReason::UserTrap(data) => Trap::User(data),
UnwindReason::LibTrap(trap) => trap,
UnwindReason::WasmTrap {
Self::UserTrap(data) => Trap::User(data),
Self::LibTrap(trap) => trap,
Self::WasmTrap {
backtrace,
pc,
signal_trap,
} => Trap::wasm(pc, backtrace, signal_trap),
UnwindReason::Panic(panic) => std::panic::resume_unwind(panic),
Self::Panic(panic) => std::panic::resume_unwind(panic),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/wasi-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![doc(html_favicon_url = "https://wasmer.io/images/icons/favicon-32x32.png")]
#![doc(html_logo_url = "https://github.com/wasmerio.png?size=200")]

pub mod types;
pub mod wasi;

Expand Down
2 changes: 0 additions & 2 deletions lib/wasi-types/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![deny(unused_mut)]
#![doc(html_favicon_url = "https://wasmer.io/images/icons/favicon-32x32.png")]
#![doc(html_logo_url = "https://github.com/wasmerio.png?size=200")]
#![allow(non_camel_case_types, clippy::identity_op)]

//! Wasmer's WASI types implementation.
Expand Down
2 changes: 1 addition & 1 deletion tests/compilers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;
use wasmer::{CompilerConfig, Features, ModuleMiddleware, Store};
use wasmer_compiler::Engine;

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Compiler {
LLVM,
Cranelift,
Expand Down
26 changes: 8 additions & 18 deletions tests/compilers/traps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ fn test_trap_return(config: crate::Config) -> Result<()> {

let e = run_func
.call(&mut store, &[])
.err()
.expect("error calling function");
.expect_err("error calling function");

assert_eq!(e.message(), "test 123");

Expand All @@ -62,8 +61,7 @@ fn test_trap_trace(config: crate::Config) -> Result<()> {

let e = run_func
.call(&mut store, &[])
.err()
.expect("error calling function");
.expect_err("error calling function");

let trace = e.trace();
assert_eq!(trace.len(), 2);
Expand Down Expand Up @@ -113,8 +111,7 @@ fn test_trap_trace_cb(config: crate::Config) -> Result<()> {

let e = run_func
.call(&mut store, &[])
.err()
.expect("error calling function");
.expect_err("error calling function");

let trace = e.trace();
println!("Trace {:?}", trace);
Expand Down Expand Up @@ -148,8 +145,7 @@ fn test_trap_stack_overflow(config: crate::Config) -> Result<()> {

let e = run_func
.call(&mut store, &[])
.err()
.expect("error calling function");
.expect_err("error calling function");

// We specifically don't check the stack trace here: stack traces after
// stack overflows are not generally possible due to unreliable unwinding
Expand Down Expand Up @@ -181,8 +177,7 @@ fn trap_display_pretty(config: crate::Config) -> Result<()> {

let e = run_func
.call(&mut store, &[])
.err()
.expect("error calling function");
.expect_err("error calling function");
assert_eq!(
e.to_string(),
"\
Expand Down Expand Up @@ -236,8 +231,7 @@ fn trap_display_multi_module(config: crate::Config) -> Result<()> {

let e = bar2
.call(&mut store, &[])
.err()
.expect("error calling function");
.expect_err("error calling function");
assert_eq!(
e.to_string(),
"\
Expand Down Expand Up @@ -433,9 +427,7 @@ fn call_signature_mismatch(config: crate::Config) -> Result<()> {
"#;

let module = Module::new(&store, &binary)?;
let err = Instance::new(&mut store, &module, &imports! {})
.err()
.expect("expected error");
let err = Instance::new(&mut store, &module, &imports! {}).expect_err("expected error");
assert_eq!(
format!("{}", err),
"\
Expand All @@ -461,9 +453,7 @@ fn start_trap_pretty(config: crate::Config) -> Result<()> {
"#;

let module = Module::new(&store, wat)?;
let err = Instance::new(&mut store, &module, &imports! {})
.err()
.expect("expected error");
let err = Instance::new(&mut store, &module, &imports! {}).expect_err("expected error");

assert_eq!(
format!("{}", err),
Expand Down
12 changes: 6 additions & 6 deletions tests/compilers/typed_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ fn static_host_function_without_env(config: crate::Config) -> anyhow::Result<()>
let mut store = config.store();

fn f(a: i32, b: i64, c: f32, d: f64) -> (f64, f32, i64, i32) {
(d * 4.0, c * 3.0, b * 2, a * 1)
(d * 4.0, c * 3.0, b * 2, a)
}

fn f_ok(a: i32, b: i64, c: f32, d: f64) -> Result<(f64, f32, i64, i32), Infallible> {
Ok((d * 4.0, c * 3.0, b * 2, a * 1))
Ok((d * 4.0, c * 3.0, b * 2, a))
}

fn long_f(
Expand Down Expand Up @@ -311,7 +311,7 @@ fn static_host_function_with_env(config: crate::Config) -> anyhow::Result<()> {
assert_eq!(*guard, 100);
*guard = 101;

(d * 4.0, c * 3.0, b * 2, a * 1)
(d * 4.0, c * 3.0, b * 2, a)
}

fn f_ok(
Expand All @@ -325,7 +325,7 @@ fn static_host_function_with_env(config: crate::Config) -> anyhow::Result<()> {
assert_eq!(*guard, 100);
*guard = 101;

Ok((d * 4.0, c * 3.0, b * 2, a * 1))
Ok((d * 4.0, c * 3.0, b * 2, a))
}

#[derive(Clone)]
Expand Down Expand Up @@ -399,7 +399,7 @@ fn dynamic_host_function_without_env(config: crate::Config) -> anyhow::Result<()
Value::F64(values[3].unwrap_f64() * 4.0),
Value::F32(values[2].unwrap_f32() * 3.0),
Value::I64(values[1].unwrap_i64() * 2),
Value::I32(values[0].unwrap_i32() * 1),
Value::I32(values[0].unwrap_i32()),
])
},
);
Expand Down Expand Up @@ -455,7 +455,7 @@ fn dynamic_host_function_with_env(config: crate::Config) -> anyhow::Result<()> {
Value::F64(values[3].unwrap_f64() * 4.0),
Value::F32(values[2].unwrap_f32() * 3.0),
Value::I64(values[1].unwrap_i64() * 2),
Value::I32(values[0].unwrap_i32() * 1),
Value::I32(values[0].unwrap_i32()),
])
},
);
Expand Down

0 comments on commit e3ea8b4

Please sign in to comment.