bazelbuild / rules_rust

Rust rules for Bazel
https://bazelbuild.github.io/rules_rust/
Apache License 2.0
652 stars 412 forks source link

Aliases not working rust-analyzer when rust_test for crate is defined #2781

Open otiv-emiel-vanseveren opened 1 month ago

otiv-emiel-vanseveren commented 1 month ago

When aliases are set on a rust_binary, they work fine. But when they are also set on a rust_test target with crate=":bin-name" then they are not propagated correctly (no aliases in generated spec file). Resulting in no aliases according to rust_analyzer in the files of the rust_binary

I added a reproduction here. Digging a bit deeper it seems like aliases set on rust_test are not added at all.

I would like to fix this myself. I figured out how I can use a local version of rules_rust, but running bazel run @rules_rust//tools/rust_analyzer:gen_rust_project also generates spec files for all rust code in rules_rust, which make iterating very slow. Is there a way to limit this to my workspace?

otiv-emiel-vanseveren commented 1 month ago

@illicitonion friendly ping, I would really like to contribute!

scentini commented 1 month ago

@otiv-emiel-vanseveren I haven't used gen_rust_project often, however it allows you to specify a specific target or wildcard pattern, e.g:

@rules_rust//tools/rust_analyzer:gen_rust_project -- //my_example:target

does that still result in generating spec files for the rules_rust code?

otiv-emiel-vanseveren commented 1 month ago

does that still result in generating spec files for the rules_rust code?

Ah, silly me. That works, thanks!