This PR:
- lints more case of raw pointer comparisons
- do not omit the named function to raw pointer conversion before
suggesting
- trigger the `ptr_eq` lint only if `cmp_null` doesn't trigger first, as
this is a more specialized version
- lints against `!=` in addition to `==`
The `ptr_eq` code has been moved from under `operators` to `ptr.rs`, in
order to benefit from factorization.
Fix#14337
changelog: [`ptr_eq`]: handle more cases
Closes#13306Closes#9925Closes#9470Closes#9305
Clippy gives wrong suggestions when the key is not `Copy`. As suggested
in #9925, in such cases Clippy will simply warn but no fix.
changelog: [`map_entry`]: fix wrong suggestions when key is not `Copy`
Using `#[allow]` will also apply to child HIR nodes, while `#[expect]`
will ensure that the proper HIR node has been used for positioning the
lint.
changelog: none
changelog: [`implicit_saturating_sub`, `inverted_saturating_sub`]:
extend lints from local variables to side-effect free expressions
Noticed when #14308 introduced an implicit `saturating_sub` operation
and didn't get tagged.
Closes https://github.com/rust-lang/rust-clippy/issues/13169
Late lints now use a parent iter to check for `#[clippy::msrv]`
attributes instead of keeping track with `extract_msrv_attr`. This is
required for incremental lints since they run per module instead of per
crate so don't visit all the necessary attributes
As a basic optimisation if no `#[clippy::msrv]` attributes are
discovered in early passes the HIR access is skipped completely and just
the configured MSRV is used, for most code bases this will be the case
changelog: none
node_args doesn't work with struct literals and expr_ty must be used
instead
r? @y21
changelog: none
(No changelog, as this ICE didn't make it to the Rust repo, as it was
caught during the sync)
Fixes#14325
Out of cycle sync, as it is complicated and confusing to resolve merge
conflicts on the Rust side. This needs review for
eda3e649a41e0e73cb2e3ee6b98cbf8d7c12acae and
4d8766caaf11a14194406b8997243bb626000aae as well as the comment I'll
leave below.
changelog: none
This feature was stabilized, so the FormatArgs lints should check if the MSRV of
the stabilization is met, rather than checking if the feature is enabled.
It is not possible to write a declarative macro, that produces an
attribute w/o
an item attached to it. This means that the `check_item` will already
insert the
span in the map, if it came from an expansion. So additionally checking
if the
macro came from an expansion doesn't add anything here. So the
`check_attribute` function, and with that the problematic `attr.span()`
call can
be completely removed.
Fixes https://github.com/rust-lang/rust-clippy/issues/14303
r? @y21
cc @jdonszelmann
changelog: Fix ICE in [`macro_use_import`] lint
It is not possible to write a declarative macro, that produces an attribute w/o
an item attached to it. This means that the `check_item` will already insert the
span in the map, if it came from an expansion. So additionally checking if the
macro came from an expansion doesn't add anything here. So the
`check_attribute` function, and with that the problematic `attr.span()` call can
be completely removed.
Fixes#14303
The `looks_like_refdef` function was assuming the range was valid, this
just adds a check to ensure that is the case. It also works around a
subtraction underflow due to the same invalid range.
changelog: [`doc_nested_refdefs`]: Fix#14287 by avoiding invalid ranges
When the manually stripped entity receives a name as the first use
through a simple `let` statement, this name can be used in the generated
`if let Some(…)` expression instead of a placeholder.
Fix#14183
changelog: [`manual_strip`]: reuse existing identifier in suggestion
when possible
For some reason, the `todo!` and `unimplemented!` macros were not
included in the list of format-supporting macros list. Since they seem
to behave exactly the same as all others like `write!` and `assert!`,
adding them now.
I wonder if we should delete the `FORMAT_MACRO_DIAG_ITEMS`, and instead
tag all macros with the `#[clippy::format_args]`?
changelog: all format-handling lints will now validate `todo!` and
`unimplemented!` macros.
These method chains can be expressed concisely with `if`/`else`.
changelog: [`obfuscated_if_else`]: support `then().unwrap_or_else()` and
`then_some().unwrap_or_else()`