minor fix in `from_str_radix_10` lint, `is_type_diagnostic_item` only
checks `Adt`, use `.is_str()` instead
changelog: [`from_str_radix_10`]: properly lint references to `&str` as
well
combine two similar arms
use in `eager_transmute`
use in `double_ended_iterator_last`
use different numbers in the new test case to avoid possible confusion
move the other "unfixable" case as well; it shouldn't lint anyway, so
having it in the main test file is fine
changelog: [infinite_loop]: Improve handling of infinite loops in async
blocks
Fixrust-lang/rust-clippy#14000
This PR refines the [infinite_loop] lint to avoid false positives when
infinite loops occur inside async blocks that are not awaited (such as
those that are spawned or assigned to variables for later use). The lint
will now only trigger when the async block containing the loop is
directly awaited.
changelog: [`collapsible_else_if`]: fix suggestion when inner `if` as
wrapped in parentheses
changelog: [`collapsible_if`]: fix suggestion when inner `if` as wrapped
in parentheses
fixes https://github.com/rust-lang/rust-clippy/issues/15303
I'm sure this is a bit dirty, but don't currently see a better way.
The `unnecessary_sort_by` lint displays different method names in
message and suggestion, which is a bit confusing.
Also got a question about `UNNECESSARY_SORT_BY` lint definition. Should
we extend its message to also cover *_unstable_* methods?
changelog: [`unnecessary-sort-by`]: sort method consistency in message
and suggestion
Now that `if let` chains have been introduced, the `if_chain` external
crate is no longer necessary. Dropping special support for it also
alleviates the need to keep the crate as a dependency in tests.
This is a cleanup PR.
changelog: none
base check
same fields different struct
reordered fields
different paths to the same struct
same for tuple structs
style: use `zip`-the-function all over the place
makes the code a bit more concise by removing the need for explicit
`.iter()`
style: move precondition checking to the match guard
the match arms above put the "sanity" checks in the guard, and call only
`check_pat` in the body. With this commit, the (tuple) struct cases
follow that convention as well. Well, almost -- I think the ident check
belongs to the second category of checks, so I put it in the body as
well
misc: use `None` in the pattern directly
this'll probably be marginally faster thanks to the equality check being
now structural
move the tests to the right file
When an expression is made of a `!` or `-` unary operator which does not
change the type of the expression, use a new variant in `Sugg` to denote
it. This allows replacing an extra application of the same operator by
the removal of the original operator instead.
Some suggestions will now be shown as `x` instead of `!!x`. Right now,
no suggestion seems to produce `--x`.
changelog: none
When an expression is made of a `!` or `-` unary operator which does not
change the type of the expression, use a new variant in `Sugg` to denote
it. This allows replacing an extra application of the same operator by
the removal of the original operator instead.
Also, when adding a unary operator to a suggestion, do not enclose the
operator argument in parentheses if it starts with a unary operator
itself unless it is a binary operation (including `as`), because in this
case parentheses are required to not bind the lhs only.
Some suggestions will now be shown as `x` instead of `!!x`. Right now,
no suggestion seems to produce `--x`.
When a bare CR is present in a four slashes comment, keep triggering the
lint but do not issue a fix suggestion as bare CRs are not supported in
doc comments. An extra note is added to the diagnostic to warn the user
about it.
I have put the test in a separate file to make it clear that the bare CR
is not a formatting error.
Fixesrust-lang/rust-clippy#15174
changelog: [`four_forward_slashes`]: warn about bare CR in comment, and
do not propose invalid autofix
Now that `if let` chains have been introduced, the `if_chain` external
crate is no longer necessary. Dropping special support for it also
alleviates the need to keep the crate as a dependency in tests.
Closesrust-lang/rust-clippy#15348
The span of the `as` expr is also incorrect, but I believe it is not a
bug from Clippy.
changelog: [`cast-lossless`] fix wrong suggestions when casting type is
from macro input