Skip to content

Commit 9cbaa01

Browse files
committed
Auto merge of rust-lang#123465 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
2 parents 385fa9d + 5d66521 commit 9cbaa01

File tree

445 files changed

+5287
-1946
lines changed

Some content is hidden

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

445 files changed

+5287
-1946
lines changed

Cargo.lock

-14
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ dependencies = [
593593
"syn 2.0.55",
594594
"tempfile",
595595
"termize",
596-
"tester",
597596
"tokio",
598597
"toml 0.7.8",
599598
"ui_test 0.22.2",
@@ -5508,19 +5507,6 @@ dependencies = [
55085507
"std",
55095508
]
55105509

5511-
[[package]]
5512-
name = "tester"
5513-
version = "0.9.1"
5514-
source = "registry+https://github.com/rust-lang/crates.io-index"
5515-
checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f"
5516-
dependencies = [
5517-
"cfg-if",
5518-
"getopts",
5519-
"libc",
5520-
"num_cpus",
5521-
"term",
5522-
]
5523-
55245510
[[package]]
55255511
name = "thin-vec"
55265512
version = "0.2.13"

src/tools/clippy/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Generated by ui-test
2+
rustc-ice-*
3+
14
# Used by CI to be able to push:
25
/.github/deploy_key
36
out

src/tools/clippy/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5379,6 +5379,7 @@ Released 2018-09-13
53795379
[`large_stack_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays
53805380
[`large_stack_frames`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames
53815381
[`large_types_passed_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value
5382+
[`legacy_numeric_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
53825383
[`len_without_is_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
53835384
[`len_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
53845385
[`let_and_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
@@ -5481,6 +5482,7 @@ Released 2018-09-13
54815482
[`missing_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
54825483
[`missing_spin_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_spin_loop
54835484
[`missing_trait_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_trait_methods
5485+
[`missing_transmute_annotations`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations
54845486
[`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes
54855487
[`mixed_attributes_style`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
54865488
[`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals

src/tools/clippy/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ anstream = "0.6.0"
3131

3232
[dev-dependencies]
3333
ui_test = "0.22.2"
34-
tester = "0.9"
3534
regex = "1.5.5"
3635
toml = "0.7.3"
3736
walkdir = "2.3"

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

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@
3232
- [Proposals](development/proposals/README.md)
3333
- [Roadmap 2021](development/proposals/roadmap-2021.md)
3434
- [Syntax Tree Patterns](development/proposals/syntax-tree-patterns.md)
35+
- [The Team](development/the_team.md)

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ $ cargo dev new_lint --name=lint_name --pass=late --category=pedantic
6262
There are two things to note here:
6363

6464
1. `--pass`: We set `--pass=late` in this command to do a late lint pass. The
65-
alternative is an `early` lint pass. We will discuss this difference in a
66-
later chapter.
67-
<!-- FIXME: Link that "later chapter" when lint_passes.md is merged -->
65+
alternative is an `early` lint pass. We will discuss this difference in the
66+
[Lint Passes] chapter.
6867
2. `--category`: If not provided, the `category` of this new lint will default
6968
to `nursery`.
7069

@@ -194,12 +193,12 @@ store.register_late_pass(|_| Box::new(foo_functions::FooFunctions));
194193

195194
As you might have guessed, where there's something late, there is something
196195
early: in Clippy there is a `register_early_pass` method as well. More on early
197-
vs. late passes in a later chapter.
198-
<!-- FIXME: Link that "later chapter" when lint_passes.md is merged -->
196+
vs. late passes in the [Lint Passes] chapter.
199197

200198
Without a call to one of `register_early_pass` or `register_late_pass`, the lint
201199
pass in question will not be run.
202200

203201

204202
[all_lints]: https://rust-lang.github.io/rust-clippy/master/
205203
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
204+
[Lint Passes]: lint_passes.md

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ questions already, but the parser is okay with it. This is what we
5050
mean when we say `EarlyLintPass` deals with only syntax on the AST level.
5151

5252
Alternatively, think of the `foo_functions` lint we mentioned in
53-
define new lints <!-- FIXME: add link --> chapter.
53+
the [Define New Lints](defining_lints.md) chapter.
5454

5555
We want the `foo_functions` lint to detect functions with `foo` as their name.
5656
Writing a lint that only checks for the name of a function means that we only
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# The team
2+
3+
Everyone who contributes to Clippy makes the project what it is. Collaboration
4+
and discussions are the lifeblood of every open-source project. Clippy has a
5+
very flat hierarchy. The teams mainly have additional access rights to the repo.
6+
7+
This document outlines the onboarding process, as well as duties, and access
8+
rights for members of a group.
9+
10+
All regular events mentioned in this chapter are tracked in the [calendar repository].
11+
The calendar file is also available for download: [clippy.ics]
12+
13+
## Everyone
14+
15+
Everyone, including you, is welcome to join discussions and contribute in other
16+
ways, like PRs.
17+
18+
You also have some triage rights, using `@rustbot` to add labels and claim
19+
issues. See [labeling with @rustbot].
20+
21+
A rule for everyone should be to keep a healthy work-life balance. Take a break
22+
when you need one.
23+
24+
## Clippy-Contributors
25+
26+
This is a group of regular contributors to Clippy to help with triaging.
27+
28+
### Duties
29+
30+
This team exists to make contributing easier for regular members. It doesn't
31+
carry any duties that need to be done. However, we want to encourage members of
32+
this group to help with triaging, which can include:
33+
34+
1. **Labeling issues**
35+
36+
For the `good-first-issue` label, it can still be good to use `@rustbot` to
37+
subscribe to the issue and help interested parties, if they post questions
38+
in the comments.
39+
40+
2. **Closing duplicate or resolved issues**
41+
42+
When you manually close an issue, it's often a good idea, to add a short
43+
comment explaining the reason.
44+
45+
3. **Ping people after two weeks of inactivity**
46+
47+
We try to keep issue assignments and PRs fairly up-to-date. After two weeks,
48+
it can be good to send a friendly ping to the delaying party.
49+
50+
You might close a PR with the `I-inactive-closed` label if the author is
51+
busy or wants to abandon it. If the reviewer is busy, the PR can be
52+
reassigned to someone else.
53+
54+
Checkout: https://triage.rust-lang.org/triage/rust-lang/rust-clippy to
55+
monitor PRs.
56+
57+
While not part of their duties, contributors are encouraged to review PRs
58+
and help on Zulip. The team always appreciates help!
59+
60+
### Membership
61+
62+
If you have been contributing to Clippy for some time, we'll probably ask you if
63+
you want to join this team. Members of this team are also welcome to suggest
64+
people who they think would make a great addition to this group.
65+
66+
For this group, there is no direct onboarding process. You're welcome to just
67+
continue what you've been doing. If you like, you can ask for someone to mentor
68+
you, either in the Clippy stream on Zulip or privately via a PM.
69+
70+
If you have been inactive in Clippy for over three months, we'll probably move
71+
you to the alumni group. You're always welcome to come back.
72+
73+
## The Clippy Team
74+
75+
[The Clippy team](https://www.rust-lang.org/governance/teams/dev-tools#Clippy%20team)
76+
is responsible for maintaining Clippy.
77+
78+
### Duties
79+
80+
1. **Respond to PRs in a timely manner**
81+
82+
It's totally fine, if you don't have the time for reviews right now.
83+
You can reassign the PR to a random member by commenting `r? clippy`.
84+
85+
2. **Take a break when you need one**
86+
87+
You are valuable! Clippy wouldn't be what it is without you. So take a break
88+
early and recharge some energy when you need to.
89+
90+
3. **Be responsive on Zulip**
91+
92+
This means in a reasonable time frame, so responding within one or two days
93+
is totally fine.
94+
95+
It's also good, if you answer threads on Zulip and take part in our Clippy
96+
meetings, every two weeks. The meeting dates are tracked in the [calendar repository].
97+
98+
99+
4. **Sync Clippy with the rust-lang/rust repo**
100+
101+
This is done every two weeks, usually by @flip1995.
102+
103+
5. **Update the changelog**
104+
105+
This needs to be done for every release, every six weeks. This is usually
106+
done by @xFrednet.
107+
108+
### Membership
109+
110+
If you have been active for some time, we'll probably reach out and ask
111+
if you want to help with reviews and eventually join the Clippy team.
112+
113+
During the onboarding process, you'll be assigned pull requests to review.
114+
You'll also have an active team member as a mentor who'll stay in contact via
115+
Zulip DMs to provide advice and feedback. If you have questions, you're always
116+
welcome to ask, that is the best way to learn. Once you're done with the review,
117+
you can ping your mentor for a full review and to r+ the PR in both of your names.
118+
119+
When your mentor is confident that you can handle reviews on your own, they'll
120+
start an informal vote among the active team members to officially add you to
121+
the team. This vote is usually accepted unanimously. Then you'll be added to
122+
the team once you've confirmed that you're still interested in joining. The
123+
onboarding phase typically takes a couple of weeks to a few months.
124+
125+
If you have been inactive in Clippy for over three months, we'll probably move
126+
you to the alumni group. You're always welcome to come back.
127+
128+
[calendar repository]: https://github.com/rust-lang/calendar/blob/main/clippy.toml
129+
[clippy.ics]: https://rust-lang.github.io/calendar/clippy.ics
130+
[labeling with @rustbot]: https://forge.rust-lang.org/triagebot/labeling.html

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

+1
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
616616
* [`if_then_some_else_none`](https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none)
617617
* [`index_refutable_slice`](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice)
618618
* [`iter_kv_map`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map)
619+
* [`legacy_numeric_constants`](https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants)
619620
* [`manual_bits`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits)
620621
* [`manual_c_str_literals`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals)
621622
* [`manual_clamp`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp)

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ define_Conf! {
262262
///
263263
/// Suppress lints whenever the suggested change would cause breakage for other crates.
264264
(avoid_breaking_exported_api: bool = true),
265-
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP, MANUAL_C_STR_LITERALS, ASSIGNING_CLONES.
265+
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP, MANUAL_C_STR_LITERALS, ASSIGNING_CLONES, LEGACY_NUMERIC_CONSTANTS.
266266
///
267267
/// The minimum rust version that the project supports. Defaults to the `rust-version` field in `Cargo.toml`
268268
#[default_text = ""]
@@ -856,11 +856,6 @@ mod tests {
856856
}
857857
}
858858

859-
assert!(
860-
names.remove("allow-one-hash-in-raw-strings"),
861-
"remove this when #11481 is fixed"
862-
);
863-
864859
assert!(
865860
names.is_empty(),
866861
"Configuration variable lacks test: {names:?}\nAdd a test to `tests/ui-toml`"

src/tools/clippy/clippy_config/src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#![feature(rustc_private, let_chains)]
22
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
3-
#![warn(rust_2018_idioms, unused_lifetimes)]
3+
#![warn(
4+
trivial_casts,
5+
trivial_numeric_casts,
6+
rust_2018_idioms,
7+
unused_lifetimes,
8+
unused_qualifications
9+
)]
410
#![allow(
511
clippy::must_use_candidate,
612
clippy::missing_panics_doc,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ msrv_aliases! {
3636
1,47,0 { TAU, IS_ASCII_DIGIT_CONST, ARRAY_IMPL_ANY_LEN }
3737
1,46,0 { CONST_IF_MATCH }
3838
1,45,0 { STR_STRIP_PREFIX }
39-
1,43,0 { LOG2_10, LOG10_2 }
39+
1,43,0 { LOG2_10, LOG10_2, NUMERIC_ASSOCIATED_CONSTANTS }
4040
1,42,0 { MATCHES_MACRO, SLICE_PATTERNS, PTR_SLICE_RAW_PARTS }
4141
1,41,0 { RE_REBALANCING_COHERENCE, RESULT_MAP_OR_ELSE }
4242
1,40,0 { MEM_TAKE, NON_EXHAUSTIVE, OPTION_AS_DEREF }

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
#![feature(let_chains)]
33
#![feature(rustc_private)]
44
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
5-
// warn on lints, that are included in `rust-lang/rust`s bootstrap
6-
#![warn(rust_2018_idioms, unused_lifetimes)]
5+
#![warn(
6+
trivial_casts,
7+
trivial_numeric_casts,
8+
rust_2018_idioms,
9+
unused_lifetimes,
10+
unused_qualifications
11+
)]
712

813
// The `rustc_driver` crate seems to be required in order to use the `rust_lexer` crate.
914
#[allow(unused_extern_crates)]

src/tools/clippy/clippy_dev/src/lint.rs

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
2020
.args(["--edition", "2021"])
2121
.arg(path)
2222
.args(args)
23+
// Prevent rustc from creating `rustc-ice-*` files the console output is enough.
24+
.env("RUSTC_ICE", "0")
2325
.status(),
2426
);
2527
} else {
@@ -32,6 +34,8 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
3234
let status = Command::new(cargo_clippy_path())
3335
.arg("clippy")
3436
.args(args)
37+
// Prevent rustc from creating `rustc-ice-*` files the console output is enough.
38+
.env("RUSTC_ICE", "0")
3539
.current_dir(path)
3640
.status();
3741

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ fn replace_region_in_text<'a>(
992992
}
993993

994994
fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
995-
match fs::OpenOptions::new().create_new(true).write(true).open(new_name) {
995+
match OpenOptions::new().create_new(true).write(true).open(new_name) {
996996
Ok(file) => drop(file),
997997
Err(e) if matches!(e.kind(), io::ErrorKind::AlreadyExists | io::ErrorKind::NotFound) => return false,
998998
Err(e) => panic_file(e, new_name, "create"),
@@ -1016,7 +1016,7 @@ fn panic_file(error: io::Error, name: &Path, action: &str) -> ! {
10161016
}
10171017

10181018
fn rewrite_file(path: &Path, f: impl FnOnce(&str) -> Option<String>) {
1019-
let mut file = fs::OpenOptions::new()
1019+
let mut file = OpenOptions::new()
10201020
.write(true)
10211021
.read(true)
10221022
.open(path)

src/tools/clippy/clippy_lints/src/approx_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl ApproxConstant {
9595
cx,
9696
APPROX_CONSTANT,
9797
e.span,
98-
&format!("approximate value of `{module}::consts::{}` found", &name),
98+
format!("approximate value of `{module}::consts::{}` found", &name),
9999
None,
100100
"consider using the constant directly",
101101
);

src/tools/clippy/clippy_lints/src/asm_syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ fn check_asm_syntax(
5353
cx,
5454
lint,
5555
span,
56-
&format!("{style} x86 assembly syntax used"),
56+
format!("{style} x86 assembly syntax used"),
5757
None,
58-
&format!("use {} x86 assembly syntax", !style),
58+
format!("use {} x86 assembly syntax", !style),
5959
);
6060
}
6161
}

src/tools/clippy/clippy_lints/src/assertions_on_constants.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
5858
cx,
5959
ASSERTIONS_ON_CONSTANTS,
6060
macro_call.span,
61-
&format!(
61+
format!(
6262
"`{}!(true)` will be optimized out by the compiler",
6363
cx.tcx.item_name(macro_call.def_id)
6464
),
@@ -74,9 +74,9 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
7474
cx,
7575
ASSERTIONS_ON_CONSTANTS,
7676
macro_call.span,
77-
&format!("`assert!(false{assert_arg})` should probably be replaced"),
77+
format!("`assert!(false{assert_arg})` should probably be replaced"),
7878
None,
79-
&format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"),
79+
format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"),
8080
);
8181
}
8282
}

0 commit comments

Comments
 (0)