From 5b8053ca3d924464570d34f297f58b70bb185664 Mon Sep 17 00:00:00 2001 From: Jeremy Fleitz Date: Fri, 28 Aug 2026 15:22:44 -0400 Subject: [PATCH] ensure that an async function matches Signed-off-by: Jeremy Fleitz --- crates/c/src/lib.rs | 4 ++++ crates/go/src/lib.rs | 3 +++ crates/moonbit/src/lib.rs | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/c/src/lib.rs b/crates/c/src/lib.rs index 91d30b14e..95781f3b7 100644 --- a/crates/c/src/lib.rs +++ b/crates/c/src/lib.rs @@ -319,6 +319,10 @@ impl WorldGenerator for C { } fn finish(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) -> Result<()> { + // Error about unused async configuration to help catch configuration + // errors. + self.opts.async_.ensure_all_used()?; + let linking_symbol = component_type_object::linking_symbol(&self.world); self.c_include(""); let snake = self.world.to_snake_case(); diff --git a/crates/go/src/lib.rs b/crates/go/src/lib.rs index 13800f06a..2816fc5cc 100644 --- a/crates/go/src/lib.rs +++ b/crates/go/src/lib.rs @@ -877,6 +877,9 @@ impl WorldGenerator for Go { fn finish(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) -> Result<()> { _ = (resolve, id); + // Error about unused async configuration to help catch configuration + // errors. + self.opts.async_.ensure_all_used()?; let version = env!("CARGO_PKG_VERSION"); let packages = resolve diff --git a/crates/moonbit/src/lib.rs b/crates/moonbit/src/lib.rs index 78d1a0dbf..15c531c77 100644 --- a/crates/moonbit/src/lib.rs +++ b/crates/moonbit/src/lib.rs @@ -524,6 +524,10 @@ impl WorldGenerator for MoonBit { } fn finish(&mut self, _resolve: &Resolve, _id: WorldId, files: &mut Files) -> Result<()> { + // Error about unused async configuration to help catch configuration + // errors. + self.opts.async_.ensure_all_used()?; + // If async is used, export async utils self.async_support.emit_runtime_files(files, VERSION); @@ -3249,9 +3253,16 @@ mod tests { #[test] fn async_filters_respect_import_export_direction() { + // The world both imports and exports `run` so that each directional + // filter below matches something; an unmatched filter is now an error + // (see `AsyncFilterSet::ensure_all_used`), which would mask what this + // test is actually checking. let wit = r#" package a:b; - world runner { import run: func(); } + world runner { + import run: func(); + export run: func(); + } "#; let mut import_opts = Opts {