Skip to content

Commit 82edbfd

Browse files
committed
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.
1 parent 9b0965c commit 82edbfd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

crates/guest-rust/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ extern crate std;
574574
/// # // ...
575575
/// # }
576576
/// #
577-
/// export!(MyComponent with_types_in self);
577+
/// export!(MyComponent, with_types_in self);
578578
/// #
579579
/// # fn main() {}
580580
/// ```
@@ -607,7 +607,7 @@ extern crate std;
607607
/// # // ...
608608
/// # }
609609
/// #
610-
/// bindings::export!(MyComponent with_types_in bindings);
610+
/// bindings::export!(MyComponent, with_types_in bindings);
611611
/// #
612612
/// # fn main() {}
613613
/// ```

crates/rust/src/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ fn _resource_rep(handle: u32) -> *mut u8
277277
#[doc(hidden)]
278278
{macro_export}
279279
macro_rules! {macro_name} {{
280-
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = {{
280+
($ty:path, with_types_in $($path_to_types:tt)*) => (const _: () = {{
281281
"
282282
);
283283

crates/rust/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,16 +875,16 @@ impl As{upcase} for {to_convert} {{
875875
#[doc(hidden)]
876876
{macro_export}
877877
macro_rules! __export_{world_name}_impl {{
878-
($ty:ident) => ({default_bindings_module}::{export_macro_name}!($ty with_types_in {default_bindings_module}););
879-
($ty:ident with_types_in $($path_to_types_root:tt)*) => ("#
878+
($ty:path) => ({default_bindings_module}::{export_macro_name}!($ty => {default_bindings_module}););
879+
($ty:path, with_types_in $($path_to_types_root:tt)*) => ("#
880880
);
881881
for (name, path_to_types) in self.export_macros.iter() {
882882
let mut path = "$($path_to_types_root)*".to_string();
883883
if !path_to_types.is_empty() {
884884
path.push_str("::");
885885
path.push_str(path_to_types)
886886
}
887-
uwriteln!(self.src, "{path}::{name}!($ty with_types_in {path});");
887+
uwriteln!(self.src, "{path}::{name}!($ty, with_types_in {path});");
888888
}
889889

890890
// See comments in `finish` for why this conditionally happens here.

0 commit comments

Comments
 (0)