Skip to content

Commit 35d0443

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rustup
2 parents 708ffd5 + 8050e59 commit 35d0443

File tree

154 files changed

+3168
-851
lines changed

Some content is hidden

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

154 files changed

+3168
-851
lines changed

.github/ISSUE_TEMPLATE/new_lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: New lint suggestion
2-
description: Suggest a new Clippy lint.
2+
description: |
3+
Suggest a new Clippy lint (currently not accepting new lints)
4+
Check out the Clippy book for more information about the feature freeze.
35
labels: ["A-lint"]
46
body:
57
- type: markdown

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ order to get feedback.
3232

3333
Delete this line and everything above before opening your PR.
3434

35+
Note that we are currently not taking in new PRs that add new lints. We are in a
36+
feature freeze. Check out the book for more information. If you open a
37+
feature-adding pull request, its review will be delayed.
38+
3539
---
3640

3741
*Please write a short comment explaining your change (or "none" for internal only changes)*

.github/workflows/feature_freeze.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Feature freeze check
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'clippy_lints/src/declared_lints.rs'
7+
8+
jobs:
9+
auto-comment:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check PR Changes
14+
id: pr-changes
15+
run: echo "::set-output name=changes::${{ toJson(github.event.pull_request.changed_files) }}"
16+
17+
- name: Create Comment
18+
if: steps.pr-changes.outputs.changes != '[]'
19+
run: |
20+
# Use GitHub API to create a comment on the PR
21+
PR_NUMBER=${{ github.event.pull_request.number }}
22+
COMMENT="**Seems that you are trying to add a new lint!**\nWe are currently in a [feature freeze](https://doc.rust-lang.org/nightly/clippy/development/feature_freeze.html), so we are delaying all lint-adding PRs to August 1st and focusing on bugfixes.\nThanks a lot for your contribution, and sorry for the inconvenience.\nWith ❤ from the Clippy team"
23+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
24+
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
25+
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}"

CHANGELOG.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,94 @@ document.
66

77
## Unreleased / Beta / In Rust Nightly
88

