-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Repro steps
cargo component new reprocd repro- Run VS Code with rust-analyzer enabled and open
src/main.rs.
rust-analyzer should trigger a check command that will generate a target/bindings/repro/target.wasm file containing the current target world for the project; the target is empty for command projects by default, so the generated bindings mod will be empty.
- Create a
witdirectory. - Add a
test.witfile with the following contents:
package repro:test
world repro {
import test: func()
}- In VS Code, manually save
src/main.rsto trigger a reparse. - In the
mainfunction insrc/main.rs, typebindings::.
Expected results
rust-analyzer should offer autocomplete suggestions for the imported function.
Actual results
Nothing happens.
Remarks
Right now, the cargo_component_bindings::generate! macro reads the target wasm file (which is very small and only contains type information) to generate bindings and emits a include_bytes! with the hopes that a dependency on the file will trigger a rebuild if it changes.
However, it appears that rust-analyzer doesn't respect changes to the file to reparse; it continues to use a cached evaluation of the proc-macro.
This may be related to rust-lang/rust-analyzer#13668, but I can't say for sure.
Workarounds
Restarting the rust-analyzer server after modifying the WIT files forces the re-evaluation of the macro with the latest bindings information.