#2597 appears to be already resolved, so the applicability of `op_ref`
can be set to `MachineApplicable`.
close#2597
changelog: [`op_ref`]: set the applicability to `MachineApplicable`
Closes#11346.
Partially fix#9905. The first case in this issue is a little tricky as
the coerce does not happen in the borrowing.
changelog: [`borrow_deref_ref`]: fix wrong suggestions when coerce to
mut
Closes#11617Closes#14368
Clippy gives wrong suggestions when the filter and then cannot be put
into closure directly. Since trying to transform these can be too
complicated, Clippy will simply warn but don't try to fix.
changelog: [`filter_map_bool_then`]: fix wrong suggestions when the
closure cannot be decompose directly
The applicability of `never_loop` is currently set to `Unspecified`, but
if the loop block does not contain `break` or `continue`, it can be
`MachineApplicable`.
changelog: [`never_loop`]: the applicability is now `MachineApplicable`
when the loop block contains neither `break` nor `continue`
fixes#13964
The lint `option_map_unwrap_or` used to have a similar issue in #10579,
so I borrowed its solution to fix this one.
changelog: [`option_if_let_else`]: fix FP when value partially moved
Commit efe3fe9b8c removed the ability for
`single_match` and `single_match_else` to trigger if comments were
present outside of the arms, as those comments would be lost while
rewriting the `match` expression.
This reinstates the lint, but prevents the suggestion from being applied
automatically in the presence of comments by using the `MaybeIncorrect`
applicability. Also, a note is added to the lint message to warn the
user about the need to preserve the comments if acting upon the
suggestion.
changelog: [`single_match`, `single_match_else`]: reinstate lint when
comments are inside the `match` but do not autofix the code
Fix#14418
Fixes https://github.com/rust-lang/rust-clippy/issues/14175.
There are two "big" cases to handle: `.map(|x| x.to_string())` and
`.map(String::to_string)`. If the closure has more than one expression,
we should not suggest `.cloned()`.
changelog: Improve `string_to_string` lint in case it is in a map call
r? @samueltardieu
Commit efe3fe9b8c removed the ability for
`single_match` and `single_match_else` to trigger if comments were
present outside of the arms, as those comments would be lost while
rewriting the `match` expression.
This reinstates the lint, but prevents the suggestion from being applied
automatically in the presence of comments by using the `MaybeIncorrect`
applicability. Also, a note is added to the lint message to warn the
user about the need to preserve the comments if acting upon the
suggestion.
close#12157
`needless_return` sometimes makes incorrect suggestions by omitting
necessary enclosing parentheses. This PR resolves the issue by using
`clippy_utils::sugg::Sugg`.
changelog: [`needless_return`]: now makes correct suggestions which
require enclosing parentheses
Fixes https://github.com/rust-lang/rust-clippy/issues/12163
I decided to initially make this a restriction lint because it felt a
bit niche and opinionated to be a warn-by-default style lint. It may be
appropriate as a style lint if the standard or convention *is* to use
`\` as doc comment linebreaks - not sure if they are!
The wording on the help message could be improved, as well as the name
of the lint itself since it's a bit wordy - suggestions welcome.
This lint works on both `///` and `//!` doc comments.
changelog: new lint: `doc_comment_double_space_linebreaks`
The lint for function calls was previously restricted to functions
taking exactly one argument. This was not documented.
Generalizing the lint to an arbitrary number of arguments in the
function call requires special casing some macro expansions from the
standard library. Macros such as `panic!()` or `assert_eq!()` exist
since Rust 1.0.0, but modern stdlib expand those macros into calls to
functions introduced in later Rust versions. While it is desirable to
lint code inside macros, using MSRV-incompatible functions coming from
`core` in macro expansions has been special-cased to not trigger this
lint.
Also, code coming from compiler desugaring may contain function calls
(for example, `a..=b` is now desugared into `RangeInclusive::new(a, b)`.
Those should not be linted either as the compiler is allowed to use
unstable function calls.
Fix#14212
changelog: [`incompatible_msrv`]: lint function calls with any argument
count
If types such as `Option<Option<String>>` are not used by value, then
`Option<Option<&String>>` will be suggested, instead of
`Option<&Option<String>>`.
changelog: [`needless_pass_by_value`]: suggest using a reference on the
innermost `Option` content
fix#14375
Last part of https://github.com/rust-lang/rust-clippy/pull/11421.
Now all ui tests require annotations.
The change in `ui_test` is to add `ICE:` errors.
changelog: Make internals ui tests annotations mandatory
r? @flip1995
If types such as `Option<Option<String>>` are not used by value, then
`Option<Option<&String>>` will be suggested, instead of
`Option<&Option<String>>`.
Follow-up of https://github.com/rust-lang/rust-clippy/pull/11421.
I can't yet make the annotations mandatory because there is an issue
with `tests/ui-internal/custom_ice_message.rs`: the error message is not
emitted as JSON, meaning that we can't match it with `ui_test`. I need
to check if it's a bug in rustc or if `ui_test` needs to handle this
case somehow.
changelog: Add missing tests annotations for `ui-internal`
r? @flip1995