9-
[1e5237f4...master](https://github.com/rust-lang/rust-clippy/compare/1e5237f4...master)
9+
[03a5b6b9...master](https://github.com/rust-lang/rust-clippy/compare/03a5b6b9...master)
10+
11+
## Rust 1.88
12+
13+
Current stable, released 2025-06-26
14+
15+
[View all 126 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2025-03-21T10%3A30%3A57Z..2025-05-01T08%3A03%3A26Z+base%3Amaster)
16+
17+
### New Lints
18+
19+
* Added [`swap_with_temporary`] to `complexity` [#14046](https://github.com/rust-lang/rust-clippy/pull/14046)
20+
* Added [`redundant_test_prefix`] to `restriction` [#13710](https://github.com/rust-lang/rust-clippy/pull/13710)
21+
* Added [`manual_dangling_ptr`] to `style` [#14107](https://github.com/rust-lang/rust-clippy/pull/14107)
22+
* Added [`char_indices_as_byte_indices`] to `correctness` [#13435](https://github.com/rust-lang/rust-clippy/pull/13435)
23+
* Added [`manual_abs_diff`] to `complexity` [#14482](https://github.com/rust-lang/rust-clippy/pull/14482)
24+
* Added [`ignore_without_reason`] to `pedantic` [#13931](https://github.com/rust-lang/rust-clippy/pull/13931)
25+
26+
### Moves and Deprecations
27+
28+
* Moved [`uninlined_format_args`] to `style` (from `pedantic`)
29+
[#14160](https://github.com/rust-lang/rust-clippy/pull/14160)
30+
* [`match_on_vec_items`] deprecated in favor of [`indexing_slicing`]
31+
[#14217](https://github.com/rust-lang/rust-clippy/pull/14217)
32+
* Removed superseded lints: `transmute_float_to_int`, `transmute_int_to_char`,
33+
`transmute_int_to_float`, `transmute_num_to_bytes` (now in rustc)
34+
[#14703](https://github.com/rust-lang/rust-clippy/pull/14703)
35+
36+
### Enhancements
37+
38+
* Configuration renamed from `lint-inconsistent-struct-field-initializers`
39+
to `check-inconsistent-struct-field-initializers`
40+
[#14280](https://github.com/rust-lang/rust-clippy/pull/14280)
41+
* Paths in `disallowed_*` configurations are now validated
42+
[#14397](https://github.com/rust-lang/rust-clippy/pull/14397)
43+
* [`borrow_as_ptr`] now lints implicit casts as well
44+
[#14408](https://github.com/rust-lang/rust-clippy/pull/14408)
45+
* [`iter_kv_map`] now recognizes references on maps
46+
[#14596](https://github.com/rust-lang/rust-clippy/pull/14596)
47+
* [`empty_enum_variants_with_brackets`] no longer lints reachable enums or enums used
48+
as functions within same crate [#12971](https://github.com/rust-lang/rust-clippy/pull/12971)
49+
* [`needless_lifetimes`] now checks for lifetime uses in closures
50+
[#14608](https://github.com/rust-lang/rust-clippy/pull/14608)
51+
* [`wildcard_imports`] now lints on `pub use` when `warn_on_all_wildcard_imports` is enabled
52+
[#14182](https://github.com/rust-lang/rust-clippy/pull/14182)
53+
* [`collapsible_if`] now recognizes the `let_chains` feature
54+
[#14481](https://github.com/rust-lang/rust-clippy/pull/14481)
55+
* [`match_single_binding`] now allows macros in scrutinee and patterns
56+
[#14635](https://github.com/rust-lang/rust-clippy/pull/14635)
57+
* [`needless_borrow`] does not contradict the compiler's
58+
`dangerous_implicit_autorefs` lint even though the references
59+
are not mandatory
60+
[#14810](https://github.com/rust-lang/rust-clippy/pull/14810)
61+
62+
### False Positive Fixes
63+
64+
* [`double_ended_iterator_last`] and [`needless_collect`] fixed FP when iter has side effects
65+
[#14490](https://github.com/rust-lang/rust-clippy/pull/14490)
66+
* [`mut_from_ref`] fixed FP where lifetimes nested in types were not considered
67+
[#14471](https://github.com/rust-lang/rust-clippy/pull/14471)
68+
* [`redundant_clone`] fixed FP in overlapping lifetime
69+
[#14237](https://github.com/rust-lang/rust-clippy/pull/14237)
70+
* [`map_entry`] fixed FP where lint would trigger without insert calls present
71+
[#14568](https://github.com/rust-lang/rust-clippy/pull/14568)
72+
* [`iter_cloned_collect`] fixed FP with custom `From`/`IntoIterator` impl
73+
[#14473](https://github.com/rust-lang/rust-clippy/pull/14473)
74+
* [`shadow_unrelated`] fixed FP in destructuring assignments
75+
[#14381](https://github.com/rust-lang/rust-clippy/pull/14381)
76+
* [`redundant_clone`] fixed FP on enum cast
77+
[#14395](https://github.com/rust-lang/rust-clippy/pull/14395)
78+
* [`collapsible_if`] fixed FP on block stmt before expr
79+
[#14730](https://github.com/rust-lang/rust-clippy/pull/14730)
80+
81+
### ICE Fixes
82+
83+
* [`missing_const_for_fn`] fix ICE with `-Z validate-mir` compilation option
84+
[#14776](https://github.com/rust-lang/rust-clippy/pull/14776)
85+
86+
### Documentation Improvements
87+
88+
* [`missing_asserts_for_indexing`] improved documentation and examples
89+
[#14108](https://github.com/rust-lang/rust-clippy/pull/14108)
90+
91+
### Others
92+
93+
* We're testing with edition 2024 now
94+
[#14602](https://github.com/rust-lang/rust-clippy/pull/14602)
95+
* Don't warn about unloaded crates in `clippy.toml` disallowed paths
96+
[#14733](https://github.com/rust-lang/rust-clippy/pull/14733)
1097

1198
## Rust 1.87
1299

@@ -5729,6 +5816,7 @@ Released 2018-09-13
57295816
[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type
57305817
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
57315818
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
5819+
[`doc_broken_link`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_broken_link
57325820
[`doc_comment_double_space_linebreaks`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_comment_double_space_linebreaks
57335821
[`doc_include_without_cfg`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_include_without_cfg
57345822
[`doc_lazy_continuation`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
@@ -5967,6 +6055,7 @@ Released 2018-09-13
59676055
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
59686056
[`manual_is_finite`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_finite
59696057
[`manual_is_infinite`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_infinite
6058+
[`manual_is_multiple_of`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_multiple_of
59706059
[`manual_is_power_of_two`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_power_of_two
59716060
[`manual_is_variant_and`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_variant_and
59726061
[`manual_let_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ path = "src/driver.rs"
2424
clippy_config = { path = "clippy_config" }
2525
clippy_lints = { path = "clippy_lints" }
2626
clippy_utils = { path = "clippy_utils" }
27+
declare_clippy_lint = { path = "declare_clippy_lint" }
2728
rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" }
2829
clippy_lints_internal = { path = "clippy_lints_internal", optional = true }
2930
tempfile = { version = "3.20", optional = true }
@@ -71,3 +72,10 @@ harness = false
7172
[[test]]
7273
name = "dogfood"
7374
harness = false
75+
76+
# quine-mc_cluskey makes up a significant part of the runtime in dogfood
77+
# due to the number of conditions in the clippy_lints crate
78+
# and enabling optimizations for that specific dependency helps a bit
79+
# without increasing total build times.
80+
[profile.dev.package.quine-mc_cluskey]
81+
opt-level = 3

book/src/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Clippy
22

3+
[### IMPORTANT NOTE FOR CONTRIBUTORS ================](development/feature_freeze.md)
4+
5+
----
6+
37
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](https://github.com/rust-lang/rust-clippy#license)
48

59
A collection of lints to catch common mistakes and improve your

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [GitLab CI](continuous_integration/gitlab.md)
1414
- [Travis CI](continuous_integration/travis.md)
1515
- [Development](development/README.md)
16+
- [IMPORTANT: FEATURE FREEZE](development/feature_freeze.md)
1617
- [Basics](development/basics.md)
1718
- [Adding Lints](development/adding_lints.md)
1819
- [Defining Lints](development/defining_lints.md)

book/src/development/adding_lints.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Adding a new lint
22

3+
[### IMPORTANT NOTE FOR CONTRIBUTORS ================](feature_freeze.md)
4+
5+
36
You are probably here because you want to add a new lint to Clippy. If this is
47
the first time you're contributing to Clippy, this document guides you through
58
creating an example lint from scratch.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# IMPORTANT: FEATURE FREEZE
2+
3+
This is a temporary notice.
4+
5+
From the 26th of June until the 18th of September we will perform a feature freeze. Only bugfix PRs will be reviewed
6+
except already open ones. Every feature-adding PR opened in between those dates will be moved into a
7+
milestone to be reviewed separately at another time.
8+
9+
We do this because of the long backlog of bugs that need to be addressed
10+
in order to continue being the state-of-the-art linter that Clippy has become known for being.
11+
12+
## For contributors
13+
14+
If you are a contributor or are planning to become one, **please do not open a lint-adding PR**, we have lots of open
15+
bugs of all levels of difficulty that you can address instead!
16+
17+
We currently have about 800 lints, each one posing a maintainability challenge that needs to account to every possible
18+
use case of the whole ecosystem. Bugs are natural in every software, but the Clippy team considers that Clippy needs a
19+
refinement period.
20+
21+
If you open a PR at this time, we will not review it but push it into a milestone until the refinement period ends,
22+
adding additional load into our reviewing schedules.
23+
24+
## I want to help, what can I do
25+
26+
Thanks a lot to everyone who wants to help Clippy become better software in this feature freeze period!
27+
If you'd like to help, making a bugfix, making sure that it works, and opening a PR is a great step!
28+
29+
To find things to fix, go to the [tracking issue][tracking_issue], find an issue that you like, go there and claim that
30+
issue with `@rustbot claim`.
31+
32+
As a general metric and always taking into account your skill and knowledge level, you can use this guide:
33+
34+
- 🟥 [ICEs][search_ice], these are compiler errors that causes Clippy to panic and crash. Usually involves high-level
35+
debugging, sometimes interacting directly with the upstream compiler. Difficult to fix but a great challenge that
36+
improves a lot developer workflows!
37+
38+
- 🟧 [Suggestion causes bug][sugg_causes_bug], Clippy suggested code that changed logic in some silent way.
39+
Unacceptable, as this may have disastrous consequences. Easier to fix than ICEs
40+
41+
- 🟨 [Suggestion causes error][sugg_causes_error], Clippy suggested code snippet that caused a compiler error
42+
when applied. We need to make sure that Clippy doesn't suggest using a variable twice at the same time or similar
43+
easy-to-happen occurrences.
44+
45+
- 🟩 [False positives][false_positive], a lint should not have fired, the easiest of them all, as this is "just"
46+
identifying the root of a false positive and making an exception for those cases.
47+
48+
Note that false negatives do not have priority unless the case is very clear, as they are a feature-request in a
49+
trench coat.
50+
51+
[search_ice]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc+state%3Aopen+label%3A%22I-ICE%22
52+
[sugg_causes_bug]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc%20state%3Aopen%20label%3AI-suggestion-causes-bug
53+
[sugg_causes_error]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc%20state%3Aopen%20label%3AI-suggestion-causes-error%20
54+
[false_positive]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc%20state%3Aopen%20label%3AI-false-positive
55+
[tracking_issue]: https://github.com/rust-lang/rust-clippy/issues/15086

book/src/lint_configuration.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,13 @@ The maximum cognitive complexity a function can have
488488
## `disallowed-macros`
489489
The list of disallowed macros, written as fully qualified paths.
490490

491+
**Fields:**
492+
- `path` (required): the fully qualified path to the macro that should be disallowed
493+
- `reason` (optional): explanation why this macro is disallowed
494+
- `replacement` (optional): suggested alternative macro
495+
- `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
496+
if the path doesn't exist, instead of emitting an error
497+
491498
**Default Value:** `[]`
492499

493500
---
@@ -498,6 +505,13 @@ The list of disallowed macros, written as fully qualified paths.
498505
## `disallowed-methods`
499506
The list of disallowed methods, written as fully qualified paths.
500507

508+
**Fields:**
509+
- `path` (required): the fully qualified path to the method that should be disallowed
510+
- `reason` (optional): explanation why this method is disallowed
511+
- `replacement` (optional): suggested alternative method
512+
- `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
513+
if the path doesn't exist, instead of emitting an error
514+
501515
**Default Value:** `[]`
502516

503517
---
@@ -520,6 +534,13 @@ default configuration of Clippy. By default, any configuration will replace the
520534
## `disallowed-types`
521535
The list of disallowed types, written as fully qualified paths.
522536

537+
**Fields:**
538+
- `path` (required): the fully qualified path to the type that should be disallowed
539+
- `reason` (optional): explanation why this type is disallowed
540+
- `replacement` (optional): suggested alternative type
541+
- `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
542+
if the path doesn't exist, instead of emitting an error
543+
523544
**Default Value:** `[]`
524545

525546
---
@@ -651,13 +672,14 @@ The maximum size of the `Err`-variant in a `Result` returned from a function
651672

652673

653674
## `lint-commented-code`
654-
Whether collapsible `if` chains are linted if they contain comments inside the parts
675+
Whether collapsible `if` and `else if` chains are linted if they contain comments inside the parts
655676
that would be collapsed.
656677

657678
**Default Value:** `false`
658679

659680
---
660681
**Affected lints:**
682+
* [`collapsible_else_if`](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if)
661683
* [`collapsible_if`](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if)
662684

663685

clippy_config/src/conf.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,24 @@ define_Conf! {
575575
#[conf_deprecated("Please use `cognitive-complexity-threshold` instead", cognitive_complexity_threshold)]
576576
cyclomatic_complexity_threshold: u64 = 25,
577577
/// The list of disallowed macros, written as fully qualified paths.
578+
///
579+
/// **Fields:**
580+
/// - `path` (required): the fully qualified path to the macro that should be disallowed
581+
/// - `reason` (optional): explanation why this macro is disallowed
582+
/// - `replacement` (optional): suggested alternative macro
583+
/// - `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
584+
/// if the path doesn't exist, instead of emitting an error
578585
#[disallowed_paths_allow_replacements = true]
579586
#[lints(disallowed_macros)]
580587
disallowed_macros: Vec<DisallowedPath> = Vec::new(),
581588
/// The list of disallowed methods, written as fully qualified paths.
589+
///
590+
/// **Fields:**
591+
/// - `path` (required): the fully qualified path to the method that should be disallowed
592+
/// - `reason` (optional): explanation why this method is disallowed
593+
/// - `replacement` (optional): suggested alternative method
594+
/// - `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
595+
/// if the path doesn't exist, instead of emitting an error
582596
#[disallowed_paths_allow_replacements = true]
583597
#[lints(disallowed_methods)]
584598
disallowed_methods: Vec<DisallowedPath> = Vec::new(),
@@ -588,6 +602,13 @@ define_Conf! {
588602
#[lints(disallowed_names)]
589603
disallowed_names: Vec<String> = DEFAULT_DISALLOWED_NAMES.iter().map(ToString::to_string).collect(),
590604
/// The list of disallowed types, written as fully qualified paths.
605+
///
606+
/// **Fields:**
607+
/// - `path` (required): the fully qualified path to the type that should be disallowed
608+
/// - `reason` (optional): explanation why this type is disallowed
609+
/// - `replacement` (optional): suggested alternative type
610+
/// - `allow-invalid` (optional, `false` by default): when set to `true`, it will ignore this entry
611+
/// if the path doesn't exist, instead of emitting an error
591612
#[disallowed_paths_allow_replacements = true]
592613
#[lints(disallowed_types)]
593614
disallowed_types: Vec<DisallowedPath> = Vec::new(),
@@ -641,9 +662,9 @@ define_Conf! {
641662
/// The maximum size of the `Err`-variant in a `Result` returned from a function
642663
#[lints(result_large_err)]
643664
large_error_threshold: u64 = 128,
644-
/// Whether collapsible `if` chains are linted if they contain comments inside the parts
665+
/// Whether collapsible `if` and `else if` chains are linted if they contain comments inside the parts
645666
/// that would be collapsed.
646-
#[lints(collapsible_if)]
667+
#[lints(collapsible_else_if, collapsible_if)]
647668
lint_commented_code: bool = false,
648669
/// Whether to suggest reordering constructor fields when initializers are present.
649670
/// DEPRECATED CONFIGURATION: lint-inconsistent-struct-field-initializers

clippy_dev/src/lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn run<'a>(path: &str, edition: &str, args: impl Iterator<Item = &'a String>
1313

1414
if is_file {
1515
exit_if_err(
16-
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
16+
Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
1717
.args(["run", "--bin", "clippy-driver", "--"])
1818
.args(["-L", "./target/debug"])
1919
.args(["-Z", "no-codegen"])
@@ -26,7 +26,7 @@ pub fn run<'a>(path: &str, edition: &str, args: impl Iterator<Item = &'a String>
2626
);
2727
} else {
2828
exit_if_err(
29-
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
29+
Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
3030
.arg("build")
3131
.status(),
3232
);

clippy_dev/src/release.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ static CARGO_TOML_FILES: &[&str] = &[
55
"clippy_config/Cargo.toml",
66
"clippy_lints/Cargo.toml",
77
"clippy_utils/Cargo.toml",
8+
"declare_clippy_lint/Cargo.toml",
89
"Cargo.toml",
910
];
1011

0 commit comments

Comments
 (0)