bazelbuild / bazelbuild/rules_rust

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

Open
#1,633 1 comment 0 reactions 0 assignees View on GitHub
enhancement needs-triage rust-analyzer
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

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

### **Idea:**
By running ```rustc --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 `_check` target. When running this target, we execute appropriate ```rustc --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 _check"`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.