diff --git a/crates/guest-rust/src/lib.rs b/crates/guest-rust/src/lib.rs index a2a35d5b9..767346cc2 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!({ ty: MyComponent, with_types_in: self }); /// # /// # fn main() {} /// ``` @@ -607,7 +607,7 @@ extern crate std; /// # // ... /// # } /// # -/// bindings::export!(MyComponent with_types_in bindings); +/// bindings::export!({ ty: MyComponent, with_types_in: bindings }); /// # /// # fn main() {} /// ``` diff --git a/crates/rust/src/interface.rs b/crates/rust/src/interface.rs index 4f4f00471..2cf432607 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: $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..4599d071d 100644 --- a/crates/rust/src/lib.rs +++ b/crates/rust/src/lib.rs @@ -875,16 +875,21 @@ 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: $ty, with_types_in: {default_bindings_module} }});); + ({{ ty: $ty:path $(,)? }}) => ({default_bindings_module}::{export_macro_name}!({{ ty: $ty, with_types_in: {default_bindings_module} }});); + ({{ ty: $ty:path, with_types_in: $($path_to_types:tt)+, }}) => ({default_bindings_module}::{export_macro_name}!({{ ty: $ty, with_types_in: $($path_to_types)* }});); + ({{ ty: $ty:path, with_types_in: $($path_to_types:tt)+ }}) => ("# ); for (name, path_to_types) in self.export_macros.iter() { - let mut path = "$($path_to_types_root)*".to_string(); + let mut path = "$($path_to_types)*".to_string(); if !path_to_types.is_empty() { 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: $ty, with_types_in: {path} }});" + ); } // See comments in `finish` for why this conditionally happens here.