Skip to content

Commit

Permalink
nightly compiler/lint fixes (#129)
Browse files Browse the repository at this point in the history
* test

* trigger test workflow

* remove lint from workflow

* lint/compiler fixes

* re-adds readme

---------

Co-authored-by: Phil Cummins <[email protected]>
  • Loading branch information
philrhc and Phil Cummins authored Dec 5, 2024
1 parent 528a3a0 commit 0041761
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
33 changes: 18 additions & 15 deletions src/stubwasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use wasmparser::{FuncType, Parser, Payload, TypeRef};

use crate::Library;

pub fn link_stub_modules(
libraries: Vec<Library>,
) -> Result<Option<(Vec<u8>, impl Fn(u32) -> u32)>, Error> {
type LinkedStubModules = Option<(Vec<u8>, Box<dyn Fn(u32) -> u32>)>;

pub fn link_stub_modules(libraries: Vec<Library>) -> Result<LinkedStubModules, Error> {
let mut wasi_imports = HashMap::new();
let mut linker = wit_component::Linker::default()
.validate(true)
Expand Down Expand Up @@ -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>(
Expand Down
2 changes: 1 addition & 1 deletion src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/test/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(non_local_definitions)]

use {
super::{Ctx, Tester, SEED},
anyhow::{anyhow, Error, Result},
Expand Down

0 comments on commit 0041761

Please sign in to comment.