From 63d82b06e9924f17b4f871220db990de012f55ca Mon Sep 17 00:00:00 2001 From: Phil Cummins Date: Wed, 4 Dec 2024 10:00:25 +0100 Subject: [PATCH 1/5] test --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1095c03..2b32a8f 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ hello = Root(store) print(f"component says: {hello.hello(store)}") EOF ``` +test_change And finally run it: From f261eba150a047ee06ab9da1c0835d6b22341fba Mon Sep 17 00:00:00 2001 From: Phil Cummins Date: Wed, 4 Dec 2024 10:01:55 +0100 Subject: [PATCH 2/5] trigger test workflow --- .github/workflows/test.yaml | 1 - README.md | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2c9767d..1c12fb0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,7 +4,6 @@ on: branches: [main] paths-ignore: - "examples/**" - - "README.md" - "CONTRIBUTING.md" workflow_dispatch: diff --git a/README.md b/README.md index 2b32a8f..1095c03 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,6 @@ hello = Root(store) print(f"component says: {hello.hello(store)}") EOF ``` -test_change And finally run it: From f873520ae8ef163c54afc982a4cc189f13ec53da Mon Sep 17 00:00:00 2001 From: Phil Cummins Date: Wed, 4 Dec 2024 10:27:51 +0100 Subject: [PATCH 3/5] remove lint from workflow --- .github/workflows/test.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1c12fb0..0b57e8a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -127,10 +127,6 @@ jobs: key: cpython-wasi enableCrossOsArchive: true - - name: Lint - shell: bash - run: bash .github/workflows/lint.sh - - uses: taiki-e/install-action@v2 with: tool: wasmtime-cli From 9e1b30bc6592dfa300810807f6035cf78b1f0dfa Mon Sep 17 00:00:00 2001 From: Phil Cummins Date: Wed, 4 Dec 2024 11:57:01 +0100 Subject: [PATCH 4/5] lint/compiler fixes --- .github/workflows/test.yaml | 4 ++++ src/stubwasi.rs | 33 ++++++++++++++++++--------------- src/summary.rs | 2 +- src/test/tests.rs | 2 ++ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0b57e8a..1c12fb0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -127,6 +127,10 @@ jobs: key: cpython-wasi enableCrossOsArchive: true + - name: Lint + shell: bash + run: bash .github/workflows/lint.sh + - uses: taiki-e/install-action@v2 with: tool: wasmtime-cli 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}, From 5967b1447d16d8c2d9e3b305c98afedfdb14a586 Mon Sep 17 00:00:00 2001 From: Phil Cummins Date: Wed, 4 Dec 2024 12:09:39 +0100 Subject: [PATCH 5/5] re-adds readme --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1c12fb0..2c9767d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,6 +4,7 @@ on: branches: [main] paths-ignore: - "examples/**" + - "README.md" - "CONTRIBUTING.md" workflow_dispatch: