From 00417611f8e4921894676a0d4ace5a6086cd2291 Mon Sep 17 00:00:00 2001 From: philrhc <140902392+philrhc@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:51:11 +0100 Subject: [PATCH] nightly compiler/lint fixes (#129) * test * trigger test workflow * remove lint from workflow * lint/compiler fixes * re-adds readme --------- Co-authored-by: Phil Cummins --- src/stubwasi.rs | 33 ++++++++++++++++++--------------- src/summary.rs | 2 +- src/test/tests.rs | 2 ++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/stubwasi.rs b/src/stubwasi.rs index 5305bad..4b3e620 100644 --- a/src/stubwasi.rs +++ b/src/stubwasi.rs @@ -10,9 +10,9 @@ use wasmparser::{FuncType, Parser, Payload, TypeRef}; use crate::Library; -pub fn link_stub_modules( - libraries: Vec, -) -> Result, impl Fn(u32) -> u32)>, Error> { +type LinkedStubModules = Option<(Vec, Box u32>)>; + +pub fn link_stub_modules(libraries: Vec) -> Result { let mut wasi_imports = HashMap::new(); let mut linker = wit_component::Linker::default() .validate(true) @@ -47,18 +47,21 @@ pub fn link_stub_modules( let new_adapter_count = u32::try_from(wasi_imports.len())?; assert!(new_adapter_count >= old_adapter_count); - Ok(Some((component, move |index: u32| { - if index == 0 { - // `main` module - 0 - } else if index <= new_adapter_count { - // adapter module - old_adapter_count - } else { - // one of the other kinds of module - index + old_adapter_count - new_adapter_count - } - }))) + Ok(Some(( + component, + Box::new(move |index: u32| { + if index == 0 { + // `main` module + 0 + } else if index <= new_adapter_count { + // adapter module + old_adapter_count + } else { + // one of the other kinds of module + index + old_adapter_count - new_adapter_count + } + }), + ))) } fn add_wasi_imports<'a>( diff --git a/src/summary.rs b/src/summary.rs index 5b6d4e4..71162da 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -88,7 +88,7 @@ pub struct MyFunction<'a> { pub wit_kind: wit_parser::FunctionKind, } -impl<'a> MyFunction<'a> { +impl MyFunction<'_> { fn key(&self) -> WorldKey { if let Some(interface) = self.interface.as_ref() { WorldKey::Interface(interface.id) diff --git a/src/test/tests.rs b/src/test/tests.rs index d647ccc..9b2c9da 100644 --- a/src/test/tests.rs +++ b/src/test/tests.rs @@ -1,3 +1,5 @@ +#![allow(non_local_definitions)] + use { super::{Ctx, Tester, SEED}, anyhow::{anyhow, Error, Result},