Skip to content

Commit

Permalink
Auto merge of rust-lang#123465 - flip1995:clippy-subtree-update, r=Ma…
Browse files Browse the repository at this point in the history
…nishearth

Clippy subtree update

r? `@Manishearth`
  • Loading branch information
bors committed Apr 5, 2024
2 parents 385fa9d + 5d66521 commit 9cbaa01
Show file tree
Hide file tree
Showing 445 changed files with 5,287 additions and 1,946 deletions.
14 changes: 0 additions & 14 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ dependencies = [
"syn 2.0.55",
"tempfile",
"termize",
"tester",
"tokio",
"toml 0.7.8",
"ui_test 0.22.2",
Expand Down Expand Up @@ -5508,19 +5507,6 @@ dependencies = [
"std",
]

[[package]]
name = "tester"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f"
dependencies = [
"cfg-if",
"getopts",
"libc",
"num_cpus",
"term",
]

[[package]]
name = "thin-vec"
version = "0.2.13"
Expand Down
3 changes: 3 additions & 0 deletions src/tools/clippy/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Generated by ui-test
rustc-ice-*

# Used by CI to be able to push:
/.github/deploy_key
out
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5379,6 +5379,7 @@ Released 2018-09-13
[`large_stack_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays
[`large_stack_frames`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames
[`large_types_passed_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value
[`legacy_numeric_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
[`len_without_is_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
[`len_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
[`let_and_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
Expand Down Expand Up @@ -5481,6 +5482,7 @@ Released 2018-09-13
[`missing_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
[`missing_spin_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_spin_loop
[`missing_trait_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_trait_methods
[`missing_transmute_annotations`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations
[`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes
[`mixed_attributes_style`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_attributes_style
[`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ anstream = "0.6.0"

[dev-dependencies]
ui_test = "0.22.2"
tester = "0.9"
regex = "1.5.5"
toml = "0.7.3"
walkdir = "2.3"
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
- [Proposals](development/proposals/README.md)
- [Roadmap 2021](development/proposals/roadmap-2021.md)
- [Syntax Tree Patterns](development/proposals/syntax-tree-patterns.md)
- [The Team](development/the_team.md)
9 changes: 4 additions & 5 deletions src/tools/clippy/book/src/development/defining_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ $ cargo dev new_lint --name=lint_name --pass=late --category=pedantic
There are two things to note here:

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

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

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

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


[all_lints]: https://rust-lang.github.io/rust-clippy/master/
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
[Lint Passes]: lint_passes.md
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/development/lint_passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ questions already, but the parser is okay with it. This is what we
mean when we say `EarlyLintPass` deals with only syntax on the AST level.

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

We want the `foo_functions` lint to detect functions with `foo` as their name.
Writing a lint that only checks for the name of a function means that we only
Expand Down
130 changes: 130 additions & 0 deletions src/tools/clippy/book/src/development/the_team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# The team

Everyone who contributes to Clippy makes the project what it is. Collaboration
and discussions are the lifeblood of every open-source project. Clippy has a
very flat hierarchy. The teams mainly have additional access rights to the repo.

This document outlines the onboarding process, as well as duties, and access
rights for members of a group.

All regular events mentioned in this chapter are tracked in the [calendar repository].
The calendar file is also available for download: [clippy.ics]

## Everyone

Everyone, including you, is welcome to join discussions and contribute in other
ways, like PRs.

You also have some triage rights, using `@rustbot` to add labels and claim
issues. See [labeling with @rustbot].

A rule for everyone should be to keep a healthy work-life balance. Take a break
when you need one.

## Clippy-Contributors

This is a group of regular contributors to Clippy to help with triaging.

### Duties

This team exists to make contributing easier for regular members. It doesn't
carry any duties that need to be done. However, we want to encourage members of
this group to help with triaging, which can include:

1. **Labeling issues**

For the `good-first-issue` label, it can still be good to use `@rustbot` to
subscribe to the issue and help interested parties, if they post questions
in the comments.

2. **Closing duplicate or resolved issues**

When you manually close an issue, it's often a good idea, to add a short
comment explaining the reason.

3. **Ping people after two weeks of inactivity**

We try to keep issue assignments and PRs fairly up-to-date. After two weeks,
it can be good to send a friendly ping to the delaying party.

You might close a PR with the `I-inactive-closed` label if the author is
busy or wants to abandon it. If the reviewer is busy, the PR can be
reassigned to someone else.

Checkout: https://triage.rust-lang.org/triage/rust-lang/rust-clippy to
monitor PRs.

While not part of their duties, contributors are encouraged to review PRs
and help on Zulip. The team always appreciates help!

### Membership

If you have been contributing to Clippy for some time, we'll probably ask you if
you want to join this team. Members of this team are also welcome to suggest
people who they think would make a great addition to this group.

For this group, there is no direct onboarding process. You're welcome to just
continue what you've been doing. If you like, you can ask for someone to mentor
you, either in the Clippy stream on Zulip or privately via a PM.

If you have been inactive in Clippy for over three months, we'll probably move
you to the alumni group. You're always welcome to come back.

## The Clippy Team

[The Clippy team](https://www.rust-lang.org/governance/teams/dev-tools#Clippy%20team)
is responsible for maintaining Clippy.

### Duties

1. **Respond to PRs in a timely manner**

It's totally fine, if you don't have the time for reviews right now.
You can reassign the PR to a random member by commenting `r? clippy`.

2. **Take a break when you need one**

You are valuable! Clippy wouldn't be what it is without you. So take a break
early and recharge some energy when you need to.

3. **Be responsive on Zulip**

This means in a reasonable time frame, so responding within one or two days
is totally fine.

It's also good, if you answer threads on Zulip and take part in our Clippy
meetings, every two weeks. The meeting dates are tracked in the [calendar repository].


4. **Sync Clippy with the rust-lang/rust repo**

This is done every two weeks, usually by @flip1995.

5. **Update the changelog**

This needs to be done for every release, every six weeks. This is usually
done by @xFrednet.

### Membership

If you have been active for some time, we'll probably reach out and ask
if you want to help with reviews and eventually join the Clippy team.

During the onboarding process, you'll be assigned pull requests to review.
You'll also have an active team member as a mentor who'll stay in contact via
Zulip DMs to provide advice and feedback. If you have questions, you're always
welcome to ask, that is the best way to learn. Once you're done with the review,
you can ping your mentor for a full review and to r+ the PR in both of your names.

When your mentor is confident that you can handle reviews on your own, they'll
start an informal vote among the active team members to officially add you to
the team. This vote is usually accepted unanimously. Then you'll be added to
the team once you've confirmed that you're still interested in joining. The
onboarding phase typically takes a couple of weeks to a few months.

If you have been inactive in Clippy for over three months, we'll probably move
you to the alumni group. You're always welcome to come back.

[calendar repository]: https://github.com/rust-lang/calendar/blob/main/clippy.toml
[clippy.ics]: https://rust-lang.github.io/calendar/clippy.ics
[labeling with @rustbot]: https://forge.rust-lang.org/triagebot/labeling.html
1 change: 1 addition & 0 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
* [`if_then_some_else_none`](https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none)
* [`index_refutable_slice`](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice)
* [`iter_kv_map`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map)
* [`legacy_numeric_constants`](https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants)
* [`manual_bits`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits)
* [`manual_c_str_literals`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_c_str_literals)
* [`manual_clamp`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp)
Expand Down
7 changes: 1 addition & 6 deletions src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ define_Conf! {
///
/// Suppress lints whenever the suggested change would cause breakage for other crates.
(avoid_breaking_exported_api: bool = true),
/// 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.
/// 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.
///
/// The minimum rust version that the project supports. Defaults to the `rust-version` field in `Cargo.toml`
#[default_text = ""]
Expand Down Expand Up @@ -856,11 +856,6 @@ mod tests {
}
}

assert!(
names.remove("allow-one-hash-in-raw-strings"),
"remove this when #11481 is fixed"
);

assert!(
names.is_empty(),
"Configuration variable lacks test: {names:?}\nAdd a test to `tests/ui-toml`"
Expand Down
8 changes: 7 additions & 1 deletion src/tools/clippy/clippy_config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#![feature(rustc_private, let_chains)]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![warn(rust_2018_idioms, unused_lifetimes)]
#![warn(
trivial_casts,
trivial_numeric_casts,
rust_2018_idioms,
unused_lifetimes,
unused_qualifications
)]
#![allow(
clippy::must_use_candidate,
clippy::missing_panics_doc,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_config/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ msrv_aliases! {
1,47,0 { TAU, IS_ASCII_DIGIT_CONST, ARRAY_IMPL_ANY_LEN }
1,46,0 { CONST_IF_MATCH }
1,45,0 { STR_STRIP_PREFIX }
1,43,0 { LOG2_10, LOG10_2 }
1,43,0 { LOG2_10, LOG10_2, NUMERIC_ASSOCIATED_CONSTANTS }
1,42,0 { MATCHES_MACRO, SLICE_PATTERNS, PTR_SLICE_RAW_PARTS }
1,41,0 { RE_REBALANCING_COHERENCE, RESULT_MAP_OR_ELSE }
1,40,0 { MEM_TAKE, NON_EXHAUSTIVE, OPTION_AS_DEREF }
Expand Down
9 changes: 7 additions & 2 deletions src/tools/clippy/clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
#![feature(let_chains)]
#![feature(rustc_private)]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
// warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)]
#![warn(
trivial_casts,
trivial_numeric_casts,
rust_2018_idioms,
unused_lifetimes,
unused_qualifications
)]

// The `rustc_driver` crate seems to be required in order to use the `rust_lexer` crate.
#[allow(unused_extern_crates)]
Expand Down
4 changes: 4 additions & 0 deletions src/tools/clippy/clippy_dev/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
.args(["--edition", "2021"])
.arg(path)
.args(args)
// Prevent rustc from creating `rustc-ice-*` files the console output is enough.
.env("RUSTC_ICE", "0")
.status(),
);
} else {
Expand All @@ -32,6 +34,8 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
let status = Command::new(cargo_clippy_path())
.arg("clippy")
.args(args)
// Prevent rustc from creating `rustc-ice-*` files the console output is enough.
.env("RUSTC_ICE", "0")
.current_dir(path)
.status();

Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_dev/src/update_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ fn replace_region_in_text<'a>(
}

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

fn rewrite_file(path: &Path, f: impl FnOnce(&str) -> Option<String>) {
let mut file = fs::OpenOptions::new()
let mut file = OpenOptions::new()
.write(true)
.read(true)
.open(path)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl ApproxConstant {
cx,
APPROX_CONSTANT,
e.span,
&format!("approximate value of `{module}::consts::{}` found", &name),
format!("approximate value of `{module}::consts::{}` found", &name),
None,
"consider using the constant directly",
);
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/asm_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ fn check_asm_syntax(
cx,
lint,
span,
&format!("{style} x86 assembly syntax used"),
format!("{style} x86 assembly syntax used"),
None,
&format!("use {} x86 assembly syntax", !style),
format!("use {} x86 assembly syntax", !style),
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
cx,
ASSERTIONS_ON_CONSTANTS,
macro_call.span,
&format!(
format!(
"`{}!(true)` will be optimized out by the compiler",
cx.tcx.item_name(macro_call.def_id)
),
Expand All @@ -74,9 +74,9 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
cx,
ASSERTIONS_ON_CONSTANTS,
macro_call.span,
&format!("`assert!(false{assert_arg})` should probably be replaced"),
format!("`assert!(false{assert_arg})` should probably be replaced"),
None,
&format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"),
format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"),
);
}
}
Expand Down

0 comments on commit 9cbaa01

Please sign in to comment.