Skip to content

Conversation

@avrabe
Copy link
Contributor

@avrabe avrabe commented Nov 14, 2025

Problem

The bitflags macro in the embedded wit_bindgen runtime was using pub(crate) visibility, which made it only accessible within the generated bindings crate itself. This prevented external crates that depend on the generated bindings from accessing the macro when they use WASI filesystem interfaces.

Solution

Changed pub(crate) use bitflags; to pub use bitflags::bitflags; in both wrapper modes:

  • Native-guest wrapper (lines 161-166)
  • Guest wrapper (lines 255-260)

This properly exports the bitflags macro so downstream crates can access it through the expected path: crate::wit_bindgen::rt::bitflags::bitflags!

Testing

Verified builds succeed for:

  • //examples/basic:hello_component_bindings_host - native-guest mode bindings
  • //tools/checksum_updater_wasm:checksum_updater_wasm_component - WASM component using WASI filesystem interfaces (wasi:filesystem/[email protected])

Both targets compile without "could not find bitflags in rt" errors.

Impact

This fixes the visibility issue for any external crate that:

  1. Depends on generated bindings from rust_wasm_component_bindgen
  2. Needs to use WASI filesystem interfaces (DescriptorFlags, PathFlags, OpenFlags)

Changed pub(crate) use bitflags; to pub use bitflags::bitflags; in the
embedded wit_bindgen runtime. This allows external crates that depend on
the generated bindings to access the bitflags macro when they use WASI
filesystem interfaces.

The pub(crate) visibility restricted access to within the bindings crate
itself, preventing downstream users from accessing the macro through the
expected path: crate::wit_bindgen::rt::bitflags::bitflags!

Tested with:
- //examples/basic:hello_component_bindings_host (native-guest mode)
- //tools/checksum_updater_wasm:checksum_updater_wasm_component (WASI filesystem)
@avrabe avrabe merged commit 2f8893b into main Nov 14, 2025
25 checks passed
@avrabe avrabe deleted the fix/bitflags-public-visibility branch November 14, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants