Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a 'check' target for 'rust_binary' and 'rust_library'. #1633

Open
semtexzv opened this issue Nov 6, 2022 · 1 comment
Open

Implement a 'check' target for 'rust_binary' and 'rust_library'. #1633

semtexzv opened this issue Nov 6, 2022 · 1 comment

Comments

@semtexzv
Copy link
Contributor

semtexzv commented Nov 6, 2022

I'd be nice to support a target similar to 'cargo check' entirely inside bazel.

Idea:

By running rustc <file> --error-format=json -Z no-codegen we get an output expected by rust analyzer. With some clever code generation It could allow the user to set checkOnSave.overrideCommand in the rust-project.json to run this target, generating necessary info for rust-analyzer to get proper error highlighting.

Details:

For each generated binary/library/crate, generate a <name>_check target. When running this target, we execute appropriate rustc <files...> --error-format=json -Z no-codegen, returning the errors, warnings in json fomat.

Then, when generating rust-project.json for rust-analyzer, insert "checkOnSave.overrideCommand" : "bazel run <path>_check"

@googleson78
Copy link
Contributor

The "check" part of this is already somewhat possible and working today, with some config options. See #1649

I also gave the "json output" somewhat of a shot in #1657.

The "automatically insert the target into rust-project.json" isn't currently possible afaik, due to the fact that rust-project.json doesn't currently store info about that. See

rust-lang/rust-analyzer#13529
rust-lang/rust-analyzer#13446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants