-
Notifications
You must be signed in to change notification settings - Fork 591
Expand file tree
/
Copy pathrust_clippy.vm
More file actions
49 lines (37 loc) · 1.6 KB
/
rust_clippy.vm
File metadata and controls
49 lines (37 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#[[
## Overview
]]#
[Clippy][clippy] is a tool for catching common mistakes in Rust code and improving it. An
expansive list of lints and the justification can be found in their [documentation][docs].
[clippy]: https://github.com/rust-lang/rust-clippy#readme
[docs]: https://rust-lang.github.io/rust-clippy/
#[[
### Setup
]]#
Simply add the following to the `.bazelrc` file in the root of your workspace:
```text
build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
build --output_groups=+clippy_checks
```
This will enable clippy on all [Rust targets](./defs.md).
Note that targets tagged with `no-clippy` will not perform clippy checks
To use a local clippy.toml, add the following flag to your `.bazelrc`. Note that due to
the upstream implementation of clippy, this file must be named either `.clippy.toml` or
`clippy.toml`. Using a custom config file requires Rust 1.34.0 or newer.
```text
build --@rules_rust//rust/settings:clippy.toml=//:clippy.toml
```
Individual targets may also point at their own configuration file via the
`clippy_config` attribute, which overrides the build setting above for that
target only. This is useful in large workspaces where different subtrees need
different `disallowed-methods`, `disallowed-types`, or other clippy options.
```python
rust_library(
name = "hello_lib",
srcs = ["src/lib.rs"],
clippy_config = "//path/to:clippy.toml",
)
```
Note that `rust_test` targets which use the `crate` attribute to test a library
do not inherit that library's `clippy_config`. Set `clippy_config` explicitly on
the `rust_test` target if it should use the same configuration.