rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Code completion support in Rust Bazel projects

Open barbu110 opened this issue 1 year ago • 2 comments

Hi folks, not sure if this is the correct place for such a question, but I'm shooting my shot.

I am very excited about the use of Bazel for Rust projects. I am building a project consisting of multiple programming languages, with the largest portion being in Rust and generated code for Protocol Buffer files.

I got everything to build nicely, but code completion is nowhere near any working state. Rust-analyzer simply cannot find anything related to rust_prost_library-generated code or about any other crates in the project.

Is code completion something I'm gonna have to give up to use Bazel or is there a known solution?

barbu110 avatar Apr 29 '24 12:04 barbu110

Hello! Our hope/intention is that everything works smoothly, but there are definitely corners where rust-analyzer doesn't work if you have a pure-bazel build (and IntelliJ too) - in general I'd expect all of these issues to be solvable, just no one has solved them yet. Contributions are very welcome to improve this coverage!

In the mean time, a lot of folks maintain parallel Cargo and Bazel builds for this reason - I'd love to get to a place where this wasn't necessary.

illicitonion avatar Apr 30 '24 10:04 illicitonion

Thanks for the prompt reply!

I was able to get code completion, go to definition, and other such amenities working using the rust_analyzer toolchain. I accidentally stumbled on it.

I'd like to perhaps contribute something to the documentation to help people discover it more easily.

barbu110 avatar Apr 30 '24 11:04 barbu110