Skip to content

Commit 0f6f2d6

Browse files
committed
Auto merge of rust-lang#79765 - flip1995:clippyup, r=Manishearth
Update Clippy Biweekly Clippy update (which I forgot about on Thursday) This includes a `Cargo.lock` update, so probably needs `rollup=never`. r? `@Manishearth`
2 parents d577c53 + 898ef0f commit 0f6f2d6

File tree

140 files changed

+4342
-577
lines changed

Some content is hidden

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

140 files changed

+4342
-577
lines changed

Cargo.lock

+8-1
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ dependencies = [
569569
"quine-mc_cluskey",
570570
"quote",
571571
"regex-syntax",
572+
"rustc-semver",
572573
"semver 0.11.0",
573574
"serde",
574575
"smallvec 1.4.2",
@@ -3365,6 +3366,12 @@ dependencies = [
33653366
"num_cpus",
33663367
]
33673368

3369+
[[package]]
3370+
name = "rustc-semver"
3371+
version = "1.1.0"
3372+
source = "registry+https://github.com/rust-lang/crates.io-index"
3373+
checksum = "5be1bdc7edf596692617627bbfeaba522131b18e06ca4df2b6b689e3c5d5ce84"
3374+
33683375
[[package]]
33693376
name = "rustc-std-workspace-alloc"
33703377
version = "1.99.0"
@@ -5265,7 +5272,7 @@ dependencies = [
52655272
"chrono",
52665273
"lazy_static",
52675274
"matchers",
5268-
"parking_lot 0.9.0",
5275+
"parking_lot 0.11.0",
52695276
"regex",
52705277
"serde",
52715278
"serde_json",

src/tools/clippy/.github/workflows/clippy_bors.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ jobs:
128128
SYSROOT=$(rustc --print sysroot)
129129
echo "$SYSROOT/bin" >> $GITHUB_PATH
130130
131-
- name: Build
132-
run: cargo build --features deny-warnings
131+
- name: Build with internal lints
132+
run: cargo build --features deny-warnings,internal-lints
133133

134-
- name: Test
135-
run: cargo test --features deny-warnings
134+
- name: Test with internal lints
135+
run: cargo test --features deny-warnings,internal-lints
136136

137-
- name: Test clippy_lints
138-
run: cargo test --features deny-warnings
137+
- name: Test clippy_lints with internal lints
138+
run: cargo test --features deny-warnings,internal-lints
139139
working-directory: clippy_lints
140140

141141
- name: Test rustc_tools_util

src/tools/clippy/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,7 @@ Released 2018-09-13
17701770
[`cmp_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_owned
17711771
[`cognitive_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity
17721772
[`collapsible_if`]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
1773+
[`collapsible_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
17731774
[`comparison_chain`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain
17741775
[`comparison_to_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
17751776
[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
@@ -2056,6 +2057,7 @@ Released 2018-09-13
20562057
[`single_element_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_element_loop
20572058
[`single_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match
20582059
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
2060+
[`size_of_in_element_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#size_of_in_element_count
20592061
[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
20602062
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
20612063
[`stable_sort_primitive`]: https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
@@ -2073,6 +2075,7 @@ Released 2018-09-13
20732075
[`suspicious_else_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting
20742076
[`suspicious_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
20752077
[`suspicious_op_assign_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_op_assign_impl
2078+
[`suspicious_operation_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_operation_groupings
20762079
[`suspicious_unary_op_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_unary_op_formatting
20772080
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
20782081
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment

src/tools/clippy/CONTRIBUTING.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ All contributors are expected to follow the [Rust Code of Conduct].
1414

1515
- [Contributing to Clippy](#contributing-to-clippy)
1616
- [Getting started](#getting-started)
17+
- [High level approach](#high-level-approach)
1718
- [Finding something to fix/improve](#finding-something-to-fiximprove)
1819
- [Writing code](#writing-code)
1920
- [Getting code-completion for rustc internals to work](#getting-code-completion-for-rustc-internals-to-work)
2021
- [How Clippy works](#how-clippy-works)
2122
- [Fixing build failures caused by Rust](#fixing-build-failures-caused-by-rust)
23+
- [Patching git-subtree to work with big repos](#patching-git-subtree-to-work-with-big-repos)
24+
- [Performing the sync](#performing-the-sync)
25+
- [Syncing back changes in Clippy to [`rust-lang/rust`]](#syncing-back-changes-in-clippy-to-rust-langrust)
26+
- [Defining remotes](#defining-remotes)
2227
- [Issue and PR triage](#issue-and-pr-triage)
2328
- [Bors and Homu](#bors-and-homu)
2429
- [Contributions](#contributions)
@@ -320,8 +325,8 @@ commands [here][homu_instructions].
320325
[l-crash]: https://github.com/rust-lang/rust-clippy/labels/L-crash
321326
[l-bug]: https://github.com/rust-lang/rust-clippy/labels/L-bug
322327
[homu]: https://github.com/rust-lang/homu
323-
[homu_instructions]: https://buildbot2.rust-lang.org/homu/
324-
[homu_queue]: https://buildbot2.rust-lang.org/homu/queue/clippy
328+
[homu_instructions]: https://bors.rust-lang.org/
329+
[homu_queue]: https://bors.rust-lang.org/queue/clippy
325330
326331
## Contributions
327332

src/tools/clippy/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ path = "src/driver.rs"
3232
clippy_lints = { version = "0.0.212", path = "clippy_lints" }
3333
# end automatic update
3434
semver = "0.11"
35-
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
35+
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
3636
tempfile = { version = "3.1.0", optional = true }
3737

3838
[dev-dependencies]
@@ -49,8 +49,9 @@ derive-new = "0.5"
4949
rustc-workspace-hack = "1.0.0"
5050

5151
[build-dependencies]
52-
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
52+
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
5353

5454
[features]
5555
deny-warnings = []
5656
integration = ["tempfile"]
57+
internal-lints = ["clippy_lints/internal-lints"]

src/tools/clippy/README.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ cargo clippy -- -W clippy::lint_name
182182
```
183183

184184
This also works with lint groups. For example you
185-
can run Clippy with warnings for all lints enabled:
185+
can run Clippy with warnings for all lints enabled:
186186
```terminal
187187
cargo clippy -- -W clippy::pedantic
188188
```
@@ -194,6 +194,33 @@ cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
194194
```
195195
Note that if you've run clippy before, this may only take effect after you've modified a file or ran `cargo clean`.
196196

197+
### Specifying the minimum supported Rust version
198+
199+
Projects that intend to support old versions of Rust can disable lints pertaining to newer features by
200+
specifying the minimum supported Rust version (MSRV) in the clippy configuration file.
201+
202+
```toml
203+
msrv = "1.30.0"
204+
```
205+
206+
The MSRV can also be specified as an inner attribute, like below.
207+
208+
```rust
209+
#![feature(custom_inner_attributes)]
210+
#![clippy::msrv = "1.30.0"]
211+
212+
fn main() {
213+
...
214+
}
215+
```
216+
217+
You can also omit the patch version when specifying the MSRV, so `msrv = 1.30`
218+
is equivalent to `msrv = 1.30.0`.
219+
220+
Note: `custom_inner_attributes` is an unstable feature so it has to be enabled explicitly.
221+
222+
Lints that recognize this configuration option can be found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv)
223+
197224
## Contributing
198225

199226
If you want to contribute to Clippy, you can find more information in [CONTRIBUTING.md](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md).

src/tools/clippy/clippy_dev/src/lib.rs

+23-9
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,30 @@ pub fn gen_deprecated<'a>(lints: impl Iterator<Item = &'a Lint>) -> Vec<String>
146146
}
147147

148148
#[must_use]
149-
pub fn gen_register_lint_list<'a>(lints: impl Iterator<Item = &'a Lint>) -> Vec<String> {
150-
let pre = " store.register_lints(&[".to_string();
151-
let post = " ]);".to_string();
152-
let mut inner = lints
149+
pub fn gen_register_lint_list<'a>(
150+
internal_lints: impl Iterator<Item = &'a Lint>,
151+
usable_lints: impl Iterator<Item = &'a Lint>,
152+
) -> Vec<String> {
153+
let header = " store.register_lints(&[".to_string();
154+
let footer = " ]);".to_string();
155+
let internal_lints = internal_lints
156+
.sorted_by_key(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
157+
.map(|l| {
158+
format!(
159+
" #[cfg(feature = \"internal-lints\")]\n &{}::{},",
160+
l.module,
161+
l.name.to_uppercase()
162+
)
163+
});
164+
let other_lints = usable_lints
165+
.sorted_by_key(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
153166
.map(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
154-
.sorted()
155-
.collect::<Vec<String>>();
156-
inner.insert(0, pre);
157-
inner.push(post);
158-
inner
167+
.sorted();
168+
let mut lint_list = vec![header];
169+
lint_list.extend(internal_lints);
170+
lint_list.extend(other_lints);
171+
lint_list.push(footer);
172+
lint_list
159173
}
160174

161175
/// Gathers all files in `src/clippy_lints` and gathers all lints inside

src/tools/clippy/clippy_dev/src/update_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn run(update_mode: UpdateMode) {
6868
"end register lints",
6969
false,
7070
update_mode == UpdateMode::Change,
71-
|| gen_register_lint_list(usable_lints.iter().chain(internal_lints.iter())),
71+
|| gen_register_lint_list(internal_lints.iter(), usable_lints.iter()),
7272
)
7373
.changed;
7474

src/tools/clippy/clippy_lints/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ smallvec = { version = "1", features = ["union"] }
2828
toml = "0.5.3"
2929
unicode-normalization = "0.1"
3030
semver = "0.11"
31+
rustc-semver="1.1.0"
3132
# NOTE: cargo requires serde feat in its url dep
3233
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>
3334
url = { version = "2.1.0", features = ["serde"] }
@@ -36,3 +37,5 @@ syn = { version = "1", features = ["full"] }
3637

3738
[features]
3839
deny-warnings = []
40+
# build clippy with internal lints enabled, off by default
41+
internal-lints = []

src/tools/clippy/clippy_lints/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::utils::{
55
span_lint_and_sugg, span_lint_and_then, without_block_comments,
66
};
77
use if_chain::if_chain;
8-
use rustc_span::lev_distance::find_best_match_for_name;
98
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
109
use rustc_errors::Applicability;
1110
use rustc_hir::{
@@ -15,6 +14,7 @@ use rustc_lint::{CheckLintNameResult, EarlyContext, EarlyLintPass, LateContext,
1514
use rustc_middle::lint::in_external_macro;
1615
use rustc_middle::ty;
1716
use rustc_session::{declare_lint_pass, declare_tool_lint};
17+
use rustc_span::lev_distance::find_best_match_for_name;
1818
use rustc_span::source_map::Span;
1919
use rustc_span::sym;
2020
use rustc_span::symbol::{Symbol, SymbolStr};

0 commit comments

Comments
 (0)