Commit graph

22935 commits

Author SHA1 Message Date
Philipp Krones
cd15aeb70b
Ping notriddle when a clippy lint in clippy_lints/doc is modified (#15147)
Related to [this Zulip
thread](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Reviewing.20the.20.60doc.60.20lints/with/525943439).

@notriddle Would you want that?

changelog: none
2025-06-26 17:48:02 +00:00
Philipp Krones
c950602c01
Rustup (#15148)
r? @ghost

changelog: none
2025-06-26 17:34:27 +00:00
Philipp Krones
32fcff8aa8
Bump Clippy version -> 0.1.90 2025-06-26 19:30:02 +02:00
Philipp Krones
9b41d8fdb6
Bump nightly version -> 2025-06-26 2025-06-26 19:29:50 +02:00
Philipp Krones
90364dd178
Merge remote-tracking branch 'upstream/master' into rustup 2025-06-26 19:29:33 +02:00
Philipp Krones
8050e591b6
Update book and templates with feature freeze (#14456)
This PR announces the feature freeze period talked about in
https://github.com/rust-lang/rust-clippy/issues/14364

1. Add the page to the book
2. Modify the in-Github templates.
3. The third commit (to be squashed into the first) rolls the date
mentioned 6 weeks (so, starting on May 9th and ending on August 20th).
This gives us a comfortable buffer to make choices for this period.

We have a pending discussion on the #14364. So having some more time to
make choices is very nice. I'm also preparing a Github action for
detecting new lints and posting a comment about the feature freeze
(being worked on in another branch)

Something I'd like comment on is the date formatting. I'm not sure if
"May 9th to the first of August" is the correct way of writing this
information in a book 😅.

changelog: Announce the feature freeze from May 9th to the first of
August
2025-06-26 16:45:13 +00:00
Samuel Tardieu
4116a72a08
Ping notriddle when a clippy lint in clippy_lints/doc is modified 2025-06-26 18:45:11 +02:00
Philipp Krones
b88d162d2a
Add link to the feature freeze tracking issue to the book 2025-06-26 18:40:51 +02:00
Philipp Krones
40554ef4aa
Add beta-accepted to CHANGELOG for 1.88 (#15130)
Add beta-accepted to CHANGELOG for 1.88 since it was missed at
rust-lang/rust-clippy#5095

changelog: none

r? flip1995
2025-06-26 16:30:45 +00:00
Alexey Semenyuk
95f0991ad4 Add beta-nominated to changelog for 1.88 2025-06-25 15:38:20 +05:00
Philipp Krones
75463814c6
changelog: link to the correct PR (#15125)
changelog: none
2025-06-25 09:13:30 +00:00
bors
708ffd5ccf Auto merge of #142997 - workingjubilee:rollup-6lxec87, r=workingjubilee
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#135731 (Implement parsing of pinned borrows)
 - rust-lang/rust#138780 (Add `#[loop_match]` for improved DFA codegen)
 - rust-lang/rust#142453 (Windows: make `read_dir` stop iterating after the first error is encountered)
 - rust-lang/rust#142633 (Error on invalid signatures for interrupt ABIs)
 - rust-lang/rust#142768 (Avoid a bitcast FFI call in transmuting)
 - rust-lang/rust#142825 (Port `#[track_caller]` to the new attribute system)
 - rust-lang/rust#142844 (Enable short-ice for Windows)
 - rust-lang/rust#142934 (Tweak `-Zmacro-stats` measurement.)
 - rust-lang/rust#142955 (Couple of test suite fixes for cg_clif)
 - rust-lang/rust#142977 (rustdoc: Don't mark `#[target_feature]` functions as ⚠)
 - rust-lang/rust#142980 (Reduce mismatched-lifetime-syntaxes suggestions to MaybeIncorrect)
 - rust-lang/rust#142982 (Corrected spelling mistake in c_str.rs)
 - rust-lang/rust#142983 (Taint body on invalid call ABI)
 - rust-lang/rust#142988 (Update wasm-component-ld to 0.5.14)
 - rust-lang/rust#142993 (Update cargo)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-25 04:05:47 +00:00
bors
4a4d67227e Auto merge of #140999 - hkBst:update-escaper, r=nnethercote
update to literal-escaper 0.0.4 for better API without `unreachable` and faster string parsing

This is the replacement for just the part of https://github.com/rust-lang/rust/pull/138163 dealing with the changed API of unescape functionality, since that got moved into its own crate.

<del>This uses an unpublished version of literal-escaper (https://github.com/rust-lang/literal-escaper/pull/8).</del>

r? `@nnethercote`
2025-06-25 01:03:30 +00:00
Ada Alakbarova
c11bc75fb0
changelog: link to the correct PR 2025-06-25 01:00:34 +02:00
Jana Dönszelmann
ae6ab44d68 fix clippy 2025-06-24 23:00:31 +02:00
Philipp Krones
ad6e19a269
Changelog for Clippy 1.88 🏄 (#15095)
Violets are red,
Roses are blue,
Summer’s a feeling,
And we’re feeling it too.

<hr>

> (Please ping me when June made it as the cat of the release. I want to
send it to her owner :D)

@xFrednet voila:

![image](https://github.com/user-attachments/assets/7908abd0-76a5-4a64-a553-9c443d4c8b37)

Cats for the next release can be traditionally nominated in the comments
:D
Please be more active and cat-minded 😻

<hr>

changelog: none

r? flip1995
2025-06-24 16:15:22 +00:00
Alexey Semenyuk
2e63c7c684 Changelog for Clippy 1.88 2025-06-23 22:26:52 +05:00
Marijn Schouten
05b74d558f update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing 2025-06-23 06:36:22 +00:00
Jonathan Brouwer
1d764e022f Port #[no_mangle] to new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-22 22:17:04 +02:00
Jonathan Brouwer
b92cccb977 Port #[must_use] to new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-22 14:51:58 +02:00
David Tolnay
953bf2be89 All HIR attributes are outer 2025-06-21 11:11:34 -07:00
Timo
76118ec84e
Add missing space when expanding a struct-like variant (#15096)
In `wildcard_enum_match_arm`, expanding a variant with struct-like
fields was missing a space between the variant name and the opening
bracket.

Also, add a test for tuple-like variants with only one field, as those
are expanded as `VariantName(_)` instead of `VariantName(..)`.

changelog: none
2025-06-21 17:22:37 +00:00
Samuel Tardieu
db539d051d
Add missing space when expanding a struct-like variant
In `wildcard_enum_match_arm`, expanding a variant with struct-like
fields was missing a space between the variant name and the opening
bracket.

Also, add a test for tuple-like variants with only one field, as those
are expanded as `VariantName(_)` instead of `VariantName(..)`.
2025-06-21 19:00:38 +02:00
Samuel Tardieu
a421ffbadb
Fix wildcard_enum_match_arm suggests wrongly with raw identifiers (#15093)
Closes rust-lang/rust-clippy#15091

The lack of ability to escape raw identifiers is a known issue of
Clippy. In this case, it can be avoided by snippet from the code.

changelog: [`wildcard_enum_match_arm`] fix wrong suggestions with raw
identifiers
2025-06-21 16:52:03 +00:00
Timo
6330f9119b
Emit lint about redundant closure on the closure node itself (#14791)
Fixes rust-lang/rust-clippy#14789

changelog: [`redundant_closure`],
[`redundant_closure_for_method_calls`]: allow lint to be allowed or
expected on the closure expression itself
2025-06-21 15:20:48 +00:00
Samuel Tardieu
c0dd2d5a38
Emit lint about redundant closure on the closure node itself 2025-06-21 16:21:40 +02:00
Samuel Tardieu
07cc166acf
Add MSRV test for unnecessary_debug_formatting with OsStr (#15001)
`unnecessary_debug_formatting` suggests display() respected for
MSRV but lacking of tests. This adds tests to check MSRV for OsStr.

changelog: none
2025-06-21 12:28:03 +00:00
Samuel Tardieu
7c828e63ba
or_fun_call: lint more methods (#15071)
Extend `or_fun_call` lint with new checks for Option::get_or_insert,
Result::map_or.

changelog: [`or_fun_call`]: lint more methods
2025-06-21 09:21:42 +00:00
Matthias Krüger
f027fc8bca Rollup merge of #142787 - samueltardieu:diag-items-for-clippy, r=Manishearth,Urgau
Add diagnostic items for Clippy

Clippy still uses some paths to access items from the standard library. Adding the missing diagnostic items allows removing the last remaining paths.

Closes rust-lang/rust-clippy#5393
2025-06-21 10:53:26 +02:00
donkomura
e0cb4ced0a
Check the MSRV for unnecessary_debug_formatting
`unnecessary_debug_formatting` suggests display() respected for
MSRV but lacking of tests. This adds tests to check MSRV for OsStr.

changelog: none
2025-06-21 15:03:37 +09:00
yanglsh
e50ef68f0c fix: wildcard_enum_match_arm suggests wrongly with raw identifiers 2025-06-21 13:46:43 +08:00
Timo
4ead403c91
Fix typo in tests/ui/missing_const_for_fn/const_trait.rs (#15090)
I think the comment is meant to refer to
[clippy_utils::qualify_min_const_fn](https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/qualify_min_const_fn.rs).

changelog: none
2025-06-20 23:27:52 +00:00
Samuel Moelius
1e30fa253b Fix typo in tests/ui/missing_const_for_fn/const_trait.rs 2025-06-20 19:17:35 -04:00
bors
f53cd2be0d Auto merge of #142794 - tgross35:rollup-iae7okj, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.)
 - rust-lang/rust#142491 (Rework #[cold] attribute parser)
 - rust-lang/rust#142494 (Fix missing docs in `rustc_attr_parsing`)
 - rust-lang/rust#142495 (Better template for `#[repr]` attributes)
 - rust-lang/rust#142497 (Fix random failure when JS code is executed when the whole file was not read yet)
 - rust-lang/rust#142575 (Ensure copy* intrinsics also perform the static self-init checks)
 - rust-lang/rust#142650 (Refactor Translator)
 - rust-lang/rust#142713 (mbe: Refactor transcription)
 - rust-lang/rust#142755 (rustdoc: Remove `FormatRenderer::cache`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-20 23:09:48 +00:00
Timo
35026c7ea8
Fix false positive of borrow_deref_ref (#14967)
If a reborrow is itself borrowed mutably, do not propose to replace it
by the original reference.

Fixes: rust-lang/rust-clippy#14934

changelog: [`borrow_deref_ref`]: do not propose replacing a reborrow by
the original reference if the reborrow is itself mutably borrowed
2025-06-20 22:11:49 +00:00
Jason Newcomb
37cb83488a
Sugg: do not parenthesize a double unary operator (#14983)
For example, adding `*` in front of `*expression` is best shown as
`**expression` rather than `*(*expression)`.

This is not perfect, as it checks whether the operator is already a
prefix of the expression, but it is better than it was before. For
example, `&`+`&mut x` will get `&&mut x` but `&mut `+`&x` will get `&mut
(&x)` as it did before this change.

changelog: none
2025-06-20 22:00:40 +00:00
Timo
98555244f0
[PERF] Don't spawn so many compilers (3/2) (19m -> 250k) (#15030)
Optimize `needless_doctest_main`, make it short-circuit, make sure that
we don't spin up a new compiler on EVERY code block.

---

The old implementation was creating a new compiler, new parser, new
thread, new SessionGlobals, new everything for each code block. No
matter if they actually didn't even contain `fn main()` or anything
relevant.

On callgrind, seems that we're reducing about a 6.7242% de cycle count
(which turns out to be a 38 million instruction difference, great!).
Benchmarked in `bumpalo-3.16.0`. Also on bumpalo we spawn 78 less
threads. This moves `SessionGlobals::new` from the top time-consuming
function by itself in some benchmarks, into one not even in the top 500.

Also, populate the test files.

changelog:[`needless_doctest_main`]: Avoid spawning so many threads in
unnecessary circumstances
2025-06-20 21:58:45 +00:00
Jason Newcomb
0601337a25
Fix manual_ok_err suggests wrongly with references (#15053)
Closes rust-lang/rust-clippy#15051

changelog: [`manual_ok_err`] fix wrong suggestions with references
2025-06-20 21:50:49 +00:00
Jason Newcomb
6064822acb
Fix branches_sharing_code suggests misleadingly when in assignment (#15076)
The lint will note `the end suggestion probably needs some adjustments
to use the expression result correctly` when the expr's is not unit. So
I extend this note to also appear when the expr is in an assignment.

changelog: [`branches_sharing_code`] fix misleading suggestions when in
assignment
2025-06-20 21:48:57 +00:00
klensy
ea72620f62 lint Option::get_or_insert and Result::map_or too 2025-06-20 23:59:36 +03:00
Jakub Beránek
f337ae60cd Rollup merge of #142767 - nnethercote:symbol-cleanups, r=petrochenkov
Some symbol and PathRoot cleanups

I'm looking into unifying how we join and print paths. Here are some preliminary cleanups.

r? ``@petrochenkov``
2025-06-20 20:03:24 +02:00
Trevor Gross
5f759a9c1f Rollup merge of #142650 - camsteffen:refactor-translator, r=petrochenkov
Refactor Translator

My main motivation was to simplify the usage of `SilentEmitter` for users like rustfmt. A few refactoring opportunities arose along the way.

* Replace `Translate` trait with `Translator` struct
* Replace `Emitter: Translate` with `Emitter::translator`
* Split `SilentEmitter` into `FatalOnlyEmitter` and `SilentEmitter`
2025-06-20 13:36:01 -04:00
Samuel Tardieu
65402ab41a clippy: replace path uses by diagnostic items 2025-06-20 17:53:09 +02:00
blyxyas
3745a3f7ab Even more optimizing documentation lints? (3/2)
Avoid creating so many SessionGlobals

Improve filtering and account for spacing

Actually return early
2025-06-20 12:07:35 +02:00
Alejandra González
2c1c746ebd
New lint: manual_is_multiple_of (#14292)
~~I've added a `min_divisor` configuration option, default to 4, to not
trigger on smaller divisibility operations. I would prefer not to lint
`if a & 1 == 0` as `if a.is_multiple_of(2)` by default because the
former is very idiomatic in systems (and embedded) programming.~~

~~A `min_and_mask_size` option, defaulting to 3, sets the default bits
to be and-masked before this lint triggers; that would be `n` in `v &
((1 << n) - 1) == 0`. The form `v % 10 == 0` is always linted.~~

~~This PR will stay in draft mode until the next rustup which will mark
`unsigned_is_multiple_of` stable for Rust 1.87.0, and the feature flags
will be removed.~~

What should its category be? I've used "complexity", but "pedantic"
might be suitable as well.

Close rust-lang/rust-clippy#14289
changelog: [`manual_is_multiple_of`]: new lint
r? ghost
2025-06-20 09:43:53 +00:00
Samuel Tardieu
6ffff5f009
New lint: manual_is_multiple_of 2025-06-20 09:42:28 +02:00
Samuel Tardieu
f25fb1adf9
Use .is_multiple_of() in Clippy tests sources
This prevents triggering the new `manual_is_multiple_of` lint on
unrelated lint tests.
2025-06-20 09:42:27 +02:00
Samuel Tardieu
0fdd0b928e
Add integer_const() and is_zero_integer_const() utility functions 2025-06-20 09:42:27 +02:00
Samuel Tardieu
8ec6f1a96f
Fix suggestion-cases-error of empty_line_after_outer_attr (#15078)
Fixes: rust-lang/rust-clippy#14980

changelog: Fix suggestion-cases-error of [`empty_line_after_outer_attr`]
2025-06-20 07:12:49 +00:00
relaxcn
95778b554d Fix suggestion-cases-error of empty_line_after_outer_attr 2025-06-20 07:07:51 +00:00