style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -191,8 +191,9 @@ impl RuntimeBlob {
|
||||
/// Consumes this runtime blob and serializes it.
|
||||
pub fn serialize(self) -> Vec<u8> {
|
||||
match self.0 {
|
||||
BlobKind::WebAssembly(raw_module) =>
|
||||
serialize(raw_module).expect("serializing into a vec should succeed; qed"),
|
||||
BlobKind::WebAssembly(raw_module) => {
|
||||
serialize(raw_module).expect("serializing into a vec should succeed; qed")
|
||||
},
|
||||
BlobKind::PolkaVM(ref blob) => blob.1.to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +45,12 @@ impl WasmInstance for Instance {
|
||||
) -> (Result<Vec<u8>, Error>, Option<AllocationStats>) {
|
||||
let pc = match self.0.module().exports().find(|e| e.symbol() == name) {
|
||||
Some(export) => export.program_counter(),
|
||||
None =>
|
||||
None => {
|
||||
return (
|
||||
Err(format!("cannot call into the runtime: export not found: '{name}'").into()),
|
||||
None,
|
||||
),
|
||||
)
|
||||
},
|
||||
};
|
||||
|
||||
let Ok(raw_data_length) = u32::try_from(raw_data.len()) else {
|
||||
@@ -93,21 +94,24 @@ impl WasmInstance for Instance {
|
||||
|
||||
match self.0.call_typed(&mut (), pc, (data_pointer, raw_data_length)) {
|
||||
Ok(()) => {},
|
||||
Err(CallError::Trap) =>
|
||||
Err(CallError::Trap) => {
|
||||
return (
|
||||
Err(format!("call into the runtime method '{name}' failed: trap").into()),
|
||||
None,
|
||||
),
|
||||
Err(CallError::Error(err)) =>
|
||||
)
|
||||
},
|
||||
Err(CallError::Error(err)) => {
|
||||
return (
|
||||
Err(format!("call into the runtime method '{name}' failed: {err}").into()),
|
||||
None,
|
||||
),
|
||||
Err(CallError::User(err)) =>
|
||||
)
|
||||
},
|
||||
Err(CallError::User(err)) => {
|
||||
return (
|
||||
Err(format!("call into the runtime method '{name}' failed: {err}").into()),
|
||||
None,
|
||||
),
|
||||
)
|
||||
},
|
||||
Err(CallError::NotEnoughGas) => unreachable!("gas metering is never enabled"),
|
||||
Err(CallError::Step) => unreachable!("stepping is never enabled"),
|
||||
};
|
||||
@@ -190,7 +194,7 @@ fn call_host_function(caller: &mut Caller<()>, function: &dyn Function) -> Resul
|
||||
args[nth_arg] = Value::F32(caller.instance.reg(Reg::ARG_REGS[nth_reg]) as u32);
|
||||
nth_reg += 1;
|
||||
},
|
||||
ValueType::I64 =>
|
||||
ValueType::I64 => {
|
||||
if caller.instance.is_64_bit() {
|
||||
args[nth_arg] = Value::I64(caller.instance.reg(Reg::ARG_REGS[nth_reg]) as i64);
|
||||
nth_reg += 1;
|
||||
@@ -203,8 +207,9 @@ fn call_host_function(caller: &mut Caller<()>, function: &dyn Function) -> Resul
|
||||
|
||||
args[nth_arg] =
|
||||
Value::I64((u64::from(value_lo) | (u64::from(value_hi) << 32)) as i64);
|
||||
},
|
||||
ValueType::F64 =>
|
||||
}
|
||||
},
|
||||
ValueType::F64 => {
|
||||
if caller.instance.is_64_bit() {
|
||||
args[nth_arg] = Value::F64(caller.instance.reg(Reg::ARG_REGS[nth_reg]));
|
||||
nth_reg += 1;
|
||||
@@ -216,7 +221,8 @@ fn call_host_function(caller: &mut Caller<()>, function: &dyn Function) -> Resul
|
||||
nth_reg += 1;
|
||||
|
||||
args[nth_arg] = Value::F64(u64::from(value_lo) | (u64::from(value_hi) << 32));
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,20 +250,22 @@ fn call_host_function(caller: &mut Caller<()>, function: &dyn Function) -> Resul
|
||||
Value::F32(value) => {
|
||||
caller.instance.set_reg(Reg::A0, value as u64);
|
||||
},
|
||||
Value::I64(value) =>
|
||||
Value::I64(value) => {
|
||||
if caller.instance.is_64_bit() {
|
||||
caller.instance.set_reg(Reg::A0, value as u64);
|
||||
} else {
|
||||
caller.instance.set_reg(Reg::A0, value as u64);
|
||||
caller.instance.set_reg(Reg::A1, (value >> 32) as u64);
|
||||
},
|
||||
Value::F64(value) =>
|
||||
}
|
||||
},
|
||||
Value::F64(value) => {
|
||||
if caller.instance.is_64_bit() {
|
||||
caller.instance.set_reg(Reg::A0, value as u64);
|
||||
} else {
|
||||
caller.instance.set_reg(Reg::A0, value as u64);
|
||||
caller.instance.set_reg(Reg::A1, (value >> 32) as u64);
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,9 @@ fn call_not_existing_function(wasm_method: WasmExecutionMethod) {
|
||||
match call_in_wasm("test_calling_missing_external", &[], wasm_method, &mut ext).unwrap_err() {
|
||||
Error::AbortedDueToTrap(error) => {
|
||||
let expected = match wasm_method {
|
||||
WasmExecutionMethod::Compiled { .. } =>
|
||||
"call to a missing function env:missing_external",
|
||||
WasmExecutionMethod::Compiled { .. } => {
|
||||
"call to a missing function env:missing_external"
|
||||
},
|
||||
};
|
||||
assert_eq!(error.message, expected);
|
||||
},
|
||||
@@ -138,8 +139,9 @@ fn call_yet_another_not_existing_function(wasm_method: WasmExecutionMethod) {
|
||||
{
|
||||
Error::AbortedDueToTrap(error) => {
|
||||
let expected = match wasm_method {
|
||||
WasmExecutionMethod::Compiled { .. } =>
|
||||
"call to a missing function env:yet_another_missing_external",
|
||||
WasmExecutionMethod::Compiled { .. } => {
|
||||
"call to a missing function env:yet_another_missing_external"
|
||||
},
|
||||
};
|
||||
assert_eq!(error.message, expected);
|
||||
},
|
||||
@@ -728,8 +730,9 @@ fn unreachable_intrinsic(wasm_method: WasmExecutionMethod) {
|
||||
match call_in_wasm("test_unreachable_intrinsic", &[], wasm_method, &mut ext).unwrap_err() {
|
||||
Error::AbortedDueToTrap(error) => {
|
||||
let expected = match wasm_method {
|
||||
WasmExecutionMethod::Compiled { .. } =>
|
||||
"wasm trap: wasm `unreachable` instruction executed",
|
||||
WasmExecutionMethod::Compiled { .. } => {
|
||||
"wasm trap: wasm `unreachable` instruction executed"
|
||||
},
|
||||
};
|
||||
assert_eq!(error.message, expected);
|
||||
},
|
||||
|
||||
@@ -303,7 +303,7 @@ where
|
||||
}
|
||||
|
||||
match wasm_method {
|
||||
WasmExecutionMethod::Compiled { instantiation_strategy } =>
|
||||
WasmExecutionMethod::Compiled { instantiation_strategy } => {
|
||||
pezsc_executor_wasmtime::create_runtime::<H>(
|
||||
blob,
|
||||
pezsc_executor_wasmtime::Config {
|
||||
@@ -322,7 +322,8 @@ where
|
||||
},
|
||||
},
|
||||
)
|
||||
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) }),
|
||||
.map(|runtime| -> Box<dyn WasmModule> { Box::new(runtime) })
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,12 +48,13 @@ where
|
||||
ExternType::Func(func_ty) => {
|
||||
pending_func_imports.insert(name.to_owned(), (import_ty, func_ty));
|
||||
},
|
||||
_ =>
|
||||
_ => {
|
||||
return Err(WasmError::Other(format!(
|
||||
"host doesn't provide any non function imports: {}:{}",
|
||||
import_ty.module(),
|
||||
name,
|
||||
))),
|
||||
)))
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -274,8 +274,9 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config,
|
||||
|
||||
config.memory_init_cow(use_cow);
|
||||
config.memory_guaranteed_dense_image_size(match semantics.heap_alloc_strategy {
|
||||
HeapAllocStrategy::Dynamic { maximum_pages } =>
|
||||
maximum_pages.map(|p| p as u64 * WASM_PAGE_SIZE).unwrap_or(u64::MAX),
|
||||
HeapAllocStrategy::Dynamic { maximum_pages } => {
|
||||
maximum_pages.map(|p| p as u64 * WASM_PAGE_SIZE).unwrap_or(u64::MAX)
|
||||
},
|
||||
HeapAllocStrategy::Static { .. } => u64::MAX,
|
||||
});
|
||||
|
||||
@@ -283,8 +284,9 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config,
|
||||
const MAX_WASM_PAGES: u64 = 0x10000;
|
||||
|
||||
let memory_pages = match semantics.heap_alloc_strategy {
|
||||
HeapAllocStrategy::Dynamic { maximum_pages } =>
|
||||
maximum_pages.map(|p| p as u64).unwrap_or(MAX_WASM_PAGES),
|
||||
HeapAllocStrategy::Dynamic { maximum_pages } => {
|
||||
maximum_pages.map(|p| p as u64).unwrap_or(MAX_WASM_PAGES)
|
||||
},
|
||||
HeapAllocStrategy::Static { .. } => MAX_WASM_PAGES,
|
||||
};
|
||||
|
||||
@@ -579,11 +581,12 @@ where
|
||||
.map_err(|e| WasmError::Other(format!("cannot create module: {:#}", e)))?;
|
||||
|
||||
match config.semantics.instantiation_strategy {
|
||||
InstantiationStrategy::Pooling |
|
||||
InstantiationStrategy::PoolingCopyOnWrite |
|
||||
InstantiationStrategy::RecreateInstance |
|
||||
InstantiationStrategy::RecreateInstanceCopyOnWrite =>
|
||||
(module, InternalInstantiationStrategy::Builtin),
|
||||
InstantiationStrategy::Pooling
|
||||
| InstantiationStrategy::PoolingCopyOnWrite
|
||||
| InstantiationStrategy::RecreateInstance
|
||||
| InstantiationStrategy::RecreateInstanceCopyOnWrite => {
|
||||
(module, InternalInstantiationStrategy::Builtin)
|
||||
},
|
||||
}
|
||||
},
|
||||
CodeSupplyMode::Precompiled(compiled_artifact_path) => {
|
||||
|
||||
@@ -116,8 +116,9 @@ pub(crate) fn replace_strategy_if_broken(strategy: &mut InstantiationStrategy) {
|
||||
|
||||
// These strategies require a working `madvise` to be sound.
|
||||
InstantiationStrategy::PoolingCopyOnWrite => InstantiationStrategy::Pooling,
|
||||
InstantiationStrategy::RecreateInstanceCopyOnWrite =>
|
||||
InstantiationStrategy::RecreateInstance,
|
||||
InstantiationStrategy::RecreateInstanceCopyOnWrite => {
|
||||
InstantiationStrategy::RecreateInstance
|
||||
},
|
||||
};
|
||||
|
||||
use std::sync::OnceLock;
|
||||
|
||||
Reference in New Issue
Block a user