bazelbuild / rules_rust

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

feat: Add `rust_lint_group` and `cargo_lints` rule to define lint groups #2993

Open ParkMyCar opened 2 weeks ago

ParkMyCar commented 2 weeks ago

Chatted about this previously in Slack. The goal with this PR is to make it easier to define and share lint configurations for your build.

Description

The PR adds two new rules, rust_lint_group and cargo_lints. It also adds a "lints" attr to rust_library and rust_binary rules that expects a new LintsInfo provider.

Then the rustc, clippy, and rustdoc actions are all updated to check for the LintsInfo provider and appends the correct arguments so the lints take effect.

Design

Honestly this is my first large change to a set of Bazel rules, so I definitely could have done something wrong here!

The change is split into two commits, the first introduces rust_lint_group which IMO is relatively straight forward. Some attributes are defined on a rule which are then formatted into command line flags and passed around with a provider.

The second commit adds cargo_lints and is much larger, a few things worth considering:

Tests

There aren't any! I wasn't sure where the best place to start was, any guidance here is appreciated!

ParkMyCar commented 1 week ago

Thanks for the review @illicitonion! Didn't get a chance to add tests (although I did test manually by using this in my project), will follow up with that!

illicitonion commented 2 days ago

Looks good, thanks! If we can get those tests in, let's get this merged! 🎉