Commit Graph

24781 Commits

Author SHA1 Message Date
Ada Alakbarova f79b6a1f60 docs: add <> around Markdown link 2026-02-18 16:12:14 +01:00
Jason Newcomb 1b33602298 Make manual_is_variant_and to cover manual is_none_or (#16424)
Closes rust-lang/rust-clippy#16419

changelog: [`manual_is_variant_and`] enhance to cover manual
`is_none_or`
2026-01-25 23:04:35 +00:00
linshuy2 02d9865f9e Enhance manual_is_variant_and to cover manual is_none_or 2026-01-25 22:40:13 +00:00
Jason Newcomb 30dbf82cf4 Fix test_attr_in_doctest FP on test_harness (#16454)
Closes rust-lang/rust-clippy#16447

changelog: [`test_attr_in_doctest`] fix FP on `test_harness`
2026-01-25 22:20:56 +00:00
Jason Newcomb 187893e00e rhs of short-circuit expression doesn't always run (#16463)
changelog: [`never_loop`]: rhs of short-circuit expression doesn't
always run

Fixes rust-lang/rust-clippy#16462
2026-01-25 22:17:15 +00:00
Samuel Tardieu 7ffda539e6 Also ignore cases with comments in let_and_return (#16461)
Related to the example in
https://github.com/rust-lang/rust-clippy/issues/16451 but doesn't fix
the issue itself

changelog: [`let_and_return`]: No longer lints when there's a comment
between the `let` and return
2026-01-25 20:47:25 +00:00
Samuel Tardieu 4a6c0dea8b rhs of short-circuit expression doesn't always run 2026-01-25 19:04:31 +01:00
Alex Macleod 8416c544ee Also ignore cases with comments in let_and_return 2026-01-25 15:02:11 +00:00
dswij 0f17b47529 Add PowerShell to doc_markdown whitelist (#16453)
Closes rust-lang/rust-clippy#16446

changelog: [`doc_markdown`] add PowerShell to whitelist
2026-01-25 07:41:06 +00:00
linshuy2 cc299873b9 fix: test_attr_in_doctest FP on test_harness 2026-01-24 21:29:16 +00:00
linshuy2 e4d146e0c3 fix: doc_markdown add PowerShell to whitelist 2026-01-24 21:19:56 +00:00
dswij dc57e57f74 fix(manual_let_else): add trailing comma to struct patterns ending with .. (#16442)
fixes rust-lang/rust-clippy#16433

Adds a trailing comma to the last field of a struct pattern if it ends
with a `..` to avoid an invalid suggestion. A test was added as well.

changelog: [`manual_let_else`] fix suggestion for `..` patterns
2026-01-24 15:55:09 +00:00
Philipp Krones f43f1d61b7 Update default branch name of rust-lang/rust in subtree sync docs (#16198)
Noticed while writing a copy of subtree sync docs for `rustfmt`.

changelog: none
2026-01-23 13:22:12 +00:00
Matheus L. P. 1ebafc5042 fix(manual_let_else): add trailing comma when necessary
Adds a trailing comma to struct patterns ending with `..`.
Fixes rust-lang#16433
2026-01-22 23:35:34 -06:00
dswij 62846d25e6 test: remove unwrap.rs (#16437)
The file is testing `unwrap_used`, but that's already covered by the
`unwrap_expect_used.rs` test file

changelog: none
2026-01-23 04:43:59 +00:00
Philipp Krones 54482290b5 Rustup (#16438)
r? @ghost

changelog: none
2026-01-22 16:00:49 +00:00
Philipp Krones 0f9b027859 Bump Clippy version -> 0.1.95 2026-01-22 16:55:20 +01:00
Philipp Krones 21e84b5da8 Bump nightly version -> 2026-01-22 2026-01-22 16:55:13 +01:00
Philipp Krones 94fe3ddd93 Merge remote-tracking branch 'upstream/master' into rustup 2026-01-22 16:55:00 +01:00
Philipp Krones e5055d4cb3 Changelog for Clippy 1.93❄️ (#16413)
Violets are red,
Roses are blue,
January brought the cold,
And extra coffee too.

--------
Our winner Nouni from @TheElectronWill is the winner at
https://github.com/rust-lang/rust-clippy/pull/16158

> Nouni trying to check whether the new release smells good 👀🐱... It
does!

Definitely it does

<img width="1152" height="1536" alt="image"
src="https://github.com/user-attachments/assets/00c03426-f8b2-43cd-8ea0-ff13ab01413a"
/>

--------

Cats for the next release can be nominated in the comments meow

changelog: none

r? flip1995
2026-01-22 09:49:25 +00:00
Ada Alakbarova 76a536c590 test: remove unwrap.rs
The file is testing `unwrap_used`, but that's already covered by the
`unwrap_expect_used.rs` test file
2026-01-22 00:18:41 +01:00
Samuel Tardieu f2b567fa14 Add manual_checked_ops lint (#16149)
changelog: [`manual_checked_ops`]: new lint suggesting `checked_div`
instead of manual zero checks before unsigned division

Part of the initiative described in rust-lang/rust-clippy#12894.
2026-01-20 10:58:35 +00:00
Amerikrainian 7533a9aca9 Add manual checked ops lint 2026-01-20 04:46:53 -06:00
dswij 4b98bd3db5 Do not consider binary operators as commutative by default (#16420)
Only `==` (and thus `!=`) are supposed to be commutative according to
Rust's documentation. Do not make assumptions about other operators
whose meaning may depend on the types on which they apply. However,
special-case operators known to be commutative for primitive types such
as addition or multiplication.

changelog: [`if_same_then_else`]: do not consider binary operators
commutative by default

Fixes rust-lang/rust-clippy#16416
2026-01-20 03:50:23 +00:00
Jason Newcomb bbfe34e205 unnecessary_sort_by: reduce suggestion diffs (#16417)
Now, only `call_span` is replaced, so the receiver is not a part of the
diff. This also removes the need to create a snippet for the receiver.

changelog: [`unnecessary_sort_by`]: reduce suggestion diffs
2026-01-19 19:05:59 +00:00
Jonathan Brouwer c591bc103a Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase
This PR was mostly made by search&replacing
2026-01-19 17:39:49 +01:00
llogiq fe4bc3123f fix(collapsible_span_lint_calls): use snippet_with_context for spans that are likely to contain macro expns (#15881)
Fixes https://github.com/rust-lang/rust-clippy/issues/15880

changelog: none
2026-01-18 15:51:15 +00:00
Samuel Tardieu a5ae1644ee Fix main_recursion tests (#16259)
Fixes rust-lang/rust-clippy#11034

changelog: [`main_recursion`]: none
2026-01-18 10:25:36 +00:00
Samuel Tardieu d25a26df71 Skip elidable_lifetime_names lint for proc-macro generated code (#16402)
When linting code generated by proc macros (like `derivative`), the
`elidable_lifetime_names` lint can produce fix suggestions with
overlapping spans. This causes `cargo clippy --fix` to fail with "cannot
replace slice of data that was already replaced".

This change adds `is_from_proc_macro` checks to the three lint entry
points (`check_item`, `check_impl_item`, `check_trait_item`) to skip
linting proc-macro generated code entirely.

Fixes rust-lang/rust-clippy#16316

---

changelog: [`elidable_lifetime_names`]: skip linting proc-macro
generated code to avoid broken fix suggestions
2026-01-17 15:20:59 +00:00
llogiq 4ab5ad49d0 clippy_dev: Parsing revamp part 3/N (#15947)
Not parsing changes, but a cleanup to make future changes easier. This
makes uplifting a lint it's own command rather than being part of
`rename_lint`. Uplifting and deprecation now also share code for
filesystem changes.

The `deprecate` command has a slight regression in that no longer
removes the lint from the lint pass declaration. This will be fixed in a
later PR where those are parsed and formatted.

changelog: none
2026-01-17 08:58:40 +00:00
llogiq 29e2b8dc8f double_comparisons: check for expressions such as x != y && x >= y (#16033)
This change expands the `double_comparisons` lint to check for
expressions of the form `x != y && x >= y` and `x != y && x <= y`. Since
the lint already checks for their dual (`x == y || x < y` and `x == y ||
x > y`, respectively) while also checking for `x <= y && x >= y` and its
dual `x > y || x < y`, it seemed like these two new cases were, in some
sense, missing.

Issues rust-lang/rust-clippy#685 and rust-lang/rust-clippy#753 appear
pertinent here.

----

changelog: [`double_comparisons`]: check and offer suggestions for
expressions such as `x != y && x >= y`
2026-01-17 08:56:36 +00:00
llogiq 3404c3b079 Remove empty stderr file from tests (#16421)
changelog: none
r? llogiq
2026-01-17 00:39:38 +00:00
llogiq 59b58ec061 Remove known problems from comparison_chain (#16422)
The current statement is incorrect as the call to `cmp` is inlined in
_optimised_ builds. See
https://github.com/rust-lang/rust-clippy/issues/5354#issuecomment-3762246553.

Revert https://github.com/rust-lang/rust-clippy/pull/6390

```
changelog: none
```
2026-01-17 00:39:10 +00:00
xtqqczze 696f616b78 Remove known problems from comparison_chain
This reverts commit e42ba4829c, reversing
changes made to d75bc868ca.
2026-01-16 23:59:16 +00:00
Samuel Tardieu dd61de95e4 Remove empty stderr file from tests 2026-01-17 00:42:02 +01:00
Samuel Tardieu bcde8c1070 Do not consider binary operators as commutative by default
Only `==` (and thus `!=`) are supposed to be commutative according to
Rust's documentation. Do not make assumptions about other operators
whose meaning may depend on the types on which they apply. However,
special-case operators known to be commutative for primitive types
such as addition or multiplication.
2026-01-17 00:36:09 +01:00
Ada Alakbarova 196c098d24 unnecessary_sort_by: reduce suggestion diffs
Now, only `call_span` is replaced, so the receiver is not a part of the
diff. This also removes the need to create a snippet for the receiver.
2026-01-16 22:47:48 +01:00
llogiq 69e70c89b1 Fix unnecessary_sort_by FN on field access (#16406)
Closes rust-lang/rust-clippy#16405
Closes rust-lang/rust-clippy#16348

changelog: [`unnecessary_sort_by`] fix FN on field access
2026-01-16 20:56:57 +00:00
llogiq 6802a56fc0 Do not output an error if standard output is full on --help/--version (#16412)
This matches rustc's behavior.

Fixes rust-lang/rust-clippy#16410

----

changelog: none
2026-01-16 20:35:29 +00:00
linshuy2 5937b8ba10 Apply unnecessary_sort_by to Clippy itself 2026-01-16 20:33:32 +00:00
linshuy2 c9bbf951c2 Allow unnecessary_sort_by to lint closures with input patterns 2026-01-16 20:31:14 +00:00
Samuel Tardieu b7e4315b32 Do not output an error if standard output is full on --help/--version
This matches rustc's behavior.
2026-01-16 18:10:29 +01:00
linshuy2 03fd408af5 Apply unnecessary_sort_by to Clippy itself 2026-01-16 16:48:59 +00:00
linshuy2 4cb70c8e4a fix: unnecessary_sort_by FN on field access 2026-01-16 16:48:55 +00:00
dswij 73d05ddd4e Post needless_continue diagnostic on the right node (#16265)
changelog: [`needless_continue`]: `allow` and `expect` attributes can
also be used on the statement triggering the lint instead of only the
whole loop.

Fixes rust-lang/rust-clippy#16256
2026-01-16 14:06:43 +00:00
Samuel Tardieu 5320bdb941 Suggest Cstr::count_bytes in strlen_on_c_strings (#16323)
Closes rust-lang/rust-clippy#16308

changelog: [`strlen_on_c_strings`]: changes suggestion to use
CStr::count_bytes()
2026-01-16 13:57:26 +00:00
Dima Khort 2f3b9ce72c feat(strlen_on_c_strings): suggest .count_bytes() 2026-01-16 14:42:02 +01:00
Samuel Tardieu a66ad939b5 Mention cast_signed in docs of cast_possible_wrap (#16407)
I was evaluating this lint recently, and accepted using it because these
methods exist.
But the docs on the lint don't mention it, so I thought it would be
prudent to include it in the docs.

See also https://github.com/rust-lang/rust-clippy/pull/15384

changelog: [`cast_possible_wrap`]: mention `cast_{un,}signed()` methods
in the documentation
2026-01-16 13:17:41 +00:00
Daniel McNab 19e0d7914f Mention cast_signed in docs of cast_possible_wrap
changelog: [`cast_possible_wrap`]: mention `cast_{un,}signed()` methods in doc

I was evaluating this lint recently, and accepted using it
because these methods exist.
But the docs on the lint don't mention it, so I thought
it would be prudent to include it in the docs.

See also https://github.com/rust-lang/rust-clippy/pull/15384

Co-authored-by: Kaur Kuut <strom@nevermore.ee>
Co-authored-by: Samuel Tardieu <sam@rfc1149.net>
2026-01-16 13:08:09 +00:00
Hugh 676d71a45b Defer is_from_proc_macro check and add tests
Move the is_from_proc_macro check inside check_fn_inner to be called
only right before emitting lints, rather than at the entry points.
This avoids the expensive check when early returns would prevent any
lint emission anyway.

Add tests for proc-macro generated code covering all check locations:
- Standalone functions
- Methods in impl blocks
- Trait methods
- Impl blocks with extra lifetimes
2026-01-15 16:39:24 -08:00