Skip to content

Commit f2b7e9f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rustup
2 parents ed363ac + faba846 commit f2b7e9f

File tree

180 files changed

+2817
-1039
lines changed

Some content is hidden

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

180 files changed

+2817
-1039
lines changed

.github/ISSUE_TEMPLATE/new_lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,24 @@ body:
4848
```
4949
validations:
5050
required: true
51+
- type: textarea
52+
id: comparison
53+
attributes:
54+
label: Comparison with existing lints
55+
description: |
56+
What makes this lint different from any existing lints that are similar, and how are those differences useful?
57+
58+
You can [use this playground template to see what existing lints are triggered by the bad code][playground]
59+
(make sure to use "Tools > Clippy" and not "Build").
60+
You can also look through the list of [rustc's allowed-by-default lints][allowed-by-default],
61+
as those won't show up in the playground above.
62+
63+
[allowed-by-default]: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
64+
65+
[playground]: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&code=%23%21%5Bwarn%28clippy%3A%3Apedantic%29%5D%0A%23%21%5Bwarn%28clippy%3A%3Anursery%29%5D%0A%23%21%5Bwarn%28clippy%3A%3Arestriction%29%5D%0A%23%21%5Bwarn%28clippy%3A%3Aall%29%5D%0A%23%21%5Ballow%28clippy%3A%3Ablanket_clippy_restriction_lints%2C+reason+%3D+%22testing+to+see+if+any+restriction+lints+match+given+code%22%29%5D%0A%0A%2F%2F%21+Template+that+can+be+used+to+see+what+clippy+lints+a+given+piece+of+code+would+trigger
66+
placeholder: Unlike `clippy::...`, the proposed lint would...
67+
- type: textarea
68+
id: context
69+
attributes:
70+
label: Additional Context
71+
description: Any additional context that you believe may be relevant.

.github/driver.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ unset CARGO_MANIFEST_DIR
4747

4848
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
4949
# FIXME: How to match the clippy invocation in compile-test.rs?
50-
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/string_to_string.rs 2>string_to_string.stderr && exit 1
51-
sed -e "/= help: for/d" string_to_string.stderr > normalized.stderr
52-
diff -u normalized.stderr tests/ui/string_to_string.stderr
50+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/char_lit_as_u8.rs 2>char_lit_as_u8.stderr && exit 1
51+
sed -e "/= help: for/d" char_lit_as_u8.stderr > normalized.stderr
52+
diff -u normalized.stderr tests/ui/char_lit_as_u8.stderr
5353

5454
# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
5555
SYSROOT=$(rustc --print sysroot)

CHANGELOG.md

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

77
## Unreleased / Beta / In Rust Nightly
88

9-
[03a5b6b9...master](https://github.com/rust-lang/rust-clippy/compare/03a5b6b9...master)
9+
[4ef75291...master](https://github.com/rust-lang/rust-clippy/compare/4ef75291...master)
10+
11+
## Rust 1.89
12+
13+
Current stable, released 2025-08-07
14+
15+
[View all 137 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2025-05-01T16%3A52%3A57Z..2025-06-13T08%3A33%3A27Z+base%3Amaster)
16+
17+
### New Lints
18+
19+
* Added [`coerce_container_to_any`] to `nursery` [#14812](https://github.com/rust-lang/rust-clippy/pull/14812)
20+
* Added [`ip_constant`] to `pedantic` [#14878](https://github.com/rust-lang/rust-clippy/pull/14878)
21+
* Added [`infallible_try_from`] to `suspicious` [#14813](https://github.com/rust-lang/rust-clippy/pull/14813)
22+
* Added [`doc_suspicious_footnotes`] to `suspicious` [#14708](https://github.com/rust-lang/rust-clippy/pull/14708)
23+
* Added [`pointer_format`] to `restriction` [#14792](https://github.com/rust-lang/rust-clippy/pull/14792)
24+
* Added [`useless_concat`] to `complexity` [#13829](https://github.com/rust-lang/rust-clippy/pull/13829)
25+
* Added [`cloned_ref_to_slice_refs`] to `perf` [#14284](https://github.com/rust-lang/rust-clippy/pull/14284)
26+
* Added [`confusing_method_to_numeric_cast`] to `suspicious` [#13979](https://github.com/rust-lang/rust-clippy/pull/13979)
27+
28+
### Moves and Deprecations
29+
30+
* Removed superseded lints: `transmute_float_to_int`, `transmute_int_to_char`,
31+
`transmute_int_to_float`, `transmute_num_to_bytes` (now in rustc)
32+
[#14703](https://github.com/rust-lang/rust-clippy/pull/14703)
33+
34+
### Enhancements
35+
36+
* [`module_name_repetitions`] added `allow_exact_repetitions` configuration option
37+
[#14261](https://github.com/rust-lang/rust-clippy/pull/14261)
38+
* [`missing_docs_in_private_items`] added `allow_unused` config for underscored fields
39+
[#14453](https://github.com/rust-lang/rust-clippy/pull/14453)
40+
* [`unnecessary_unwrap`] fixed being emitted twice in closure
41+
[#14763](https://github.com/rust-lang/rust-clippy/pull/14763)
42+
* [`needless_return`] lint span no longer wraps to previous line
43+
[#14790](https://github.com/rust-lang/rust-clippy/pull/14790)
44+
* [`trivial-copy-size-limit`] now defaults to `target_pointer_width`
45+
[#13319](https://github.com/rust-lang/rust-clippy/pull/13319)
46+
* [`integer_division`] fixed false negative for NonZero denominators
47+
[#14664](https://github.com/rust-lang/rust-clippy/pull/14664)
48+
* [`arbitrary_source_item_ordering`] no longer lints inside items with `#[repr]` attribute
49+
[#14610](https://github.com/rust-lang/rust-clippy/pull/14610)
50+
* [`excessive_precision`] no longer triggers on exponent with leading zeros
51+
[#14824](https://github.com/rust-lang/rust-clippy/pull/14824)
52+
* [`to_digit_is_some`] no longer lints in const contexts when MSRV is below 1.87
53+
[#14771](https://github.com/rust-lang/rust-clippy/pull/14771)
54+
55+
### False Positive Fixes
56+
57+
* [`std_instead_of_core`] fixed FP when part of the `use` cannot be replaced
58+
[#15016](https://github.com/rust-lang/rust-clippy/pull/15016)
59+
* [`unused_unit`] fixed FP for `Fn` bounds
60+
[#14962](https://github.com/rust-lang/rust-clippy/pull/14962)
61+
* [`unnecessary_debug_formatting`] fixed FP inside `Debug` impl
62+
[#14955](https://github.com/rust-lang/rust-clippy/pull/14955)
63+
* [`assign_op_pattern`] fixed FP on unstable const trait
64+
[#14886](https://github.com/rust-lang/rust-clippy/pull/14886)
65+
* [`useless_conversion`] fixed FP when using `.into_iter().any()`
66+
[#14800](https://github.com/rust-lang/rust-clippy/pull/14800)
67+
* [`collapsible_if`] fixed FP on block stmt before expr
68+
[#14730](https://github.com/rust-lang/rust-clippy/pull/14730)
69+
* [`manual_unwrap_or_default`] fixed FP on ref binding
70+
[#14731](https://github.com/rust-lang/rust-clippy/pull/14731)
71+
* [`unused_async`] fixed FP on default impl
72+
[#14720](https://github.com/rust-lang/rust-clippy/pull/14720)
73+
* [`manual_slice_fill`] fixed FP on `IndexMut` overload
74+
[#14719](https://github.com/rust-lang/rust-clippy/pull/14719)
75+
* [`unnecessary_to_owned`] fixed FP when map key is a reference
76+
[#14834](https://github.com/rust-lang/rust-clippy/pull/14834)
77+
78+
### ICE Fixes
79+
80+
* [`mutable_key_type`] fixed ICE when infinitely associated generic types are used
81+
[#14965](https://github.com/rust-lang/rust-clippy/pull/14965)
82+
* [`zero_sized_map_values`] fixed ICE while computing type layout
83+
[#14837](https://github.com/rust-lang/rust-clippy/pull/14837)
84+
* [`useless_asref`] fixed ICE on trait method
85+
[#14830](https://github.com/rust-lang/rust-clippy/pull/14830)
86+
* [`manual_slice_size_calculation`] fixed ICE in suggestion and triggers in `const` context
87+
[#14804](https://github.com/rust-lang/rust-clippy/pull/14804)
88+
* [`missing_const_for_fn`]: fix ICE with some compilation options
89+
[#14776](https://github.com/rust-lang/rust-clippy/pull/14776)
90+
91+
### Documentation Improvements
92+
93+
* [`manual_contains`] improved documentation wording
94+
[#14917](https://github.com/rust-lang/rust-clippy/pull/14917)
95+
96+
### Performance improvements
97+
98+
* [`strlen_on_c_strings`] optimized by 99.75% (31M → 76k instructions)
99+
[#15043](https://github.com/rust-lang/rust-clippy/pull/15043)
100+
* Reduced documentation lints execution time by 85% (7.5% → 1% of total runtime)
101+
[#14870](https://github.com/rust-lang/rust-clippy/pull/14870)
102+
* [`unit_return_expecting_ord`] optimized to reduce binder instantiation from 95k to 10k calls
103+
[#14905](https://github.com/rust-lang/rust-clippy/pull/14905)
104+
* [`doc_markdown`] optimized by 50%
105+
[#14693](https://github.com/rust-lang/rust-clippy/pull/14693)
106+
* Refactor and speed up `cargo dev fmt`
107+
[#14638](https://github.com/rust-lang/rust-clippy/pull/14638)
10108

11109
## Rust 1.88
12110

@@ -6260,6 +6358,7 @@ Released 2018-09-13
62606358
[`pointers_in_nomem_asm_block`]: https://rust-lang.github.io/rust-clippy/master/index.html#pointers_in_nomem_asm_block
62616359
[`positional_named_format_parameters`]: https://rust-lang.github.io/rust-clippy/master/index.html#positional_named_format_parameters
62626360
[`possible_missing_comma`]: https://rust-lang.github.io/rust-clippy/master/index.html#possible_missing_comma
6361+
[`possible_missing_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#possible_missing_else
62636362
[`precedence`]: https://rust-lang.github.io/rust-clippy/master/index.html#precedence
62646363
[`precedence_bits`]: https://rust-lang.github.io/rust-clippy/master/index.html#precedence_bits
62656364
[`print_in_format_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#print_in_format_impl

CONTRIBUTING.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,26 +199,34 @@ currently. Between writing new lints, fixing issues, reviewing pull requests and
199199
responding to issues there may not always be enough time to stay on top of it
200200
all.
201201

202-
Our highest priority is fixing [ICEs][I-ICE] and [bugs][C-bug], for example
203-
an ICE in a popular crate that many other crates depend on. We don't
204-
want Clippy to crash on your code and we want it to be as reliable as the
205-
suggestions from Rust compiler errors.
206-
207-
We have prioritization labels and a sync-blocker label, which are described below.
208-
- [P-low][p-low]: Requires attention (fix/response/evaluation) by a team member but isn't urgent.
209-
- [P-medium][p-medium]: Should be addressed by a team member until the next sync.
210-
- [P-high][p-high]: Should be immediately addressed and will require an out-of-cycle sync or a backport.
211-
- [L-sync-blocker][l-sync-blocker]: An issue that "blocks" a sync.
212-
Or rather: before the sync this should be addressed,
213-
e.g. by removing a lint again, so it doesn't hit beta/stable.
202+
To find things to fix, go to the [tracking issue][tracking_issue], find an issue that you like,
203+
and claim it with `@rustbot claim`.
204+
205+
As a general metric and always taking into account your skill and knowledge level, you can use this guide:
206+
207+
- 🟥 [ICEs][search_ice], these are compiler errors that causes Clippy to panic and crash. Usually involves high-level
208+
debugging, sometimes interacting directly with the upstream compiler. Difficult to fix but a great challenge that
209+
improves a lot developer workflows!
210+
211+
- 🟧 [Suggestion causes bug][sugg_causes_bug], Clippy suggested code that changed logic in some silent way.
212+
Unacceptable, as this may have disastrous consequences. Easier to fix than ICEs
213+
214+
- 🟨 [Suggestion causes error][sugg_causes_error], Clippy suggested code snippet that caused a compiler error
215+
when applied. We need to make sure that Clippy doesn't suggest using a variable twice at the same time or similar
216+
easy-to-happen occurrences.
217+
218+
- 🟩 [False positives][false_positive], a lint should not have fired, the easiest of them all, as this is "just"
219+
identifying the root of a false positive and making an exception for those cases.
220+
221+
Note that false negatives do not have priority unless the case is very clear, as they are a feature-request in a
222+
trench coat.
214223

215224
[triage]: https://forge.rust-lang.org/release/triage-procedure.html
216-
[I-ICE]: https://github.com/rust-lang/rust-clippy/labels/I-ICE
217-
[C-bug]: https://github.com/rust-lang/rust-clippy/labels/C-bug
218-
[p-low]: https://github.com/rust-lang/rust-clippy/labels/P-low
219-
[p-medium]: https://github.com/rust-lang/rust-clippy/labels/P-medium
220-
[p-high]: https://github.com/rust-lang/rust-clippy/labels/P-high
221-
[l-sync-blocker]: https://github.com/rust-lang/rust-clippy/labels/L-sync-blocker
225+
[search_ice]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc+state%3Aopen+label%3A%22I-ICE%22
226+
[sugg_causes_bug]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc%20state%3Aopen%20label%3AI-suggestion-causes-bug
227+
[sugg_causes_error]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc%20state%3Aopen%20label%3AI-suggestion-causes-error%20
228+
[false_positive]: https://github.com/rust-lang/rust-clippy/issues?q=sort%3Aupdated-desc%20state%3Aopen%20label%3AI-false-positive
229+
[tracking_issue]: https://github.com/rust-lang/rust-clippy/issues/15086
222230

223231
## Contributions
224232

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ harness = false
6464
[[test]]
6565
name = "dogfood"
6666
harness = false
67+
68+
# quine-mc_cluskey makes up a significant part of the runtime in dogfood
69+
# due to the number of conditions in the clippy_lints crate
70+
# and enabling optimizations for that specific dependency helps a bit
71+
# without increasing total build times.
72+
[profile.dev.package.quine-mc_cluskey]
73+
opt-level = 3

book/src/lint_configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ default configuration of Clippy. By default, any configuration will replace the
555555
* `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
556556
* `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.
557557

558-
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "MHz", "GHz", "THz", "AccessKit", "CoAP", "CoreFoundation", "CoreGraphics", "CoreText", "DevOps", "Direct2D", "Direct3D", "DirectWrite", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenAL", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "OpenType", "WebGL", "WebGL2", "WebGPU", "WebRTC", "WebSocket", "WebTransport", "WebP", "OpenExr", "YCbCr", "sRGB", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
558+
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "MHz", "GHz", "THz", "AccessKit", "CoAP", "CoreFoundation", "CoreGraphics", "CoreText", "DevOps", "Direct2D", "Direct3D", "DirectWrite", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenAL", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "OpenType", "WebGL", "WebGL2", "WebGPU", "WebRTC", "WebSocket", "WebTransport", "WebP", "OpenExr", "YCbCr", "sRGB", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "NixOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
559559

560560
---
561561
**Affected lints:**

clippy_config/src/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const DEFAULT_DOC_VALID_IDENTS: &[&str] = &[
4444
"WebP", "OpenExr", "YCbCr", "sRGB",
4545
"TensorFlow",
4646
"TrueType",
47-
"iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD",
47+
"iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "NixOS",
4848
"TeX", "LaTeX", "BibTeX", "BibLaTeX",
4949
"MinGW",
5050
"CamelCase",

clippy_lints/src/approx_const.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use clippy_config::Conf;
22
use clippy_utils::diagnostics::span_lint_and_help;
33
use clippy_utils::msrvs::{self, Msrv};
44
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
5-
use rustc_hir::RustcVersion;
6-
use rustc_hir::{HirId, Lit};
5+
use rustc_hir::{HirId, Lit, RustcVersion};
76
use rustc_lint::{LateContext, LateLintPass};
87
use rustc_session::impl_lint_pass;
98
use rustc_span::{Span, symbol};

clippy_lints/src/attrs/duplicated_attributes.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use super::DUPLICATED_ATTRIBUTES;
22
use clippy_utils::diagnostics::span_lint_and_then;
33
use itertools::Itertools;
44
use rustc_ast::{Attribute, MetaItem};
5+
use rustc_ast_pretty::pprust::path_to_string;
56
use rustc_data_structures::fx::FxHashMap;
67
use rustc_lint::EarlyContext;
78
use rustc_span::{Span, Symbol, sym};
@@ -35,39 +36,46 @@ fn check_duplicated_attr(
3536
if attr.span.from_expansion() {
3637
return;
3738
}
38-
let Some(ident) = attr.ident() else { return };
39-
let name = ident.name;
40-
if name == sym::doc || name == sym::cfg_attr_trace || name == sym::rustc_on_unimplemented || name == sym::reason {
41-
// FIXME: Would be nice to handle `cfg_attr` as well. Only problem is to check that cfg
42-
// conditions are the same.
43-
// `#[rustc_on_unimplemented]` contains duplicated subattributes, that's expected.
44-
return;
45-
}
46-
if let Some(direct_parent) = parent.last()
47-
&& *direct_parent == sym::cfg_trace
48-
&& [sym::all, sym::not, sym::any].contains(&name)
49-
{
50-
// FIXME: We don't correctly check `cfg`s for now, so if it's more complex than just a one
51-
// level `cfg`, we leave.
52-
return;
39+
let attr_path = if let Some(ident) = attr.ident() {
40+
ident.name
41+
} else {
42+
Symbol::intern(&path_to_string(&attr.path))
43+
};
44+
if let Some(ident) = attr.ident() {
45+
let name = ident.name;
46+
if name == sym::doc || name == sym::cfg_attr_trace || name == sym::rustc_on_unimplemented || name == sym::reason
47+
{
48+
// FIXME: Would be nice to handle `cfg_attr` as well. Only problem is to check that cfg
49+
// conditions are the same.
50+
// `#[rustc_on_unimplemented]` contains duplicated subattributes, that's expected.
51+
return;
52+
}
53+
if let Some(direct_parent) = parent.last()
54+
&& *direct_parent == sym::cfg_trace
55+
&& [sym::all, sym::not, sym::any].contains(&name)
56+
{
57+
// FIXME: We don't correctly check `cfg`s for now, so if it's more complex than just a one
58+
// level `cfg`, we leave.
59+
return;
60+
}
5361
}
5462
if let Some(value) = attr.value_str() {
5563
emit_if_duplicated(
5664
cx,
5765
attr,
5866
attr_paths,
59-
format!("{}:{name}={value}", parent.iter().join(":")),
67+
format!("{}:{attr_path}={value}", parent.iter().join(":")),
6068
);
6169
} else if let Some(sub_attrs) = attr.meta_item_list() {
62-
parent.push(name);
70+
parent.push(attr_path);
6371
for sub_attr in sub_attrs {
6472
if let Some(meta) = sub_attr.meta_item() {
6573
check_duplicated_attr(cx, meta, attr_paths, parent);
6674
}
6775
}
6876
parent.pop();
6977
} else {
70-
emit_if_duplicated(cx, attr, attr_paths, format!("{}:{name}", parent.iter().join(":")));
78+
emit_if_duplicated(cx, attr, attr_paths, format!("{}:{attr_path}", parent.iter().join(":")));
7179
}
7280
}
7381

clippy_lints/src/attrs/inline_always.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use super::INLINE_ALWAYS;
22
use clippy_utils::diagnostics::span_lint;
33
use rustc_hir::attrs::{AttributeKind, InlineAttr};
4-
use rustc_hir::find_attr;
5-
use rustc_hir::Attribute;
4+
use rustc_hir::{Attribute, find_attr};
65
use rustc_lint::LateContext;
76
use rustc_span::Span;
87
use rustc_span::symbol::Symbol;

0 commit comments

Comments
 (0)