Skip to content

Commit 4d31ed4

Browse files
committed
Auto merge of #119856 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
2 parents 062e7c6 + af39354 commit 4d31ed4

File tree

157 files changed

+5166
-819
lines changed

Some content is hidden

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

157 files changed

+5166
-819
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
github_token: "${{ secrets.github_token }}"
3939

4040
- name: Checkout
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
4242

4343
- name: Install toolchain
4444
run: rustup show active-toolchain

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
github_token: "${{ secrets.github_token }}"
2727

2828
- name: Checkout
29-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
3030
with:
3131
ref: ${{ github.ref }}
3232

@@ -72,7 +72,7 @@ jobs:
7272
github_token: "${{ secrets.github_token }}"
7373

7474
- name: Checkout
75-
uses: actions/checkout@v3
75+
uses: actions/checkout@v4
7676

7777
- name: Install i686 dependencies
7878
if: matrix.host == 'i686-unknown-linux-gnu'
@@ -151,7 +151,7 @@ jobs:
151151
github_token: "${{ secrets.github_token }}"
152152

153153
- name: Checkout
154-
uses: actions/checkout@v3
154+
uses: actions/checkout@v4
155155

156156
- name: Install toolchain
157157
run: rustup show active-toolchain
@@ -175,7 +175,7 @@ jobs:
175175
github_token: "${{ secrets.github_token }}"
176176

177177
- name: Checkout
178-
uses: actions/checkout@v3
178+
uses: actions/checkout@v4
179179

180180
- name: Install toolchain
181181
run: rustup show active-toolchain
@@ -231,7 +231,7 @@ jobs:
231231
github_token: "${{ secrets.github_token }}"
232232

233233
- name: Checkout
234-
uses: actions/checkout@v3
234+
uses: actions/checkout@v4
235235

236236
- name: Install toolchain
237237
run: rustup show active-toolchain

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
# Setup
2626
- name: Checkout
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

2929
# Run
3030
- name: Build

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
steps:
2222
# Setup
2323
- name: Checkout
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- name: Checkout
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828
with:
2929
ref: ${{ env.TARGET_BRANCH }}
3030
path: 'out'

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
# Setup
1818
- name: Checkout
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020

2121
- name: Setup Node.js
2222
uses: actions/setup-node@v3

