Fix `semicolon_if_nothing_returned` FP on `let-else` stmts
closes#7912
`semicolon_if_nothing_returned` now additionally checks if the statements ends in `;` , this will also prevent `let-else` statements to be linted.
changelog: fix [`semicolon_if_nothing_returned`] FP firing on `let-else`
`match_overlapping_arm` refactoring
The main purpose of this pull request is to remove the unneeded and scary `unimplented!()` in the `match_arm_overlapping` code.
The rest is gratuitous refactoring.
changelog: none
Fix `explicit_counter_loop` suggestion for non-usize types
changelog: Add a new suggestion for non-usize types in [`explicit_counter_loop`]
closes: #7920
Fix suggestion for deref expressions in redundant_pattern_matching
changelog: Fix suggestion for deref expressions in [`redundant_pattern_matching`]
closes: #7921
Only the end bounds of ranges can actually be included or excluded. This
commit changes the SpannedRange type to reflect that. Update `Kind::value`
to and `Kind::cmp` for this change. `Kind::cmp` gets flipped to check value
first and then the bound details and is much shorter.
This unbounded case never actually happens because `all_ranges(..)` uses
the scrutinee type bounds for open ranges. Switch to our own `Bound`
enum so that we don't have this case.
Introduce `expr_visitor` and `expr_visitor_no_bodies`
changelog: none
A couple utils that satisfy a *lot* of visitor use cases. Factoring in every possible usage would be really big so I just focused on cleaning clippy_utils.
Add `cargo dev lint` to manually run clippy on a file
I found the manual run command really useful, this makes it a bit easier to type
Not sure if this belongs in the changelog or not
changelog: Add `cargo dev lint` to manually run clippy on a file
Replace `in_macro` usage with `from_expansion`
changelog: none
Generally replace `in_macro(span)` with `span.from_expansion()`. If we're just trying to avoid expanded code, this seems more appropriate because any kind of expanded code is prone to false positives. One place I did not touch is `macro_use.rs`. I think this lint could use a rewrite so I moved `in_macro` there, the only place it is still used.
Reference `clippy_utils` docs on nightly-rustc and some other documentation updates
The `clippy_utils` crate is now part of the nightly-rustc documentation. See [**very beautiful documentation**](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/). This PR references them in our documentation and updates some other documentation.
changelog: none
Update Clippy dependencies
Clippy has two outdated dependencies, where one indirect dependency has been flagged by rustsec for dropping a lifetime. See [RUSTSEC-2020-0146](https://rustsec.org/advisories/RUSTSEC-2020-0146). This PR updates these dependencies.
With previous dependency updates, it was tried to prevent duplicates in the `Cargo.lock` file of rust-lang/rust. I've tried to keep this in mind with this update.
* Dependency `semver`
* Used in `src/tools/cargo/Cargo.toml` as version `1.0.3`
* Used in `src/tools/rust-analyzer/crates/project_model/Cargo.toml` as version `1`
* Updated in Clippy from `0.11` to `1.0` (Clippy usually defines the major and minor patch version). The `Cargo.lock` file lists `1.0.3` which is one patch version behind the most recent one but prevents a duplicate with cargo's pinned version.
* Dependency `cargo_metadata`
* Used in several tools as `0.14`
* Used in `src/tools/tidy` and `src/tools/rls` as `0.12`
* Updated in Clippy from `0.12` to `0.14`
All updates to the `Cargo.lock` have been done automatically by `x.py`.
There are still some tools with these outdated dependencies. Clippy didn't require any changes, and it would be likely that the others could also be updated without any problem. Let me know if I should try to update them as well 🙃.
Keep up the good work, whoever is reading this 🦀
---
For Clippy:
changelog: none