Enabling Clippy for extra linting of Rust code in Chromium

19 views
Skip to first unread message

Łukasz Anforowicz

unread,
Mar 9, 2026, 11:50:12 AMMar 9
to chrom...@google.com, rust-dev, chrome-rust...@google.com

Hello,


Clippy is a tool that offers suggestions for improving Rust code.  Chromium recently started using Clippy on some CQ bots - see https://crrev.com/c/7634267 (initially Clippy has been enabled on Linux, other bots/platforms will follow).  More information about Clippy support in Chromium can be found in `//docs/rust/clippy.md`.


Action to consider if you work on Rust code in Chromium: we recommend setting `enable_rust_clippy = true` in `args.gn`:

  • This action is optional, but if you do nothing, then potential Clippy issues in your CLs won’t be detected until a CQ pass.  Reproducing Clippy errors locally requires setting this `args.gn` flag.

  • Clippy is disabled by default to avoid adding build overhead to Chromium engineers primarily working with C, C++, or Java.


We understand that new warnings and lints may add some extra friction to working with Rust code.  Nevertheless, we believe that enabling Clippy should be a net positive for the Chromium project:

  • Clippy helps with scalable teaching of idiomatic Rust coding patterns and reduces the workload on human reviewers.

  • In general, we strongly believe in “shifting left” - detecting and fixing issues as early as possible.  The borrow checker and Clippy both work on different aspects of this goal.

  • Finally, we hope that tools like `build/rust/apply_fixes.py` can streamline applying fix suggestions provided by the Rust compiler and/or Clippy.  An example invocation can be found in `//docs/rust/clippy.md`.


We want Clippy to feel useful, not annoying. If you encounter a lint check that doesn't seem worthwhile, let us know and we'll disable it.   The easiest way to do that is to send us a CL that modifies the list of lints in the `//build/config/compiler:default_clippy_lints` config.


Thanks,


Lukasz (on behalf of the Chrome Rust team)


Reply all
Reply to author
Forward
0 new messages