bazelbuild / bazelbuild/rules_rust

Document/provide "cargo check"-like functionality

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

Description

`cargo check` is something that rust developers very often use - it can save lots of time, and from my current work place, it's by far the most asked for things by developers migrating from cargo to bazel. It turns out we can easily provide close to the same thing `rules_rust`.

Thanks to the recently implemented pipelining support we can somewhat get "check"-like functionality for free.
This is due to the fact that `cargo check` essentially tries to only output `.rmeta` files whenever possible (e.g. whenever we're not depending on a macro or we don't have to run a build script etc) - which seems to me to be almost the exact same thing that the current pipelining functionality is doing.

With the addition of only requesting the `build_metadata` output group (`--output_groups=build_metadata`), we should now be conceptually be doing mostly the same thing as `cargo check`.

I think that it would be very useful to users to document this combination, e..g advertised as a config:
```
build:check --@rules_rust//rust/settings:pipelined_compilation=True
build:check --output_groups=build_metadata
```
.

Alternatively, we could try to provide a flag built into `rules_rust` to enable both of these things together, but I don't know how to control output groups from within starlark (other than manipulating what providers are returned).

Do you think this is worth advertising, or is the implementation too fragile and something else dedicated would do the job better?

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.