Factor out `clippy_utils` crate
As discussed in https://github.com/rust-lang/rust-clippy/pull/6746, this PR factors out `clippy_lints::utils` as its own crate, `clippy_utils` .
This change will allow `clippy_utils` to be used in lints outside of Clippy.
There is no plan to publish this crate on `crates.io` (see https://github.com/rust-lang/rust-clippy/pull/6746#issuecomment-780747522). Dependent crates should obtain it from GitHub.
changelog: Factor out `clippy_utils` so it can be used by external tools (not published)
README: Add subsection on running Clippy as a rustc wrapper
This is useful for projects that do not use cargo.
changelog: README: Add subsection on running Clippy as a rustc wrapper
lintcheck fix build (forgot to pass function parameter) and runtime (…
…don't check metadata of directory if it does not exist)
Accidentally broke lintcheck in my previous commit.
changelog: None
lintcheck: fully rerun lintcheck if clippy was rebuilt since last log update
Automatically clean lintchecks shared target dir (will force clippy to recheck sources) if
the clippy binaries are older than the lintcheck logs.
Also updated lintcheck logs in the pr.
changelog: lintcheck: fully rerun lintcheck if clippy was rebuilt since last log update
Automatically clean lintchecks shared target dir (will force clippy to recheck sources) if
the clippy binaries are older than the lintcheck logs.
Also update lintcheck logs
Quick fix cargo dev bless
fixes#6757
r? `@phansch`
Trying to do a quick fix of `bless`, I'm not sure how much work it will need to do transition to `bless` built in `compiletest`, so please feel free to close this PR if it will not need so much.
changelog: none
upper_case_acronyms: move lint from style to pedantic lint group
The lint does point out inconsistency with the Rust naming convention,
but the fact that rustc does not warn about the inconsistency by default
means that clippy probably should not warn by default either.
changelog: move upper_case_acronyms lint from style to pedantic group.
The lint does point out inconsistency with the Rust naming convention,
but the fact that rustc does not warn about the inconsistency by default
means that clippy probably should not warn by default either.
changelog: move upper_case_acronyms lint from style to pedantic group.
Inconsistent struct constructor
fixes: #6352
r? `@matthiaskrgr`
I added the lint that checks for the struct constructors where the order of the field init shorthands is inconsistent with that in the struct definition.
changelog: Add style lint: `inconsistent_struct_constructor`
Fix FP in inherent_to_string when the function has generic parameters
Minimal example of the false positive:
````
struct G;
impl G {
fn to_string<const _N: usize>(&self) -> String {
"G.to_string()".to_string()
}
}
fn main() {
let g = G;
g.to_string::<1>();
}
````
Clippy emits an `inherent_to_string` warning, and suggests that we implement `Display` for `G` instead. However, this is not possible, since the generic parameter _N only exists in this function, not in `G` itself. This particular example uses const generics, which is where the issue is most likely to come up, but this PR skips the lint if the `to_string` function has any kind of generic parameters.
changelog: Fix FP in `inherent_to_string`
Change unnecessary_wraps to pedantic
changelog: Change unnecessary_wraps to pedantic
There seems to be enough evidence that this lint is not wanted as warn-by-default. Attempted before at #6380. False positives at #6721 and #6427. Actually requested to change the category at #6726.
Closes#6726
Teach SpanlessEq binding IDs
changelog: Fix collapsible_match false positive
Fixes#6740
This PR changes the way `SpanlessEq` determines whether two local variables are the same. Instead of checking that the names match, it checks that the `HirId`s match. If local bindings are declared within the expressions that are being compared, `SpanlessEq` will remember bindings that correspond to each other in a `FxHashMap<HirId, HirId>`. This makes `SpanlessEq` more flexible while also fixing false positives.
Example: `{ let x = 1; x + 2 }` is equal to `{ let y = 1; y + 2 }`.
CC `@xFrednet` I think this will resolve some concerns in #6463