This fixes an issue where clippy suggests passing a function that takes
no arguments as the first argument of `Result::map_or_else`. The
function needs to take one argument. Example that triggers the issue:
[Playground
link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=0b6f9bc7b6ab4dcd26745065544e0b8a)
Fixes#10335.
changelog: [`option_if_let_else`]: fix incorrect suggestion when the
contents of an `Err` variant are ignored
This test, which checks that we do not define new profiles directly in
Clippy's multiple `Cargo.toml` files, must not look inside `target` as
`lintcheck` might place some third-party sources there. Of course those
third-party sources are allowed to define profiles in their
`Cargo.toml`.
changelog: none
This test, which checks that we do not define new profiles directly in
Clippy's multiple `Cargo.toml` files, must not look inside `target` as
`lintcheck` might place some third-party sources there. Of course those
third-party sources are allowed to define profiles in their `Cargo.toml`.
Fix `unnecessary_unwrap` false negative when unwrapping a known value
inside a macro call
Fixesrust-lang/rust-clippy#12295
Produces no changes to `lintcheck`
changelog: [`unnecessary_unwrap`]: Fix false negative when unwrapping a
known value inside a macro call
I made sue to run `cargo dev fmt`.
I also ran the following checks (in order) on a fresh clone of mi fork:
1. `cargo build`
2. `cargo test`
3. `cargo lintcheck`
Running `cargo test` after `lintcheck` causes a test to fail, but this
also happens on a clean fork without my changes
Fixes https://github.com/rust-lang/rust-clippy/issues/13357
Determining the exact placement of the `if !to_ref_ty.is_sized()`s
required meticulously constructing the suggestion/truth table of
`is_sized`, `msrv.meets` and `has_erased_regions`. The test cases should
hopefully cover all the new combinations.
changelog: [`transmute_ptr_to_ref`]: don't suggest `.cast` when to-type
is DST
This recognizes the following expression as being equivalent to the
question mark:
```rust
match x {
Ok(v) => v,
Err(e) => return Err(e.into()), // or `Into::into(x)` or `<T as Into<U>>::into(x)`
}
```
Fixesrust-lang/rust-clippy#15679
changelog: [`question_mark`]: recognizes a match with an early return
with a call to `.into()` as possibly equivalent to a question mark
Putting this lint in `/methods` is simpler and probably slightly more
efficient.
changelog: [`ptr_offset_with_cast`]: respect MSRV when suggesting fix,
and lint even more cases
decided to put each lint extraction into a separate commit this time --
do let me know if you prefer all of that being in a single commit
instead
changelog: none
- move tests to `ui-toml/`, since they all use `clippy.toml`
- remove the trait test case from `ref_option.rs`, because it's already
covered by `ref_option_traits.rs`
I was looking for the function that peels refs from a type while also
returning the number of refs peeled, and it turns out there were
actually two of them?? I removed the by far less popular one, and made
some other clean-up along the way
changelog: none
Fixes https://github.com/rust-lang/rust-clippy/issues/13277
Unfortunately breaks another case, which has only been working thanks to
the now fixed bug -- see last commit.
changelog: [`use_self`]: don't early-return if the outer type has no
lifetimes
- give `ty::walk_ptrs_hir_ty` a more standard name
`peel_hir_ty_refs_and_ptrs`
- move it out of `ty`, since that's for `middle::ty::Ty`
- remove `ty::walk_ptrs_ty_depth` for equivalent `peel_middle_ty_refs`
- rename the latter into `ty::peel_and_count_ty_refs`
- incorporate mutability tracking (from
`ty::peel_mid_ty_refs_is_mutable`) into that
Have `as_underscore` only make a suggestion when the type is
suggestable.
changelog: [`as_underscore`]: Don't suggest a fix if the type is not
suggestable
Fixesrust-lang/rust-clippy#15282
changelog: [`cast_sign_loss`, `cast_possible_wrap`]: add suggestion
using `cast_{un,}signed()` methods
Fixesrust-lang/rust-clippy#14150
This PR adds a suggestion to `cast_sign_loss` and `cast_possible_wrap`,
which fixes reported warnings using the `cast_{un,}signed()` methods, as
proposed in rust-lang/rust-clippy#14150. Suggestions are only made if
MSRV is >=1.87.
Also, I'm not 100% sure about the suggestion message yet. I'm open for
suggestions.