From c89f74f7e8a4fd76e18dd12b5f8660f3378af662 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Fri, 7 Jan 2022 23:53:06 +0000 Subject: [PATCH] Wasm: clippy fixes --- compiler/gen_wasm/src/wasm_module/linking.rs | 2 +- compiler/gen_wasm/src/wasm_module/sections.rs | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/compiler/gen_wasm/src/wasm_module/linking.rs b/compiler/gen_wasm/src/wasm_module/linking.rs index 4e14b12f1e..048ede0418 100644 --- a/compiler/gen_wasm/src/wasm_module/linking.rs +++ b/compiler/gen_wasm/src/wasm_module/linking.rs @@ -430,7 +430,7 @@ enum SubSectionId { SymbolTable = 8, } -fn serialize_subsection<'a, I: Serialize, T: SerialBuffer>( +fn serialize_subsection( buffer: &mut T, id: SubSectionId, items: &[I], diff --git a/compiler/gen_wasm/src/wasm_module/sections.rs b/compiler/gen_wasm/src/wasm_module/sections.rs index bc8b5dc363..b418a659eb 100644 --- a/compiler/gen_wasm/src/wasm_module/sections.rs +++ b/compiler/gen_wasm/src/wasm_module/sections.rs @@ -629,7 +629,7 @@ impl SectionCounter { /// A Wasm module section that we don't use for Roc code, /// but may be present in a preloaded binary -#[derive(Debug)] +#[derive(Debug, Default)] pub struct OpaqueSection<'a> { bytes: &'a [u8], } @@ -640,16 +640,10 @@ impl<'a> OpaqueSection<'a> { } } -impl<'a> Default for OpaqueSection<'a> { - fn default() -> Self { - Self { bytes: &[] } - } -} - impl Serialize for OpaqueSection<'_> { fn serialize(&self, buffer: &mut T) { if !self.bytes.is_empty() { - buffer.append_slice(&self.bytes); + buffer.append_slice(self.bytes); } } } @@ -682,7 +676,6 @@ impl<'a> WasmModule<'a> { /// Serialize the module to bytes /// (Mutates some data related to linking) - #[allow(clippy::unit_arg)] pub fn serialize_mut(&mut self, buffer: &mut T) { buffer.append_u8(0); buffer.append_slice("asm".as_bytes());