Fixes#13793.
Interestingly enough, to actually check that the macro call has at least
two arguments, we need to use the rust lexer after getting the original
source code snippet.
changelog: Add new `useless_concat` lint
fixes#12979fixes#12951fixes#13233
Tests still need to be finished and the docs still need to be updated,
but this should otherwise ready.
changelog: Lint `declare_interior_mutable_const` and
`borrow_interior_mutable_const` more precisely
Added lint for catching `&[foo.clone()]` where foo is a reference and
suggests `std::slice::from_ref(foo)`.
changelog: new lint: [`cloned_ref_to_slice_refs`]
The MSRV being for crates targeting 1.85-1.87 on edition 2024
This enables the lint for regular nightly users without the feature gate
enabled
r? @samueltardieu
Fixes https://github.com/rust-lang/rust-clippy/issues/14678
changelog: none
Closes#9191Closes#14444Closes#8055
Adds a new helper to partly check for side effects by recursively
checking if the iterator type contains closures with mutable captures.
changelog: [`double_ended_iterator_last`] fix FP when iter has side
effects
changelog: [`needless_collect`] fix lint not consider side effects
I'm removing empty identifiers everywhere, because in practice they
always mean "no identifier" rather than "empty identifier". (An empty
identifier is impossible.) It's better to use `Option` to mean "no
identifier" because you then can't forget about the "no identifier"
possibility.
Some specifics:
- When testing an attribute for a single name, the commit uses the
`has_name` method.
- When testing an attribute for multiple names, the commit uses the new
`has_any_name` method.
- When using `match` on an attribute, the match arms now have `Some` on
them.
In the tests, we now avoid printing empty identifiers by not printing
the identifier in the `error:` line at all, instead letting the carets
point out the problem.
This PR has started as an effort to proceed from the feedback in
rust-lang/rust-clippy#12861.
- Checks test functions (functions marked with `#[test]` annotation) for
redundant "test_" prefix.
- Auto-fix is supported (and handles collisions gracefully, see below).
- If removing "test_" prefix from, say, `test_foo()` results in a name
collision (either because function `foo()` is already defined within the
current scope, or because the `foo()` call exists within function --
thus creating an unwanted recursion), lint suggests function rename,
warning the user that a simple trimming of `test_` prefix will result in
a name collision.
- If removing "test_" prefix results in invalid identifier (consider
`test_const`, `test_`, `test_42`), then again no auto-fix is suggested,
user is asked to rename function, with a note that a simple prefix
trimming will result in an invalid function name.
(`Applicability::HasPlaceholders` is used and user is suggested to: drop
`test_` prefix + add `_works` suffix, i.e. `test_foo` becomes
`foo_works` -- but again, user has to apply those changes manually).
- If trimmed version of the function name is a valid identifier, doesn't
result in name collision or unwanted recursion, then user is able to run
auto-fix.
fixesrust-lang/rust-clippy#8931
changelog: new lint: [`redundant_test_prefix`]
It's a much better name, more consistent with how we name such things.
Also rename `Lifetime::res` as `Lifetime::kind` to match. I suspect this
field used to have the type `LifetimeRes` and then the type was changed
but the field name remained the same.
Fix#14461:
- insert parentheses as required in suggestion
- check MSRV before suggesting fix in `const` context
- do not lint macro expansion result
Commits have been logically separated to facilitate review, and start
with a refactoring (and simplification) of the existing code.
changelog: [`manual_is_power_of_two`]: insert parentheses as required in
suggestion, check MSRV before suggesting fix in `const` context, do not
lint macro expansion results