Skip to content

Commit b29ae3a

Browse files
committed
merge 'upstream_master' into 'master'
同步社区最新master分支代码 Created-by: lizheng 30020856 Author-id: 11958 MR-id: 457385 Commit-by: bors;Michael Krasnitski;Mara Bos;KaDiWa;Alex Macleod;Manish Goregaokar;Tyler Weaver;Niki4tap;koka;Sylvain Desodt;ksaleem;Philipp Krones;Collin Styles;xFrednet;Martin Fischer;Evan Typanski;Vincenzo Palazzo;Samuel Moelius;chansuke;Michael Woerister;Kyle Matsuda;Maria José Solano;Michael Goulet;Yuki Okushi;Jason Newcomb;Joshua Nelson;Oli Scherer;Robert Bastian;navh;asquared31415;Andre Bogus;Albert Larsan;dswij;Raiki Tamura;Caio;blyxyas;Robin Schroer;Kyle Huey;Eric Wu;Nilstrieb;Andy Russell;Max Baumann;Ardis Lu;Trevor Gross;Ray Redondo;Matthias Krüger;Esteban Küber;Lukas Lueg;alexey semenyuk;dboso;Samuel Tardieu;feniljain;Gary Guo;Nicholas Nethercote;Fridtjof Stoldt;naosense;alex-semenyuk;Taiki Endo;Hannah Town;Jakob Degen;Lukas Wirth;Vadim Petrochenkov;mdgaziur;Eric Huss;Yuri Astrakhan;kraktus;Ralf Jung;Santiago Pastorino;Camille GILLOT;hkalbasi;Arpad Borsos;Maybe Waffle;ozkanonur;Sosthène Guédon;Deadbeef;Kartavya Vashishtha;Aphek;Nadir Fejzic;Lukas Markeffsky;hrxi;clubby789;yukang;Ryan Scheidter;Grachev Mikhail;Elliot Bobrow;Dylan DPC;Steven Casper;bebecue;Trevor Arjeski;Onur Özkan;Cameron Steffen;Guillaume Gomez;Matthew Ingwersen;Alex ✨ Cosmic Princess ✨;dswijj;mejrs;Rageking8;Alex;est31;oxalica;JT;Doru-Florin Blanzeanu;Andreu Botella;royrustdev;flip1995;lcnr;Kevin Per;Josh Stone;TennyZhuang;Marijn Schouten;Steven Nguyen;Cody;Urgau;ouz-a;Nahua Kang;Felix Kohlgrüber Merged-by: wangqilin 00349210 E2E-issues: Description: add syntax-tree-patterns RFC, Remove if_chain from equatable_if_let, Lint suggests matches macro if PartialEq trait is not implemented, Run cargo dev bless to update fixes & stderr, Merge commit 'ac0e10aa68325235069a842f47499852b2dee79e' into clippyup, Remove `mir::CastKind::Misc`, Merge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup, Introduce TypeErrCtxt TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't need to., Change InferCtxtBuilder from enter to build, make const_err a hard error, Auto merge of #102091 - RalfJung:const_err, r=oli-obk make const_err a hard error This lint has been deny-by-default with future incompat wording since [Rust 1.51](rust-lang/rust#80394) and the stable release of this week starts showing it in cargo's future compat reports. I can't wait to finally get rid of at least some of the mess in our const-err-reporting-code. ;) r? `@oli-obk` Fixes rust-lang/rust#71800 Fixes rust-lang/rust#100114, Auto merge of rust-lang#2583 - RalfJung:rustup, r=oli-obk initial josh subtree sync This demonstrates what a josh-based rustup would look like with my patched josh. To create it I did ``` git fetch http://localhost:8000/rust-lang/rust.git:start=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri.git master git merge FETCH_HEAD ./rustup-toolchain HEAD && ./miri fmt git commit -am rustup ``` Unlike the [previous attempt](rust-lang/miri#2554), this does not add a new root commit to the repo. Once we merge this, we committed to using josh for subtree syncing, and in particular a version of josh that includes josh-project/josh#961 (or something compatible)., Stabilize half_open_range_patterns, Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk Remove `mir::CastKind::Misc` As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast. r? ````@oli-obk````, [`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as float Floats cannot be expressed as hexadecimal literals, ImplItemKind::TyAlias => ImplItemKind::Type, merge rustc history, Fix clippy tests that trigger `for_loop_over_fallibles` lint, fixup lint name, deprecate `clippy::for_loops_over_fallibles`, Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki rename `ImplItemKind::TyAlias` to `ImplItemKind::Type` The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`., Rollup merge of #102275 - Urgau:stabilize-half_open_range_patterns, r=cjgillot Stabilize `half_open_range_patterns` This PR stabilize `feature(half_open_range_patterns)`: ``` Allows using `..=X` as a pattern. ``` And adds a new `feature(half_open_range_patterns_in_slices)` for the slice part, rust-lang/rust#102275 (comment). The FCP was completed in rust-lang/rust#67264., Rename AssocItemKind::TyAlias to AssocItemKind::Type, Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead Uplift `clippy::for_loops_over_fallibles` lint into rustc This PR, as the title suggests, uplifts [`clippy::for_loops_over_fallibles`] lint into rustc. This lint warns for code like this: ```rust for _ in Some(1) {} for _ in Ok::<_, ()>(1) {} ``` i.e. directly iterating over `Option` and `Result` using `for` loop. There are a number of suggestions that this PR adds (on top of what clippy suggested): 1. If the argument (? is there a better name for that expression) of a `for` loop is a `.next()` call, then we can suggest removing it (or rather replacing with `.by_ref()` to allow iterator being used later) ```rust for _ in iter.next() {} // turns into for _ in iter.by_ref() {} ``` 2. (otherwise) We can suggest using `while let`, this is useful for non-iterator, iterator-like things like [async] channels ```rust for _ in rx.recv() {} // turns into while let Some(_) = rx.recv() {} ``` 3. If the argument type is `Result<impl IntoIterator, _>` and the body has a `Result<_, _>` type, we can suggest using `?` ```rust for _ in f() {} // turns into for _ in f()? {} ``` 4. To preserve the original behavior and clear intent, we can suggest using `if let` ```rust for _ in f() {} // turns into if let Some(_) = f() {} ``` (P.S. `Some` and `Ok` are interchangeable depending on the type) I still feel that the lint wording/look is somewhat off, so I'll be happy to hear suggestions (on how to improve suggestions :D)! Resolves #99272 [`clippy::for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles, Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type` Thanks `@camsteffen` for catching this in ast too, cc rust-lang/rust#102829 (comment), merge rustc history, Fix unclosed HTML tag in clippy doc, fix `box-default` ignoring trait objects' types, Fix allow_attributes_without_reason applying to external crate macros Previously the `clippy::allow_attributes_without_reason` lint would apply to external crate macros. Many macros in the Rust ecosystem include these `allow` attributes without adding a reason, making this lint pretty much unusable in any sizable Rust project. This commit fixes that by adding a check to the lint if the attribute is from an external crate macro and returning early., Fix bug in `referent_used_exactly_once`, merge rustc history, `default_numeric_fallback` do not lint on constants, refactor `default_numeric_fallback` We only need to store if the literal binding has an explicit type bound or not, Book: Small grammar + link a11y change, Remove CastCheckResult since it's unused, add missing comma, Auto merge of rust-lang#9644 - hkBst:patch-1, r=flip1995 add missing comma changelog: none, Auto merge of rust-lang#9643 - icecream17:patch-1, r=flip1995 Book: Small grammar + link a11y change *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: none --- Very minor For the link accessibility change, `here` and related don't provide context for screen readers who are reading a list of links. (Random supporting google links) https://www.w3.org/QA/Tips/noClickHere https://usability.yale.edu/web-accessibility/articles/links, Don't lint `ptr_arg` when used as an incompatible trait object, Auto merge of rust-lang#9645 - Jarcho:ptr_arg_9542, r=llogiq Don't lint `ptr_arg` when used as an incompatible trait object fixes rust-lang#9542 changelog: [`ptr_arg`](https://rust-lang.github.io/rust-clippy/master/#ptr_arg): Don't lint when used as an incompatible trait object, Add a suggestion and a note about orphan rules for `from_over_into`, Auto merge of rust-lang#9649 - Alexendoo:from-over-into-suggestion, r=llogiq Add a suggestion and a note about orphan rules for `from_over_into` Adds a machine applicable suggestion to convert the `Into` impl into a `From` one to `from_over_into` Also adds a note explaining that `impl From<Local> for Foreign` is fine if the `Into` type is foreign Closes rust-lang#7444 Addresses half of rust-lang#9638 changelog: [`from_over_into`] Add a suggestion and a note about orphan rules, Separate internal lints by pass, Move some things around, Expand `unnecessary_def_path` lint, Fix adjacent code, Format affected files, `explicit_ty_bound` code golf, [`zero_prefixed_literal`] Do not advise to use octal form if not possible, Enable test no_std_main_recursion, fix `box-default` linting `no_std` non-boxes, Auto merge of rust-lang#9655 - llogiq:unbox-default, r=dswij fix `box-default` linting `no_std` non-boxes This fixes rust-lang#9653 by doing the check against the `Box` type correctly even if `Box` isn't there, as in `no_std` code. Thanks to `@lukas-code` for opening the issue and supplying a reproducer! --- changelog: none, Auto merge of rust-lang#9636 - kraktus:numeric-fallback, r=dswij [`default_numeric_fallback`] do not lint on constants fix rust-lang#9632 changelog:[`default_numeric_fallback`] do not lint on constants, Auto merge of rust-lang#9566 - smoelius:diagnostic-item-path, r=dswij Expand internal lint `unnecessary_def_path` This PR does essentially two things: * Separates the internal lints into modules by pass. (`internal_lints.rs` was over 1400 lines, which is a little unruly IMHO.) * ~Adds a new~ Expands the `unnecessary_def_path` internal lint to flag hardcoded paths to diagnostic and language items. My understanding is that the latter is currently done by reviewers. Automating this process should make things easier for both reviewers and contributors. I could make the first bullet a separate PR, or remove it entirely, if desired. changelog: Add internal lint `diagnostic_item_path`, Add new lint `partial_pub_fields` Signed-off-by: TennyZhuang <zty0826@gmail.com>, fix dogfood Signed-off-by: TennyZhuang <zty0826@gmail.com>, add many tests Signed-off-by: TennyZhuang <zty0826@gmail.com>, fix a doctest Signed-off-by: TennyZhuang <zty0826@gmail.com>, Auto merge of rust-lang#9658 - TennyZhuang:partial-pub-fields, r=llogiq Add new lint `partial_pub_fields` Signed-off-by: TennyZhuang <zty0826@gmail.com> *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: `partial_pub_fields`: new lint to disallow partial fields of a struct be pub Resolve rust-lang#9604, Auto merge of rust-lang#9652 - kraktus:octo_89, r=xFrednet [`zero_prefixed_literal`] Do not advise to use octal form if not possible fix rust-lang#9651 changelog: [`zero_prefixed_literal`] Do not advise to use octal form if not possible, Auto merge of rust-lang#9609 - kraktus:hexa_f32, r=giraffate [`unnecessary_cast`] Do not lint negative he See merge request innersource/rust/toolset/rust-clippy!8
2 parents 5a84ad2 + 8a98609 commit b29ae3a

