Skip to content

Commit 01efb2e

Browse files
committed
fix: Remove incorrect export macro re-export from wrapper
The wit-bindgen CLI generates the export! macro itself (via --pub-export-macro flag). We should NOT re-export it from wit-bindgen-rt, which doesn't have it in v0.39.0. The wrapper should only provide: - pub use wit_bindgen_rt as wit_bindgen; (for wit_bindgen::rt module) The export! macro is generated by the CLI and included in the bindings. This fixes: error[E0432]: unresolved import `wit_bindgen_rt::export`
1 parent 3ed1ccf commit 01efb2e

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

docs/embedded_runtime_fix.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,17 @@ This is automatically available as `@crates//:wit-bindgen-rt` through the crates
4141
- `wit-bindgen` = Procedural macro crate for `generate!()` macro
4242
- `wit-bindgen-rt` = Runtime crate for CLI-generated bindings (what we need)
4343

44-
#### 2. Simplified Runtime Wrapper (rust/rust_wasm_component_bindgen.bzl:58-79)
44+
#### 2. Simplified Runtime Wrapper (rust/rust_wasm_component_bindgen.bzl:58-78)
4545

4646
**Before**: 114 lines of embedded runtime stubs
47-
**After**: 6 lines of simple re-exports
47+
**After**: 1 line of simple re-export
4848

4949
```rust
50-
// Re-export wit-bindgen-rt as wit_bindgen to provide proper runtime implementation
51-
// The wit-bindgen CLI generates code that expects: crate::wit_bindgen::rt
50+
// Re-export wit-bindgen-rt as wit_bindgen to provide the runtime module
51+
// This provides wit_bindgen::rt with proper allocator integration
5252
pub use wit_bindgen_rt as wit_bindgen;
5353

54-
// Re-export the export macro at crate level for convenience
55-
pub use wit_bindgen_rt::export;
54+
// Note: export! macro is generated by wit-bindgen CLI (via --pub-export-macro)
5655
```
5756

5857
#### 3. Added Dependencies to Bindings Libraries (lines 326, 337)

rust/rust_wasm_component_bindgen.bzl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,24 @@ def _generate_wrapper_impl(ctx):
5757

5858
# Create wrapper content - re-export wit-bindgen-rt as wit_bindgen
5959
# The wit-bindgen CLI generates code that expects: crate::wit_bindgen::rt
60-
# wit-bindgen-rt provides the runtime support (export macro, allocator, etc)
60+
# The CLI also generates the export! macro with --pub-export-macro flag
6161
wrapper_content = """// Generated wrapper for WIT bindings
6262
//
6363
// This wrapper re-exports wit-bindgen-rt as wit_bindgen to provide the runtime
6464
// at the path expected by wit-bindgen CLI (--runtime-path crate::wit_bindgen::rt)
65+
//
66+
// The export! macro is generated by wit-bindgen CLI (via --pub-export-macro)
6567
6668
// Suppress clippy warnings for generated code
6769
#![allow(clippy::all)]
6870
#![allow(unused_imports)]
6971
#![allow(dead_code)]
7072
71-
// Re-export wit-bindgen-rt as wit_bindgen to provide proper runtime implementation
72-
// This provides the export! macro, rt module with correct allocator integration
73+
// Re-export wit-bindgen-rt as wit_bindgen to provide the runtime module
74+
// This provides wit_bindgen::rt with proper allocator integration
7375
pub use wit_bindgen_rt as wit_bindgen;
7476
75-
// Re-export the export macro at crate level for convenience
76-
pub use wit_bindgen_rt::export;
77-
78-
// Generated bindings follow:
77+
// Generated bindings follow (including export! macro):
7978
"""
8079

8180
# Concatenate wrapper content with generated bindings

0 commit comments

Comments
 (0)