Matthias Krüger [Tue, 9 Mar 2021 13:06:42 +0000 (14:06 +0100)]
lintcheck: make sure we lauch from the repo root
This will terminate the program if run via "cargo run".
"cargo run" does currently not work because at least a bunch of paths do not take that into account.
bors [Wed, 10 Mar 2021 16:27:18 +0000 (16:27 +0000)]
Auto merge of #6794 - camsteffen:needless-borrowed-ref, r=flip1995
Improve needless_borrowed_ref docs
changelog: none
I think "borrowed ref" is a confusing description for this lint. Destructuring a reference is the opposite of borrowing. So I updated the wording throughout the docs. Unfortunately this nit applies to the name of the lint itself, but I won't bother changing that. One motivation for these changes is to clarify the difference between this lint and `needless_borrow` (they are actually quite different). Let me know if I need to clarify anything or if you disagree with any changes.
bors [Wed, 10 Mar 2021 08:40:51 +0000 (08:40 +0000)]
Auto merge of #79519 - cjgillot:noattr, r=wesleywiser
Store HIR attributes in a side table
Same idea as #72015 but for attributes.
The objective is to reduce incr-comp invalidations due to modified attributes.
Notably, those due to modified doc comments.
Implementation:
- collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables;
- access the attributes through a `hir_owner_attrs` query;
- local refactorings to use this access;
- remove `attrs` from HIR data structures one-by-one.
Change in behaviour:
- the HIR visitor traverses all attributes at once instead of parent-by-parent;
- attribute arrays are sometimes duplicated: for statements and variant constructors;
- as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints.
~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~
bors [Tue, 9 Mar 2021 18:42:09 +0000 (18:42 +0000)]
Auto merge of #6878 - flip1995:authors, r=Manishearth
Set Clippy authors to "The Rust Clippy Developers"
Clippy has grown enough, that putting specific people in the "authors"
field isn't warranted anymore.
As a heads-up: `@Manishearth` `@llogiq` `@birkenfeld` `@mcarton` `@oli-obk` `@phansch` `@matthiaskrgr` your names will be removed from one or more of the `Cargo.toml` files of Clippy. This of course does not mean that we value your previous work on Clippy any less :heart:
As per our discussion in today's meeting: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202021-03-09/near/229502514
kadmin [Mon, 5 Oct 2020 22:53:00 +0000 (22:53 +0000)]
Update match branches
This updates all places where match branches check on StatementKind or UseContext.
This doesn't properly implement them, but adds TODOs where they are, and also adds some best
guesses to what they should be in some cases.
bors [Mon, 8 Mar 2021 16:03:20 +0000 (16:03 +0000)]
Auto merge of #6725 - Y-Nak:refactor-types-lints, r=flip1995
Refactor types lints
Ref #6724.
As described in #6724, `types.rs` contains many groups inside it.
In this PR, I reorganize the lints of the `types` group into their own modules.
bors [Mon, 8 Mar 2021 13:18:39 +0000 (13:18 +0000)]
Auto merge of #6834 - hyd-dev:clippy-args, r=phansch,flip1995,oli-obk
Let Cargo track CLIPPY_ARGS
This PR makes `clippy-driver` emit `CLIPPY_ARGS` in its `dep-info` output.
Just like #6441, this allows this workflow to work:
```shell
cargo clippy # warning: empty `loop {}` wastes CPU cycles
cargo clippy -- -A clippy::empty_loop # no warnings emitted
```
But without rebuilding all dependencies.
cc https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/CLIPPY_ARGS.20is.20not.20tracked.20by.20Cargo/near/228599088
changelog: Cargo now re-runs Clippy if arguments after `--` provided to `cargo clippy` are changed.
bors [Mon, 8 Mar 2021 00:04:48 +0000 (00:04 +0000)]
Auto merge of #6807 - anall:feature/use_new_diagnostics, r=Manishearth
migrate paths to newly-added diagnostic items
This gets rid of the following paths:
* OS_STRING
* TO_OWNED
* TO_STRING
Removes some usages of:
* PATH_BUF
Per #5393
also removes unneeded `is_ty_param_path` from `clippy_lints::types` and relocates `is_ty_param_lang_item` and `is_ty_param_diagnostic_item` to `clippy_utils`.
bors [Sun, 7 Mar 2021 22:58:11 +0000 (22:58 +0000)]
Auto merge of #6853 - Jarcho:len_without_is_empty_fp, r=Manishearth
`len_without_is_empty` will now consider multiple impl blocks
fixes #1562
This also reverts #1559 as the `#[allow]` now works on the `len` method. A note has also been added to point out where the `empty` method is, if it exists.
changelog: `len_without_is_empty` will now consider multiple impl blocks
changelog: `len_without_is_empty` will now consider `#[allow]` on both the `len` method, and the type definition
Jason Newcomb [Fri, 5 Mar 2021 18:01:13 +0000 (13:01 -0500)]
`len_without_is_empty` will now consider multiple impl blocks
`len_without_is_empty` will now consider `#[allow]` on both the `len` method, and the type definition
bors [Fri, 5 Mar 2021 21:10:52 +0000 (21:10 +0000)]
Auto merge of #6848 - matthiaskrgr:lintcheck_clippyfix, r=llogiq
lintcheck: add --fix mode which tries to apply lint suggestions to th…
…e sources and prints a warning if that fails
Great for spotting false positives/broken suggestions of applicable lints.
There are false positives though because I'm not sure yet how to silence rustc warnings while keeping clippy warnings.
Sometimes rustc makes a suggestion that fails to apply and the implementation does not differentiate between clippy and rustc warnings when applying lint suggestions.
Matthias Krüger [Fri, 5 Mar 2021 08:30:12 +0000 (09:30 +0100)]
lintcheck: add --fix mode which tries to apply lint suggestions to the sources and prints a warning if that fails
Great for spotting false positives/broken suggestions of applicable lints.
There are false positives though becasue I'm not sure yet how to silence rustc warnings while keeping clippy warnings.
Sometimes rustc makes a suggestion that fails to apply and the implementation does not differenciate between clippy and rustc warnings when applying lint suggestions.