Skip to content

Commit 758f196

Browse files
committed
Auto merge of rust-lang#103337 - flip1995:clippyup, r=Manishearth
Update Clippy r? `@Manishearth`
2 parents c07a6a9 + da9755b commit 758f196

File tree

284 files changed

+8511
-4206
lines changed

Some content is hidden

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

284 files changed

+8511
-4206
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ env:
2525
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
2626
NO_FMT_TEST: 1
2727
CARGO_INCREMENTAL: 0
28+
CARGO_UNSTABLE_SPARSE_REGISTRY: true
2829

2930
jobs:
3031
base:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
1212
NO_FMT_TEST: 1
1313
CARGO_INCREMENTAL: 0
14+
CARGO_UNSTABLE_SPARSE_REGISTRY: true
1415

1516
defaults:
1617
run:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515

1616
env:
1717
RUST_BACKTRACE: 1
18+
CARGO_INCREMENTAL: 0
19+
CARGO_UNSTABLE_SPARSE_REGISTRY: true
1820

1921
jobs:
2022
clippy_dev:

src/tools/clippy/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3735,6 +3735,7 @@ Released 2018-09-13
37353735
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
37363736
[`arithmetic_side_effects`]: https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects
37373737
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
3738+
[`as_ptr_cast_mut`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_ptr_cast_mut
37383739
[`as_underscore`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore
37393740
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
37403741
[`assertions_on_result_states`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states
@@ -3772,6 +3773,7 @@ Released 2018-09-13
37723773
[`cast_enum_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_enum_constructor
37733774
[`cast_enum_truncation`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_enum_truncation
37743775
[`cast_lossless`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
3776+
[`cast_nan_to_int`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_nan_to_int
37753777
[`cast_possible_truncation`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
37763778
[`cast_possible_wrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_wrap
37773779
[`cast_precision_loss`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
@@ -3988,6 +3990,7 @@ Released 2018-09-13
39883990
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
39893991
[`manual_bits`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits
39903992
[`manual_clamp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
3993+
[`manual_filter`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter
39913994
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
39923995
[`manual_find`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find
39933996
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
@@ -4046,6 +4049,7 @@ Released 2018-09-13
40464049
[`missing_panics_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
40474050
[`missing_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
40484051
[`missing_spin_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_spin_loop
4052+
[`missing_trait_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_trait_methods
40494053
[`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes
40504054
[`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals
40514055
[`mixed_read_write_in_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_read_write_in_expression
@@ -4131,6 +4135,7 @@ Released 2018-09-13
41314135
[`panic_in_result_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_in_result_fn
41324136
[`panic_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_params
41334137
[`panicking_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_unwrap
4138+
[`partial_pub_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#partial_pub_fields
41344139
[`partialeq_ne_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl
41354140
[`partialeq_to_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_to_none
41364141
[`path_buf_push_overwrite`]: https://rust-lang.github.io/rust-clippy/master/index.html#path_buf_push_overwrite
@@ -4312,6 +4317,7 @@ Released 2018-09-13
43124317
[`unstable_as_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_slice
43134318
[`unused_async`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_async
43144319
[`unused_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_collect
4320+
[`unused_format_specs`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_format_specs
43154321
[`unused_io_amount`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount
43164322
[`unused_label`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_label
43174323
[`unused_peekable`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_peekable

src/tools/clippy/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ All contributors are expected to follow the [Rust Code of Conduct].
2929

3030
## The Clippy book
3131

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

3535
[Clippy book]: https://doc.rust-lang.org/nightly/clippy/index.html

src/tools/clippy/book/src/development/adding_lints.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,27 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
478478
```
479479

480480
Once the `msrv` is added to the lint, a relevant test case should be added to
481-
`tests/ui/min_rust_version_attr.rs` which verifies that the lint isn't emitted
482-
if the project's MSRV is lower.
481+
the lint's test file, `tests/ui/manual_strip.rs` in this example. It should
482+
have a case for the version below the MSRV and one with the same contents but
483+
for the MSRV version itself.
484+
485+
```rust
486+
#![feature(custom_inner_attributes)]
487+
488+
...
489+
490+
fn msrv_1_44() {
491+
#![clippy::msrv = "1.44"]
492+
493+
/* something that would trigger the lint */
494+
}
495+
496+
fn msrv_1_45() {
497+
#![clippy::msrv = "1.45"]
498+
499+
/* something that would trigger the lint */
500+
}
501+
```
483502

484503
As a last step, the lint should be added to the lint documentation. This is done
485504
in `clippy_lints/src/utils/conf.rs`:

src/tools/clippy/book/src/development/basics.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ the reference file with:
6969
cargo dev bless
7070
```
7171

72-
For example, this is necessary, if you fix a typo in an error message of a lint
72+
For example, this is necessary if you fix a typo in an error message of a lint,
7373
or if you modify a test file to add a test case.
7474

7575
> _Note:_ This command may update more files than you intended. In that case
@@ -101,8 +101,9 @@ cargo dev setup intellij
101101
cargo dev dogfood
102102
```
103103

104-
More about intellij command usage and reasons
105-
[here](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#intellij-rust)
104+
More about [intellij] command usage and reasons.
105+
106+
[intellij]: https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#intellij-rust
106107

107108
## lintcheck
108109

src/tools/clippy/clippy_dev/src/serve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn mtime(path: impl AsRef<Path>) -> SystemTime {
4949
.into_iter()
5050
.flatten()
5151
.flatten()
52-
.map(|entry| mtime(&entry.path()))
52+
.map(|entry| mtime(entry.path()))
5353
.max()
5454
.unwrap_or(SystemTime::UNIX_EPOCH)
5555
} else {

src/tools/clippy/clippy_dev/src/setup/intellij.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ impl ClippyProjectInfo {
3636
}
3737

3838
pub fn setup_rustc_src(rustc_path: &str) {
39-
let rustc_source_dir = match check_and_get_rustc_dir(rustc_path) {
40-
Ok(path) => path,
41-
Err(_) => return,
39+
let Ok(rustc_source_dir) = check_and_get_rustc_dir(rustc_path) else {
40+
return
4241
};
4342

4443
for project in CLIPPY_PROJECTS {
@@ -172,24 +171,18 @@ pub fn remove_rustc_src() {
172171
}
173172

174173
fn remove_rustc_src_from_project(project: &ClippyProjectInfo) -> bool {
175-
let mut cargo_content = if let Ok(content) = read_project_file(project.cargo_file) {
176-
content
177-
} else {
174+
let Ok(mut cargo_content) = read_project_file(project.cargo_file) else {
178175
return false;
179176
};
180-
let section_start = if let Some(section_start) = cargo_content.find(RUSTC_PATH_SECTION) {
181-
section_start
182-
} else {
177+
let Some(section_start) = cargo_content.find(RUSTC_PATH_SECTION) else {
183178
println!(
184179
"info: dependencies could not be found in `{}` for {}, skipping file",
185180
project.cargo_file, project.name
186181
);
187182
return true;
188183
};
189184

190-
let end_point = if let Some(end_point) = cargo_content.find(DEPENDENCIES_SECTION) {
191-
end_point
192-
} else {
185+
let Some(end_point) = cargo_content.find(DEPENDENCIES_SECTION) else {
193186
eprintln!(
194187
"error: the end of the rustc dependencies section could not be found in `{}`",
195188
project.cargo_file

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn generate_lint_files(
128128
for (lint_group, lints) in Lint::by_lint_group(usable_lints.into_iter().chain(internal_lints)) {
129129
let content = gen_lint_group_list(&lint_group, lints.iter());
130130
process_file(
131-
&format!("clippy_lints/src/lib.register_{lint_group}.rs"),
131+
format!("clippy_lints/src/lib.register_{lint_group}.rs"),
132132
update_mode,
133133
&content,
134134
);
@@ -869,13 +869,11 @@ fn clippy_lints_src_files() -> impl Iterator<Item = (PathBuf, DirEntry)> {
869869
macro_rules! match_tokens {
870870
($iter:ident, $($token:ident $({$($fields:tt)*})? $(($capture:ident))?)*) => {
871871
{
872-
$($(let $capture =)? if let Some(LintDeclSearchResult {
872+
$(#[allow(clippy::redundant_pattern)] let Some(LintDeclSearchResult {
873873
token_kind: TokenKind::$token $({$($fields)*})?,
874-
content: _x,
874+
content: $($capture @)? _,
875875
..
876-
}) = $iter.next() {
877-
_x
878-
} else {
876+
}) = $iter.next() else {
879877
continue;
880878
};)*
881879
#[allow(clippy::unused_unit)]

0 commit comments

Comments
 (0)