From bcf79e157792d3d966db3910f42e89ea48eaae46 Mon Sep 17 00:00:00 2001 From: Matt Wilkinson Date: Tue, 21 Apr 2026 00:01:19 -0400 Subject: [PATCH 1/3] rust: qualify world-owned type paths so future/stream payload vtables resolve --- crates/rust/src/interface.rs | 5 +++++ crates/rust/tests/codegen.rs | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/crates/rust/src/interface.rs b/crates/rust/src/interface.rs index 38caf7c14..c81c3271e 100644 --- a/crates/rust/src/interface.rs +++ b/crates/rust/src/interface.rs @@ -1887,6 +1887,11 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) return format!("{path}::{name}"); } } + // World-level aliases live at macro root. `path_to_root()` is + // `""` at root, `"super::super::"` in stream/future payload mode. + if let TypeOwner::World(_) = self.resolve.types[id].owner { + return format!("{}{name}", self.path_to_root()); + } name } diff --git a/crates/rust/tests/codegen.rs b/crates/rust/tests/codegen.rs index a6df22cf9..773b31b30 100644 --- a/crates/rust/tests/codegen.rs +++ b/crates/rust/tests/codegen.rs @@ -235,3 +235,25 @@ mod method_chaining { enable_method_chaining: true }); } + +// Regression for #1598: world-level `use t.{r};` inside +// `future>` used to emit unresolved bare `R` in vtable{N}. +#[allow(unused, reason = "testing codegen, not functionality")] +mod issue_1598_future_result_use { + wit_bindgen::generate!({ + inline: r#" + package a:b; + + world w { + use t.{r}; + export f: func() -> future>; + } + + interface t { + record r { + x: u32, + } + } + "#, + }); +} From 2114f5c1b6f70d822613013e05890d759de55ac8 Mon Sep 17 00:00:00 2001 From: Matt Wilkinson Date: Tue, 21 Apr 2026 15:13:10 -0400 Subject: [PATCH 2/3] add regression test to .wit file --- crates/rust/tests/codegen.rs | 22 ---------------------- crates/test/src/csharp.rs | 1 + tests/codegen/issue-1598.wit | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 tests/codegen/issue-1598.wit diff --git a/crates/rust/tests/codegen.rs b/crates/rust/tests/codegen.rs index 773b31b30..a6df22cf9 100644 --- a/crates/rust/tests/codegen.rs +++ b/crates/rust/tests/codegen.rs @@ -235,25 +235,3 @@ mod method_chaining { enable_method_chaining: true }); } - -// Regression for #1598: world-level `use t.{r};` inside -// `future>` used to emit unresolved bare `R` in vtable{N}. -#[allow(unused, reason = "testing codegen, not functionality")] -mod issue_1598_future_result_use { - wit_bindgen::generate!({ - inline: r#" - package a:b; - - world w { - use t.{r}; - export f: func() -> future>; - } - - interface t { - record r { - x: u32, - } - } - "#, - }); -} diff --git a/crates/test/src/csharp.rs b/crates/test/src/csharp.rs index a4d017e18..e95adc3b3 100644 --- a/crates/test/src/csharp.rs +++ b/crates/test/src/csharp.rs @@ -48,6 +48,7 @@ impl LanguageMethods for Csharp { | "async-resource-func.wit" | "import-export-resource.wit" | "issue-1433.wit" + | "issue-1598.wit" | "named-fixed-length-list.wit" | "map.wit" ) diff --git a/tests/codegen/issue-1598.wit b/tests/codegen/issue-1598.wit new file mode 100644 index 000000000..eac624b60 --- /dev/null +++ b/tests/codegen/issue-1598.wit @@ -0,0 +1,14 @@ +//@ async = true + +package a:b; + +world w { + use t.{r}; + export f: async func() -> future>; +} + +interface t { + record r { + x: u32, + } +} From be1da1373591df33636a7503c2854d11ffb24979 Mon Sep 17 00:00:00 2001 From: Matt Wilkinson Date: Tue, 21 Apr 2026 15:54:25 -0400 Subject: [PATCH 3/3] add ignores for wit test to cpp and go --- crates/test/src/cpp.rs | 4 ++++ crates/test/src/go.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/crates/test/src/cpp.rs b/crates/test/src/cpp.rs index 33751f60a..4946a1fef 100644 --- a/crates/test/src/cpp.rs +++ b/crates/test/src/cpp.rs @@ -45,6 +45,10 @@ impl LanguageMethods for Cpp { config: &crate::config::WitConfig, _args: &[String], ) -> bool { + // Compiles on C++ despite the blanket async exclusion below. + if name == "issue-1598.wit" { + return false; + } return match name { "issue1514-6.wit" | "named-fixed-length-list.wit" | "map.wit" => true, _ => false, diff --git a/crates/test/src/go.rs b/crates/test/src/go.rs index 83060b3a9..afe651951 100644 --- a/crates/test/src/go.rs +++ b/crates/test/src/go.rs @@ -30,6 +30,7 @@ impl LanguageMethods for Go { config.error_context || name == "async-trait-function.wit" || name == "named-fixed-length-list.wit" + || name == "issue-1598.wit" } fn default_bindgen_args_for_codegen(&self) -> &[&str] {