From 82edbfd5b4cae81482705fdd99db37d77c2304b9 Mon Sep 17 00:00:00 2001 From: Ari Seyhun Date: Fri, 13 Mar 2026 16:32:58 +1100 Subject: [PATCH 1/2] feat(rust)!: use path in generated `export!` macro instead of `ident` Changes the generated `export!` macro to accept a `$ty:path` instead of `$ty:ident` for more flexibility. Requires the `with_types_in` separator to be changed to `, with_types_in`, since a `path` cannot be followed by an ident in macros. --- crates/guest-rust/src/lib.rs | 4 ++-- crates/rust/src/interface.rs | 2 +- crates/rust/src/lib.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/guest-rust/src/lib.rs b/crates/guest-rust/src/lib.rs index a2a35d5b9..0c57f9ff0 100644 --- a/crates/guest-rust/src/lib.rs +++ b/crates/guest-rust/src/lib.rs @@ -574,7 +574,7 @@ extern crate std; /// # // ... /// # } /// # -/// export!(MyComponent with_types_in self); +/// export!(MyComponent, with_types_in self); /// # /// # fn main() {} /// ``` @@ -607,7 +607,7 @@ extern crate std; /// # // ... /// # } /// # -/// bindings::export!(MyComponent with_types_in bindings); +/// bindings::export!(MyComponent, with_types_in bindings); /// # /// # fn main() {} /// ``` diff --git a/crates/rust/src/interface.rs b/crates/rust/src/interface.rs index 4f4f00471..eb059a1b6 100644 --- a/crates/rust/src/interface.rs +++ b/crates/rust/src/interface.rs @@ -277,7 +277,7 @@ fn _resource_rep(handle: u32) -> *mut u8 #[doc(hidden)] {macro_export} macro_rules! {macro_name} {{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = {{ + ($ty:path, with_types_in $($path_to_types:tt)*) => (const _: () = {{ " ); diff --git a/crates/rust/src/lib.rs b/crates/rust/src/lib.rs index 3df749648..93b52a740 100644 --- a/crates/rust/src/lib.rs +++ b/crates/rust/src/lib.rs @@ -875,8 +875,8 @@ impl As{upcase} for {to_convert} {{ #[doc(hidden)] {macro_export} macro_rules! __export_{world_name}_impl {{ - ($ty:ident) => ({default_bindings_module}::{export_macro_name}!($ty with_types_in {default_bindings_module});); - ($ty:ident with_types_in $($path_to_types_root:tt)*) => ("# + ($ty:path) => ({default_bindings_module}::{export_macro_name}!($ty => {default_bindings_module});); + ($ty:path, with_types_in $($path_to_types_root:tt)*) => ("# ); for (name, path_to_types) in self.export_macros.iter() { let mut path = "$($path_to_types_root)*".to_string(); @@ -884,7 +884,7 @@ macro_rules! __export_{world_name}_impl {{ path.push_str("::"); path.push_str(path_to_types) } - uwriteln!(self.src, "{path}::{name}!($ty with_types_in {path});"); + uwriteln!(self.src, "{path}::{name}!($ty, with_types_in {path});"); } // See comments in `finish` for why this conditionally happens here. From 11fe1b1ee9cd5f39a363bd9c393bd8c45b858fa0 Mon Sep 17 00:00:00 2001 From: Ari Seyhun Date: Fri, 13 Mar 2026 18:32:26 +1100 Subject: [PATCH 2/2] fix(rust): export world macro --- crates/rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rust/src/lib.rs b/crates/rust/src/lib.rs index 93b52a740..2045e3529 100644 --- a/crates/rust/src/lib.rs +++ b/crates/rust/src/lib.rs @@ -875,7 +875,7 @@ impl As{upcase} for {to_convert} {{ #[doc(hidden)] {macro_export} macro_rules! __export_{world_name}_impl {{ - ($ty:path) => ({default_bindings_module}::{export_macro_name}!($ty => {default_bindings_module});); + ($ty:path) => ({default_bindings_module}::{export_macro_name}!($ty, with_types_in {default_bindings_module});); ($ty:path, with_types_in $($path_to_types_root:tt)*) => ("# ); for (name, path_to_types) in self.export_macros.iter() {