src/tools/clippy/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5105,6 +5105,7 @@ Released 2018-09-13
51055105
[`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
51065106
[`empty_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drop
51075107
[`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum
5108+
[`empty_enum_variants_with_brackets`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum_variants_with_brackets
51085109
[`empty_line_after_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
51095110
[`empty_line_after_outer_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
51105111
[`empty_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop
@@ -5294,6 +5295,7 @@ Released 2018-09-13
52945295
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
52955296
[`manual_is_finite`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_finite
52965297
[`manual_is_infinite`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_infinite
5298+
[`manual_is_variant_and`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_variant_and
52975299
[`manual_let_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
52985300
[`manual_main_separator_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_main_separator_str
52995301
[`manual_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
@@ -5440,6 +5442,7 @@ Released 2018-09-13
54405442
[`only_used_in_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#only_used_in_recursion
54415443
[`op_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
54425444
[`option_and_then_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_and_then_some
5445+
[`option_as_ref_cloned`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_cloned
54435446
[`option_as_ref_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref
54445447
[`option_env_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_env_unwrap
54455448
[`option_expect_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#option_expect_used
@@ -5483,6 +5486,7 @@ Released 2018-09-13
54835486
[`ptr_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
54845487
[`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
54855488
[`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
5489+
[`pub_underscore_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_underscore_fields
54865490
[`pub_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_use
54875491
[`pub_with_shorthand`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_with_shorthand
54885492
[`pub_without_shorthand`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_without_shorthand
@@ -5580,6 +5584,7 @@ Released 2018-09-13
55805584
[`stable_sort_primitive`]: https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
55815585
[`std_instead_of_alloc`]: https://rust-lang.github.io/rust-clippy/master/index.html#std_instead_of_alloc
55825586
[`std_instead_of_core`]: https://rust-lang.github.io/rust-clippy/master/index.html#std_instead_of_core
5587+
[`str_split_at_newline`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_split_at_newline
55835588
[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
55845589
[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
55855590
[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign
@@ -5612,6 +5617,7 @@ Released 2018-09-13
56125617
[`temporary_cstring_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_cstring_as_ptr
56135618
[`test_attr_in_doctest`]: https://rust-lang.github.io/rust-clippy/master/index.html#test_attr_in_doctest
56145619
[`tests_outside_test_module`]: https://rust-lang.github.io/rust-clippy/master/index.html#tests_outside_test_module
5620+
[`thread_local_initializer_can_be_made_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
56155621
[`to_digit_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_digit_is_some
56165622
[`to_string_in_display`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_display
56175623
[`to_string_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
@@ -5810,4 +5816,5 @@ Released 2018-09-13
58105816
[`allowed-dotfiles`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-dotfiles
58115817
[`enforce-iter-loop-reborrow`]: https://doc.rust-lang.org/clippy/lint_configuration.html#enforce-iter-loop-reborrow
58125818
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
5819+
[`pub-underscore-fields-behavior`]: https://doc.rust-lang.org/clippy/lint_configuration.html#pub-underscore-fields-behavior
58135820
<!-- end autogenerated links to configuration documentation -->

src/tools/clippy/COPYRIGHT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REUSE-IgnoreStart
22

3-
Copyright 2014-2022 The Rust Project Developers
3+
Copyright 2014-2024 The Rust Project Developers
44

55
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
66
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license

src/tools/clippy/LICENSE-APACHE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2014-2022 The Rust Project Developers
189+
Copyright 2014-2024 The Rust Project Developers
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

src/tools/clippy/LICENSE-MIT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2014-2022 The Rust Project Developers
3+
Copyright (c) 2014-2024 The Rust Project Developers
44

55
Permission is hereby granted, free of charge, to any
66
person obtaining a copy of this software and associated

src/tools/clippy/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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 650 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
8+
[There are over 700 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.
@@ -278,7 +278,7 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT
278278

279279
<!-- REUSE-IgnoreStart -->
280280

281-
Copyright 2014-2023 The Rust Project Developers
281+
Copyright 2014-2024 The Rust Project Developers
282282

283283
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
284284
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license

src/tools/clippy/book/src/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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 650 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are over 700 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

src/tools/clippy/book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Clippy's Lints](lints.md)
1010
- [Continuous Integration](continuous_integration/README.md)
1111
- [GitHub Actions](continuous_integration/github_actions.md)
12+
- [GitLab CI](continuous_integration/gitlab.md)
1213
- [Travis CI](continuous_integration/travis.md)
1314
- [Development](development/README.md)
1415
- [Basics](development/basics.md)

src/tools/clippy/book/src/continuous_integration/github_actions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
clippy_check:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
- name: Run Clippy
2020
run: cargo clippy --all-targets --all-features
2121
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# GitLab CI
2+
3+
You can add Clippy to GitLab CI by using the latest stable [rust docker image](https://hub.docker.com/_/rust),
4+
as it is shown in the `.gitlab-ci.yml` CI configuration file below,
5+
6+
```yml
7+
# Make sure CI fails on all warnings, including Clippy lints
8+
variables:
9+
RUSTFLAGS: "-Dwarnings"
10+
11+
clippy_check:
12+
image: rust:latest
13+
script:
14+
- rustup component add clippy
15+
- cargo clippy --all-targets --all-features
16+
```

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ let x: Option<u32> = Some(42);
102102
m!(x, x.unwrap());
103103
```
104104

105-
If the `m!(x, x.unwrapp());` line is expanded, we would get two expanded
105+
If the `m!(x, x.unwrap());` line is expanded, we would get two expanded
106106
expressions:
107107

108108
- `x.is_some()` (from the `$a.is_some()` line in the `m` macro)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ in this chapter:
133133
- [Type checking](https://rustc-dev-guide.rust-lang.org/type-checking.html)
134134
- [Ty module](https://rustc-dev-guide.rust-lang.org/ty.html)
135135

136-
[Adt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/sty/enum.TyKind.html#variant.Adt
136+
[Adt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/ty_kind/enum.TyKind.html#variant.Adt
137137
[AdtDef]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/adt/struct.AdtDef.html
138138
[expr_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html#method.expr_ty
139139
[node_type]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html#method.node_type
@@ -144,7 +144,7 @@ in this chapter:
144144
[LateLintPass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html
145145
[pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/typeck_results/struct.TypeckResults.html#method.pat_ty
146146
[Ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html
147-
[TyKind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/sty/enum.TyKind.html
147+
[TyKind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/ty_kind/enum.TyKind.html
148148
[TypeckResults]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html
149149
[middle_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/ty/struct.Ty.html
150150
[hir_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_hir/struct.Ty.html

src/tools/clippy/book/src/lint_configuration.md

+10
Original file line numberDiff line numberDiff line change
@@ -805,3 +805,13 @@ for _ in &mut *rmvec {}
805805
* [`missing_errors_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc)
806806

807807

808+
## `pub-underscore-fields-behavior`
809+
810+
811+
**Default Value:** `"PublicallyExported"`
812+
813+
---
814+
**Affected lints:**
815+
* [`pub_underscore_fields`](https://rust-lang.github.io/rust-clippy/master/index.html#pub_underscore_fields)
816+
817+

src/tools/clippy/clippy_config/src/conf.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::msrvs::Msrv;
2-
use crate::types::{DisallowedPath, MacroMatcher, MatchLintBehaviour, Rename};
2+
use crate::types::{DisallowedPath, MacroMatcher, MatchLintBehaviour, PubUnderscoreFieldsBehaviour, Rename};
33
use crate::ClippyConfiguration;
44
use rustc_data_structures::fx::FxHashSet;
55
use rustc_session::Session;
@@ -547,6 +547,11 @@ define_Conf! {
547547
///
548548
/// Whether to also run the listed lints on private items.
549549
(check_private_items: bool = false),
550+
/// Lint: PUB_UNDERSCORE_FIELDS
551+
///
552+
/// Lint "public" fields in a struct that are prefixed with an underscore based on their
553+
/// exported visibility, or whether they are marked as "pub".
554+
(pub_underscore_fields_behavior: PubUnderscoreFieldsBehaviour = PubUnderscoreFieldsBehaviour::PublicallyExported),
550555
}
551556

552557
/// Search for the configuration file.

src/tools/clippy/clippy_config/src/metadata.rs

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ fn parse_config_field_doc(doc_comment: &str) -> Option<(Vec<String>, String)> {
9696
doc_comment.make_ascii_lowercase();
9797
let lints: Vec<String> = doc_comment
9898
.split_off(DOC_START.len())
99+
.lines()
100+
.next()
101+
.unwrap()
99102
.split(", ")
100103
.map(str::to_string)
101104
.collect();

src/tools/clippy/clippy_config/src/msrvs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! msrv_aliases {
1717
// names may refer to stabilized feature flags or library items
1818
msrv_aliases! {
1919
1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE }
20-
1,70,0 { OPTION_IS_SOME_AND, BINARY_HEAP_RETAIN }
20+
1,70,0 { OPTION_RESULT_IS_VARIANT_AND, BINARY_HEAP_RETAIN }
2121
1,68,0 { PATH_MAIN_SEPARATOR_STR }
2222
1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS }
2323
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }

src/tools/clippy/clippy_config/src/types.rs

+6
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,9 @@ unimplemented_serialize! {
126126
Rename,
127127
MacroMatcher,
128128
}
129+
130+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
131+
pub enum PubUnderscoreFieldsBehaviour {
132+
PublicallyExported,
133+
AllPubFields,
134+
}

src/tools/clippy/clippy_dev/src/new_lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn create(
6767
if pass == "early" {
6868
println!(
6969
"\n\
70-
NOTE: Use a late pass unless you need something specific from\
70+
NOTE: Use a late pass unless you need something specific from\n\
7171
an early pass, as they lack many features and utilities"
7272
);
7373
}

0 commit comments

Comments
 (0)