cargo-component
cargo-component copied to clipboard
Cargo workspaces `core`, `alloc` imports and `macro` exports cannot be resolved
It seems that composing a project with a structure like below has resolution issues that need a patch to the bindings generated to function:
.
├── Cargo.toml # <<< Workspace only, with members in components/* and crates/*
├── components # <<< Minimal wrappers around ./crates/*
│ ├── cli
│ ├── responder
│ └── <other cargo component crates>
├── crates
│ ├── <pure rust crates, no wasm>
└── wit
├── cli.wit
├── responder.wit
└── <other wit files>
Here is a minimal reproducible example with the patch I got compiling at least - note the diff is inverted so I needed the opposite change from the PR to compile: https://github.com/NukeManDan/cargo-component-workspace-bindings/pull/1 . Although I am not sure that this is the right fix, just what hacked together seems to fix cargo's complaints :sweat_smile: .
The patch here is to be more explicit in imports and a long standing weirdness of macro resolution: https://github.com/rust-lang/rust/issues/57966
Perhaps this issue would need to be transferred to https://github.com/bytecodealliance/wit-bindgen if the fix should not exist here.