Skip to content

Commit 9524cff

Browse files
committed
Auto merge of rust-lang#10857 - MarcusGrass:update-configuration-file-doc, r=flip1995
Explain which paths clippy searches for configuration in docs Fixes rust-lang/rust-clippy#9921. Adds information on where to place the configuration files, it may be a bit verbose. Also added a comment to the section of the code where the search happens, to hopefully prevent changing that without updating the docs. changelog: Make documentation about where to place configuration files clearer.
2 parents 652b4c7 + 194343f commit 9524cff

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

book/src/configuration.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
> **Note:** The configuration file is unstable and may be deprecated in the future.
44
5-
Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`. It contains a
6-
basic `variable = value` mapping e.g.
5+
Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`, which is searched for in:
6+
7+
1. The directory specified by the `CLIPPY_CONF_DIR` environment variable, or
8+
2. The directory specified by the
9+
[CARGO_MANIFEST_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html) environment variable, or
10+
3. The current directory.
11+
12+
It contains a basic `variable = value` mapping e.g.
713

814
```toml
915
avoid-breaking-exported-api = false

book/src/development/adding_lints.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,14 @@ Before submitting your PR make sure you followed all the basic requirements:
630630

631631
## Adding configuration to a lint
632632

633-
Clippy supports the configuration of lints values using a `clippy.toml` file in
634-
the workspace directory. Adding a configuration to a lint can be useful for
633+
Clippy supports the configuration of lints values using a `clippy.toml` file which is searched for in:
634+
635+
1. The directory specified by the `CLIPPY_CONF_DIR` environment variable, or
636+
2. The directory specified by the
637+
[CARGO_MANIFEST_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html) environment variable, or
638+
3. The current directory.
639+
640+
Adding a configuration to a lint can be useful for
635641
thresholds or to constrain some behavior that can be seen as a false positive
636642
for some users. Adding a configuration is done in the following steps:
637643

clippy_lints/src/utils/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ pub fn lookup_conf_file() -> io::Result<(Option<PathBuf>, Vec<String>)> {
486486
const CONFIG_FILE_NAMES: [&str; 2] = [".clippy.toml", "clippy.toml"];
487487

488488
// Start looking for a config file in CLIPPY_CONF_DIR, or failing that, CARGO_MANIFEST_DIR.
489-
// If neither of those exist, use ".".
489+
// If neither of those exist, use ".". (Update documentation if this priority changes)
490490
let mut current = env::var_os("CLIPPY_CONF_DIR")
491491
.or_else(|| env::var_os("CARGO_MANIFEST_DIR"))
492492
.map_or_else(|| PathBuf::from("."), PathBuf::from)

0 commit comments

Comments
 (0)