File tree

1,432 files changed

+27583
-24644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,432 files changed

+27583
-24644
lines changed

.github/driver.sh

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ test "$sysroot" = $desired_sysroot
1717
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
1818
test "$sysroot" = $desired_sysroot
1919

20+
# Check that the --sysroot argument is only passed once (SYSROOT is ignored)
21+
(
22+
cd rustc_tools_util
23+
touch src/lib.rs
24+
SYSROOT=/tmp RUSTFLAGS="--sysroot=$(rustc --print sysroot)" ../target/debug/cargo-clippy clippy --verbose
25+
)
26+
2027
# Make sure this isn't set - clippy-driver should cope without it
2128
unset CARGO_MANIFEST_DIR
2229

.github/workflows/clippy_bors.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ jobs:
8282
with:
8383
github_token: "${{ secrets.github_token }}"
8484

85-
- name: Install dependencies (Linux-i686)
86-
run: |
87-
sudo dpkg --add-architecture i386
88-
sudo apt-get update
89-
sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
90-
if: matrix.host == 'i686-unknown-linux-gnu'
91-
9285
- name: Checkout
9386
uses: actions/checkout@v3.0.2
9487

@@ -164,6 +157,11 @@ jobs:
164157
- name: Test metadata collection
165158
run: cargo collect-metadata
166159

