mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 05:18:43 +00:00
Make "make lint" pass for Rust 1.63
This commit is contained in:
@@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http")]
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fmt::Write as _;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
@@ -912,7 +913,8 @@ impl CreateExe {
|
|||||||
for atom_name in atom_names.iter() {
|
for atom_name in atom_names.iter() {
|
||||||
let atom_name = Self::normalize_atom_name(atom_name);
|
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}\");
|
wasm_module_t *atom_{atom_name} = wasmer_object_module_new(store, \"{atom_name}\");
|
||||||
@@ -923,11 +925,16 @@ impl CreateExe {
|
|||||||
return -1;
|
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
|
WASMER_STATIC_MAIN_C_SOURCE
|
||||||
.replace("#define WASI", "#define WASI\r\n#define WASI_PIRITA")
|
.replace("#define WASI", "#define WASI\r\n#define WASI_PIRITA")
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ impl List {
|
|||||||
if empty_table {
|
if empty_table {
|
||||||
table.add_empty_row();
|
table.add_empty_row();
|
||||||
}
|
}
|
||||||
let _ = table.printstd();
|
table.printstd();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ impl ControlStackFrame {
|
|||||||
/// Pop values from the value stack so that it is left at the
|
/// Pop values from the value stack so that it is left at the
|
||||||
/// input-parameters to an else-block.
|
/// input-parameters to an else-block.
|
||||||
pub fn truncate_value_stack_to_else_params(&self, stack: &mut Vec<Value>) {
|
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());
|
stack.truncate(self.original_stack_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ impl ControlStackFrame {
|
|||||||
// block can see the same number of parameters as the consequent block. As a matter of
|
// 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.
|
// fact, we need to substract an extra number of parameter values for if blocks.
|
||||||
let num_duplicated_params = match self {
|
let num_duplicated_params = match self {
|
||||||
&ControlStackFrame::If {
|
&Self::If {
|
||||||
num_param_values, ..
|
num_param_values, ..
|
||||||
} => {
|
} => {
|
||||||
debug_assert!(num_param_values <= self.original_stack_size());
|
debug_assert!(num_param_values <= self.original_stack_size());
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub static GLOBAL_CONFIG_FILE_NAME: &str = if cfg!(target_os = "wasi") {
|
|||||||
"wapm.toml"
|
"wapm.toml"
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Serialize, Debug, PartialEq)]
|
#[derive(Deserialize, Default, Serialize, Debug, PartialEq, Eq)]
|
||||||
pub struct PartialWapmConfig {
|
pub struct PartialWapmConfig {
|
||||||
/// The number of seconds to wait before checking the registry for a new
|
/// The number of seconds to wait before checking the registry for a new
|
||||||
/// version of the package.
|
/// version of the package.
|
||||||
@@ -41,12 +41,12 @@ pub const fn wax_default_cooldown() -> i32 {
|
|||||||
5 * 60
|
5 * 60
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, PartialEq, Default)]
|
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Default)]
|
||||||
pub struct Proxy {
|
pub struct Proxy {
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, PartialEq, Default)]
|
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Default)]
|
||||||
pub struct UpdateNotifications {
|
pub struct UpdateNotifications {
|
||||||
pub enabled: String,
|
pub enabled: String,
|
||||||
}
|
}
|
||||||
@@ -57,14 +57,14 @@ pub struct Telemetry {
|
|||||||
pub enabled: String,
|
pub enabled: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
|
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Registries {
|
pub enum Registries {
|
||||||
Single(Registry),
|
Single(Registry),
|
||||||
Multi(MultiRegistry),
|
Multi(MultiRegistry),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
|
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct MultiRegistry {
|
pub struct MultiRegistry {
|
||||||
/// Currently active registry
|
/// Currently active registry
|
||||||
pub current: String,
|
pub current: String,
|
||||||
@@ -82,7 +82,7 @@ impl Default for Registries {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
|
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct Registry {
|
pub struct Registry {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub token: Option<String>,
|
pub token: Option<String>,
|
||||||
@@ -278,7 +278,7 @@ impl PartialWapmConfig {
|
|||||||
pub fn get_folder(test_name: &str) -> Result<PathBuf, String> {
|
pub fn get_folder(test_name: &str) -> Result<PathBuf, String> {
|
||||||
let test_dir = std::env::temp_dir().join("test_wasmer").join(test_name);
|
let test_dir = std::env::temp_dir().join("test_wasmer").join(test_name);
|
||||||
let _ = std::fs::create_dir_all(&test_dir);
|
let _ = std::fs::create_dir_all(&test_dir);
|
||||||
Ok(test_dir.to_path_buf())
|
Ok(test_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ pub fn query_command_from_registry(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
||||||
pub enum QueryPackageError {
|
pub enum QueryPackageError {
|
||||||
ErrorSendingQuery(String),
|
ErrorSendingQuery(String),
|
||||||
NoPackageFound {
|
NoPackageFound {
|
||||||
@@ -329,7 +329,7 @@ impl fmt::Display for QueryPackageError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, PartialOrd)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
|
||||||
pub enum GetIfPackageHasNewVersionResult {
|
pub enum GetIfPackageHasNewVersionResult {
|
||||||
// if version = Some(...) and the ~/.wasmer/checkouts/.../{version} exists, the package is already installed
|
// if version = Some(...) and the ~/.wasmer/checkouts/.../{version} exists, the package is already installed
|
||||||
UseLocalAlreadyInstalled {
|
UseLocalAlreadyInstalled {
|
||||||
@@ -860,7 +860,7 @@ pub fn test_if_registry_present(registry: &str) -> Result<bool, String> {
|
|||||||
use graphql_client::GraphQLQuery;
|
use graphql_client::GraphQLQuery;
|
||||||
|
|
||||||
let q = TestIfRegistryPresent::build_query(test_if_registry_present::Variables {});
|
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,
|
registry,
|
||||||
"",
|
"",
|
||||||
&q,
|
&q,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ where
|
|||||||
pub memory: Arc<MemFileSystem>,
|
pub memory: Arc<MemFileSystem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> WebcFileSystem<T>
|
impl<T> WebcFileSystem<T>
|
||||||
where
|
where
|
||||||
T: std::fmt::Debug + Send + Sync + 'static,
|
T: std::fmt::Debug + Send + Sync + 'static,
|
||||||
T: Deref<Target = WebC<'static>>,
|
T: Deref<Target = WebC<'static>>,
|
||||||
@@ -54,7 +54,7 @@ where
|
|||||||
pub memory: Arc<MemFileSystem>,
|
pub memory: Arc<MemFileSystem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> FileOpener for WebCFileOpener<T>
|
impl<T> FileOpener for WebCFileOpener<T>
|
||||||
where
|
where
|
||||||
T: std::fmt::Debug + Send + Sync + 'static,
|
T: std::fmt::Debug + Send + Sync + 'static,
|
||||||
T: Deref<Target = WebC<'static>>,
|
T: Deref<Target = WebC<'static>>,
|
||||||
|
|||||||
@@ -261,8 +261,8 @@ impl<T> MaybeInstanceOwned<T> {
|
|||||||
/// Returns underlying pointer to the VM data.
|
/// Returns underlying pointer to the VM data.
|
||||||
pub fn as_ptr(&self) -> NonNull<T> {
|
pub fn as_ptr(&self) -> NonNull<T> {
|
||||||
match self {
|
match self {
|
||||||
MaybeInstanceOwned::Host(p) => unsafe { NonNull::new_unchecked(p.get()) },
|
Self::Host(p) => unsafe { NonNull::new_unchecked(p.get()) },
|
||||||
MaybeInstanceOwned::Instance(p) => *p,
|
Self::Instance(p) => *p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,12 +273,12 @@ where
|
|||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
MaybeInstanceOwned::Host(p) => {
|
Self::Host(p) => {
|
||||||
write!(f, "host(")?;
|
write!(f, "host(")?;
|
||||||
p.as_ref().fmt(f)?;
|
p.as_ref().fmt(f)?;
|
||||||
write!(f, ")")
|
write!(f, ")")
|
||||||
}
|
}
|
||||||
MaybeInstanceOwned::Instance(p) => {
|
Self::Instance(p) => {
|
||||||
write!(f, "instance(")?;
|
write!(f, "instance(")?;
|
||||||
unsafe { p.as_ref().fmt(f)? };
|
unsafe { p.as_ref().fmt(f)? };
|
||||||
write!(f, ")")
|
write!(f, ")")
|
||||||
|
|||||||
@@ -829,14 +829,14 @@ enum UnwindReason {
|
|||||||
impl UnwindReason {
|
impl UnwindReason {
|
||||||
fn into_trap(self) -> Trap {
|
fn into_trap(self) -> Trap {
|
||||||
match self {
|
match self {
|
||||||
UnwindReason::UserTrap(data) => Trap::User(data),
|
Self::UserTrap(data) => Trap::User(data),
|
||||||
UnwindReason::LibTrap(trap) => trap,
|
Self::LibTrap(trap) => trap,
|
||||||
UnwindReason::WasmTrap {
|
Self::WasmTrap {
|
||||||
backtrace,
|
backtrace,
|
||||||
pc,
|
pc,
|
||||||
signal_trap,
|
signal_trap,
|
||||||
} => Trap::wasm(pc, backtrace, signal_trap),
|
} => Trap::wasm(pc, backtrace, signal_trap),
|
||||||
UnwindReason::Panic(panic) => std::panic::resume_unwind(panic),
|
Self::Panic(panic) => std::panic::resume_unwind(panic),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 types;
|
||||||
pub mod wasi;
|
pub mod wasi;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#![deny(unused_mut)]
|
#![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)]
|
#![allow(non_camel_case_types, clippy::identity_op)]
|
||||||
|
|
||||||
//! Wasmer's WASI types implementation.
|
//! Wasmer's WASI types implementation.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
|||||||
use wasmer::{CompilerConfig, Features, ModuleMiddleware, Store};
|
use wasmer::{CompilerConfig, Features, ModuleMiddleware, Store};
|
||||||
use wasmer_compiler::Engine;
|
use wasmer_compiler::Engine;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum Compiler {
|
pub enum Compiler {
|
||||||
LLVM,
|
LLVM,
|
||||||
Cranelift,
|
Cranelift,
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ fn test_trap_return(config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let e = run_func
|
let e = run_func
|
||||||
.call(&mut store, &[])
|
.call(&mut store, &[])
|
||||||
.err()
|
.expect_err("error calling function");
|
||||||
.expect("error calling function");
|
|
||||||
|
|
||||||
assert_eq!(e.message(), "test 123");
|
assert_eq!(e.message(), "test 123");
|
||||||
|
|
||||||
@@ -62,8 +61,7 @@ fn test_trap_trace(config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let e = run_func
|
let e = run_func
|
||||||
.call(&mut store, &[])
|
.call(&mut store, &[])
|
||||||
.err()
|
.expect_err("error calling function");
|
||||||
.expect("error calling function");
|
|
||||||
|
|
||||||
let trace = e.trace();
|
let trace = e.trace();
|
||||||
assert_eq!(trace.len(), 2);
|
assert_eq!(trace.len(), 2);
|
||||||
@@ -113,8 +111,7 @@ fn test_trap_trace_cb(config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let e = run_func
|
let e = run_func
|
||||||
.call(&mut store, &[])
|
.call(&mut store, &[])
|
||||||
.err()
|
.expect_err("error calling function");
|
||||||
.expect("error calling function");
|
|
||||||
|
|
||||||
let trace = e.trace();
|
let trace = e.trace();
|
||||||
println!("Trace {:?}", trace);
|
println!("Trace {:?}", trace);
|
||||||
@@ -148,8 +145,7 @@ fn test_trap_stack_overflow(config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let e = run_func
|
let e = run_func
|
||||||
.call(&mut store, &[])
|
.call(&mut store, &[])
|
||||||
.err()
|
.expect_err("error calling function");
|
||||||
.expect("error calling function");
|
|
||||||
|
|
||||||
// We specifically don't check the stack trace here: stack traces after
|
// We specifically don't check the stack trace here: stack traces after
|
||||||
// stack overflows are not generally possible due to unreliable unwinding
|
// stack overflows are not generally possible due to unreliable unwinding
|
||||||
@@ -181,8 +177,7 @@ fn trap_display_pretty(config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let e = run_func
|
let e = run_func
|
||||||
.call(&mut store, &[])
|
.call(&mut store, &[])
|
||||||
.err()
|
.expect_err("error calling function");
|
||||||
.expect("error calling function");
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
e.to_string(),
|
e.to_string(),
|
||||||
"\
|
"\
|
||||||
@@ -236,8 +231,7 @@ fn trap_display_multi_module(config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let e = bar2
|
let e = bar2
|
||||||
.call(&mut store, &[])
|
.call(&mut store, &[])
|
||||||
.err()
|
.expect_err("error calling function");
|
||||||
.expect("error calling function");
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
e.to_string(),
|
e.to_string(),
|
||||||
"\
|
"\
|
||||||
@@ -433,9 +427,7 @@ fn call_signature_mismatch(config: crate::Config) -> Result<()> {
|
|||||||
"#;
|
"#;
|
||||||
|
|
||||||
let module = Module::new(&store, &binary)?;
|
let module = Module::new(&store, &binary)?;
|
||||||
let err = Instance::new(&mut store, &module, &imports! {})
|
let err = Instance::new(&mut store, &module, &imports! {}).expect_err("expected error");
|
||||||
.err()
|
|
||||||
.expect("expected error");
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", err),
|
format!("{}", err),
|
||||||
"\
|
"\
|
||||||
@@ -461,9 +453,7 @@ fn start_trap_pretty(config: crate::Config) -> Result<()> {
|
|||||||
"#;
|
"#;
|
||||||
|
|
||||||
let module = Module::new(&store, wat)?;
|
let module = Module::new(&store, wat)?;
|
||||||
let err = Instance::new(&mut store, &module, &imports! {})
|
let err = Instance::new(&mut store, &module, &imports! {}).expect_err("expected error");
|
||||||
.err()
|
|
||||||
.expect("expected error");
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", err),
|
format!("{}", err),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(clippy::unnecessary_operation)] // We use x1 multiplies for clarity
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|||||||
Reference in New Issue
Block a user