fixesrust-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
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
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.
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
Fixesrust-lang/rust-clippy#16416
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
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.
Fixesrust-lang/rust-clippy#16316
---
changelog: [`elidable_lifetime_names`]: skip linting proc-macro
generated code to avoid broken fix suggestions
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
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`
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: [`needless_continue`]: `allow` and `expect` attributes can
also be used on the statement triggering the lint instead of only the
whole loop.
Fixesrust-lang/rust-clippy#16256
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
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>
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