160+
- name: Test lint_configuration.md is up-to-date
161+
run: |
162+
echo "run \`cargo collect-metadata\` if this fails"
163+
git update-index --refresh
164+
167165
integration_build:
168166
needs: changelog
169167
runs-on: ubuntu-latest

CHANGELOG.md

+535-3
Large diffs are not rendered by default.

CODE_OF_CONDUCT.md

+1-68
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,3 @@
11
# The Rust Code of Conduct
22

3-
A version of this document [can be found online](https://www.rust-lang.org/conduct.html).
4-
5-
## Conduct
6-
7-
**Contact**: [rust-mods@rust-lang.org](mailto:rust-mods@rust-lang.org)
8-
9-
* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience,
10-
gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
11-
religion, nationality, or other similar characteristic.
12-
* On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and
13-
welcoming environment for all.
14-
* Please be kind and courteous. There's no need to be mean or rude.
15-
* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and
16-
numerous costs. There is seldom a right answer.
17-
* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and
18-
see how it works.
19-
* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We
20-
interpret the term "harassment" as including the definition in the <a href="http://citizencodeofconduct.org/">Citizen
21-
Code of Conduct</a>; if you have any lack of clarity about what might be included in that concept, please read their
22-
definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups.
23-
* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or
24-
made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation
25-
team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a
26-
safe place for you and we've got your back.
27-
* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
28-
29-
## Moderation
30-
31-
32-
These are the policies for upholding our community's standards of conduct. If you feel that a thread needs moderation,
33-
please contact the [Rust moderation team][mod_team].
34-
35-
1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks,
36-
are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.)
37-
2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed.
38-
3. Moderators will first respond to such remarks with a warning.
39-
4. If the warning is unheeded, the user will be "kicked," i.e., kicked out of the communication channel to cool off.
40-
5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded.
41-
6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended
42-
party a genuine apology.
43-
7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a
44-
different moderator, **in private**. Complaints about bans in-channel are not allowed.
45-
8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate
46-
situation, they should expect less leeway than others.
47-
48-
In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically
49-
unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly
50-
if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can
51-
drive people away from the community entirely.
52-
53-
And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was
54-
they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good
55-
there was something you could've communicated better — remember that it's your responsibility to make your fellow
56-
Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about
57-
cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their
58-
trust.
59-
60-
The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust,
61-
#rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo);
62-
GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org
63-
(users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the
64-
maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider
65-
explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion.
66-
67-
*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the
68-
[Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).*
69-
70-
[mod_team]: https://www.rust-lang.org/team.html#Moderation-team
3+
The Code of Conduct for this repository [can be found online](https://www.rust-lang.org/conduct.html).

CONTRIBUTING.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ All contributors are expected to follow the [Rust Code of Conduct].
2323
- [Issue and PR triage](#issue-and-pr-triage)
2424
- [Bors and Homu](#bors-and-homu)
2525
- [Contributions](#contributions)
26+
- [License](#license)
2627

2728
[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/clippy
2829
[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
2930

3031
## The Clippy book
3132

32-
If you're new to Clippy and don't know where to start the [Clippy book] includes
33+
If you're new to Clippy and don't know where to start, the [Clippy book] includes
3334
a [developer guide] and is a good place to start your journey.
3435

3536
[Clippy book]: https://doc.rust-lang.org/nightly/clippy/index.html
@@ -245,6 +246,38 @@ Contributions to Clippy should be made in the form of GitHub pull requests. Each
245246
be reviewed by a core contributor (someone with permission to land patches) and either landed in the
246247
main tree or given feedback for changes that would be required.
247248

249+
All PRs should include a `changelog` entry with a short comment explaining the change. The rule of thumb is basically,
250+
"what do you believe is important from an outsider's perspective?" Often, PRs are only related to a single property of a
251+
lint, and then it's good to mention that one. Otherwise, it's better to include too much detail than too little.
252+
253+
Clippy's [changelog] is created from these comments. Every release, someone gets all commits from bors with a
254+
`changelog: XYZ` entry and combines them into the changelog. This is a manual process.
255+
256+
Examples:
257+
- New lint
258+
```
259+
changelog: new lint: [`missing_trait_methods`]
260+
```
261+
- False positive fix
262+
```
263+
changelog: Fix [`unused_peekable`] false positive when peeked in a closure or called as `f(&mut peekable)`
264+
```
265+
- Purely internal change
266+
```
267+
changelog: none
268+
```
269+
270+
Note this it is fine for a PR to include multiple `changelog` entries, e.g.:
271+
```
272+
changelog: Something 1
273+
changelog: Something 2
274+
changelog: Something 3
275+
```
276+
277+
[changelog]: CHANGELOG.md
278+
279+
## License
280+
248281
All code in this repository is under the [Apache-2.0] or the [MIT] license.
249282

250283
<!-- adapted from https://github.com/servo/servo/blob/master/CONTRIBUTING.md -->

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.66"
3+
version = "0.1.69"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"
@@ -23,7 +23,7 @@ path = "src/driver.rs"
2323
[dependencies]
2424
clippy_lints = { path = "clippy_lints" }
2525
semver = "1.0"
26-
rustc_tools_util = "0.2.1"
26+
rustc_tools_util = "0.3.0"
2727
tempfile = { version = "3.2", optional = true }
2828
termize = "0.1"
2929

@@ -42,7 +42,7 @@ filetime = "0.2"
4242
rustc-workspace-hack = "1.0"
4343

4444
# UI test dependencies
45-
clap = { version = "3.1", features = ["derive"] }
45+
clap = { version = "4.1.4", features = ["derive"] }
4646
clippy_utils = { path = "clippy_utils" }
4747
derive-new = "0.5"
4848
if_chain = "1.0"
@@ -56,7 +56,7 @@ tokio = { version = "1", features = ["io-util"] }
5656
rustc-semver = "1.1"
5757

5858
[build-dependencies]
59-
rustc_tools_util = "0.2.1"
59+
rustc_tools_util = "0.3.0"
6060

6161
[features]
6262
deny-warnings = ["clippy_lints/deny-warnings"]

README.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Clippy
22

3-
[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test%22+event%3Apush+branch%3Aauto)
3+
[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test%20(bors)/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test+(bors)%22+event%3Apush+branch%3Aauto)
44
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)
55

66
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
77

8-
[There are over 550 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
8+
[There are over 600 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
99

1010
Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
1111
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
@@ -194,21 +194,25 @@ value` mapping e.g.
194194
```toml
195195
avoid-breaking-exported-api = false
196196
disallowed-names = ["toto", "tata", "titi"]
197-
cognitive-complexity-threshold = 30
198197
```
199198

200-
See the [list of lints](https://rust-lang.github.io/rust-clippy/master/index.html) for more information about which
201-
lints can be configured and the meaning of the variables.
199+
The [table of configurations](https://doc.rust-lang.org/nightly/clippy/lint_configuration.html)
200+
contains all config values, their default, and a list of lints they affect.
201+
Each [configurable lint](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration)
202+
, also contains information about these values.
202203

203-
> **Note**
204-
>
205-
> `clippy.toml` or `.clippy.toml` cannot be used to allow/deny lints.
204+
For configurations that are a list type with default values such as
205+
[disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names),
206+
you can use the unique value `".."` to extend the default values instead of replacing them.
207+
208+
```toml
209+
# default of disallowed-names is ["foo", "baz", "quux"]
210+
disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"]
211+
```
206212

207213
> **Note**
208214
>
209-
> Configuration changes will not apply for code that has already been compiled and cached under `./target/`;
210-
> for example, adding a new string to `doc-valid-idents` may still result in Clippy flagging that string. To be sure
211-
> that any configuration changes are applied, you may want to run `cargo clean` and re-compile your crate from scratch.
215+
> `clippy.toml` or `.clippy.toml` cannot be used to allow/deny lints.
212216
213217
To deactivate the “for further information visit *lint-link*” message you can
214218
define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable.
@@ -230,7 +234,7 @@ in the `Cargo.toml` can be used.
230234
rust-version = "1.30"
231235
```
232236

233-
The MSRV can also be specified as an inner attribute, like below.
237+
The MSRV can also be specified as an attribute, like below.
234238

235239
```rust
236240
#![feature(custom_inner_attributes)]

book/src/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Clippy
22

3-
[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test%22+event%3Apush+branch%3Aauto)
3+
[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test%20(bors)/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test+(bors)%22+event%3Apush+branch%3Aauto)
44
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](https://github.com/rust-lang/rust-clippy#license)
55

66
A collection of lints to catch common mistakes and improve your
77
[Rust](https://github.com/rust-lang/rust) code.
88

9-
[There are over 550 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are over 600 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1010

1111
Lints are divided into categories, each with a default [lint
1212
level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how

book/src/SUMMARY.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [Installation](installation.md)
66
- [Usage](usage.md)
77
- [Configuration](configuration.md)
8+
- [Lint Configuration](lint_configuration.md)
89
- [Clippy's Lints](lints.md)
910
- [Continuous Integration](continuous_integration/README.md)
1011
- [GitHub Actions](continuous_integration/github_actions.md)
@@ -21,3 +22,4 @@
2122
- [The Clippy Book](development/infrastructure/book.md)
2223
- [Proposals](development/proposals/README.md)
2324
- [Roadmap 2021](development/proposals/roadmap-2021.md)
25+
- [Syntax Tree Patterns](development/proposals/syntax-tree-patterns.md)

book/src/configuration.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ basic `variable = value` mapping eg.
88
```toml
99
avoid-breaking-exported-api = false
1010
disallowed-names = ["toto", "tata", "titi"]
11-
cognitive-complexity-threshold = 30
1211
```
1312

14-
See the [list of lints](https://rust-lang.github.io/rust-clippy/master/index.html) for more information about which
15-
lints can be configured and the meaning of the variables.
13+
The [table of configurations](./lint_configuration.md)
14+
contains all config values, their default, and a list of lints they affect.
15+
Each [configurable lint](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration)
16+
, also contains information about these values.
17+
18+
For configurations that are a list type with default values such as
19+
[disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names),
20+
you can use the unique value `".."` to extend the default values instead of replacing them.
21+
22+
```toml
23+
# default of disallowed-names is ["foo", "baz", "quux"]
24+
disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"]
25+
```
1626

1727
To deactivate the "for further information visit *lint-link*" message you can define the `CLIPPY_DISABLE_DOCS_LINKS`
1828
environment variable.
@@ -72,7 +82,7 @@ minimum supported Rust version (MSRV) in the clippy configuration file.
7282
msrv = "1.30.0"
7383
```
7484

75-
The MSRV can also be specified as an inner attribute, like below.
85+
The MSRV can also be specified as an attribute, like below.
7686

7787
```rust
7888
#![feature(custom_inner_attributes)]

0 commit comments

Comments
 (0)