]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agoAuto merge of #9734 - alex-semenyuk:badge, r=giraffate
bors [Mon, 31 Oct 2022 00:15:57 +0000 (00:15 +0000)]
Auto merge of #9734 - alex-semenyuk:badge, r=giraffate

Fix Clippy Test badge

Clippy test badge always shows "no status" message. Fix it for showing real status
changelog: none

20 months agoAuto merge of #9747 - kraktus:option_if_let_else, r=Manishearth
bors [Sun, 30 Oct 2022 22:46:41 +0000 (22:46 +0000)]
Auto merge of #9747 - kraktus:option_if_let_else, r=Manishearth

[`option_if_let_else`] do not lint if any arm has guard

fix https://github.com/rust-lang/rust-clippy/issues/9742

changelog: [`option_if_let_else`] do not lint if any arm has guard

20 months agoAuto merge of #9755 - Alexendoo:restriction-cli-warn, r=Manishearth
bors [Sun, 30 Oct 2022 22:06:46 +0000 (22:06 +0000)]
Auto merge of #9755 - Alexendoo:restriction-cli-warn, r=Manishearth

Warn when `clippy::restriction` is enabled via the command line

Currently it catches `#![warn(clippy::restriction)]`, it'll now catch `-W clippy::restriction` from the CLI. Also tweaks the message slightly

changelog: [`blanket_clippy_restriction_lints`]: Warn when `clippy::restriction` is enabled via the command line

20 months agoWarn when clippy::restriction is enabled via the command line
Alex Macleod [Sun, 30 Oct 2022 21:15:46 +0000 (21:15 +0000)]
Warn when clippy::restriction is enabled via the command line

20 months ago[`option_if_let_else`] do not lint if any arm has guard
kraktus [Sat, 29 Oct 2022 14:32:11 +0000 (16:32 +0200)]
[`option_if_let_else`] do not lint if any arm has guard

20 months agoAuto merge of #9714 - Alexendoo:bool-to-int-if-let, r=xFrednet
bors [Sat, 29 Oct 2022 12:22:02 +0000 (12:22 +0000)]
Auto merge of #9714 - Alexendoo:bool-to-int-if-let, r=xFrednet

Fix `bool_to_int_with_if` false positive with `if let`

Fixes #9706

changelog: FP: [`bool_to_int_with_if`]: Now ignores `if let` statements

20 months agoFix `bool_to_int_with_if` false positive with `if let`
Alex Macleod [Sat, 29 Oct 2022 12:15:51 +0000 (12:15 +0000)]
Fix `bool_to_int_with_if` false positive with `if let`

20 months agoAuto merge of #9738 - kraktus:bool_to_int_with_if, r=xFrednet
bors [Sat, 29 Oct 2022 09:29:09 +0000 (09:29 +0000)]
Auto merge of #9738 - kraktus:bool_to_int_with_if, r=xFrednet

[`bool_to_int_with_if`] do not lint in const context

changelog: [`bool_to_int_with_if`] do not lint in const context

fix https://github.com/rust-lang/rust-clippy/issues/9737

20 months agoAuto merge of #9648 - llogiq:fix-undocumented-unsafe-blocks, r=Jarcho
bors [Sat, 29 Oct 2022 01:35:49 +0000 (01:35 +0000)]
Auto merge of #9648 - llogiq:fix-undocumented-unsafe-blocks, r=Jarcho

fix `undocumented-unsafe-blocks` false positive

This fixes #9142 by iterating over the parent nodes as long as within a block, expression, statement, local, const or static.

---

changelog: none

20 months agoAuto merge of #9711 - smoelius:issue-9710, r=Jarcho
bors [Sat, 29 Oct 2022 00:56:17 +0000 (00:56 +0000)]
Auto merge of #9711 - smoelius:issue-9710, r=Jarcho

Fix `needless_borrow` false positive #9710

Fixes #9710

changelog: fix `needless_borrow` false positive #9710

20 months agoAuto merge of #9741 - llogiq:fix-string-extend-chars-slice-ref, r=Manishearth
bors [Fri, 28 Oct 2022 22:43:07 +0000 (22:43 +0000)]
Auto merge of #9741 - llogiq:fix-string-extend-chars-slice-ref, r=Manishearth

fix the `string-extend-chars` suggestion on slice

This adds the missing `&` to the suggestion if the target is a `str` slice (e.g. extending with `"foo"[..].chars()`).

This closes #9735.

---

changelog: fix the `string-extend-chars` suggestion for `str` slices

20 months agofix `undocumented-unsafe-blocks` false positive
Andre Bogus [Fri, 14 Oct 2022 14:07:22 +0000 (16:07 +0200)]
fix `undocumented-unsafe-blocks` false positive

20 months agoFix badge
alexey semenyuk [Mon, 24 Oct 2022 21:59:21 +0000 (00:59 +0300)]
Fix badge

20 months agofix the `string-extend-chars` suggestion on slice
Andre Bogus [Fri, 28 Oct 2022 15:22:40 +0000 (17:22 +0200)]
fix the `string-extend-chars` suggestion on slice

This adds the missing `&` to the suggestion if the target is a
`str` slice (e.g. extending with `"foo"[..].chars()`).

20 months agoFix #9710
Samuel Moelius [Tue, 25 Oct 2022 09:54:22 +0000 (05:54 -0400)]
Fix #9710

20 months ago[`bool_to_int_with_if`] do not lint in const context
kraktus [Fri, 28 Oct 2022 12:45:16 +0000 (14:45 +0200)]
[`bool_to_int_with_if`] do not lint in const context

20 months agoAuto merge of #9733 - nbdd0121:master, r=dswij
bors [Fri, 28 Oct 2022 06:26:49 +0000 (06:26 +0000)]
Auto merge of #9733 - nbdd0121:master, r=dswij

Ensure new_ret_no_self is not fired if impl Trait<Self> is returned.

Fix #7344: ensure new_ret_no_self is not fired if `impl Trait<Self>` is returned.

changelog: [`new_ret_no_self`]: No longer lints when `impl Trait<Self>` is returned

20 months agoAuto merge of #9726 - kraktus:fix_use_self, r=Alexendoo
bors [Thu, 27 Oct 2022 22:08:07 +0000 (22:08 +0000)]
Auto merge of #9726 - kraktus:fix_use_self, r=Alexendoo

[`use_self`] fix suggestion when full path to struct was given

Previously the following wrong suggestion was given

```rust
impl Error for std::fmt::Error {
    fn custom<T: std::fmt::Display>(_msg: T) -> Self {
-        std::fmt::Error // Should lint
+        Self::Error // Should lint
    }
}
```

Also remove known problem line related to #4140 since it's been closed, and refactor the lint

changelog: [`use_self`] fix suggestion when full path to struct was given

20 months agoAdd unit tests for issue 7344
Gary Guo [Thu, 27 Oct 2022 17:50:42 +0000 (18:50 +0100)]
Add unit tests for issue 7344

20 months agoEnsure new_ret_no_self is not fired if `impl Trait<Self>` is returned.
Gary Guo [Thu, 27 Oct 2022 17:49:07 +0000 (18:49 +0100)]
Ensure new_ret_no_self is not fired if `impl Trait<Self>` is returned.

20 months agoAuto merge of #9722 - ebobrow:question-mark, r=Manishearth
bors [Thu, 27 Oct 2022 13:01:33 +0000 (13:01 +0000)]
Auto merge of #9722 - ebobrow:question-mark, r=Manishearth

`question_mark` don't lint on `if let Err` with `else`

cc #9518

AFAICT the only time this would be a valid suggestion is the rather esoteric

```rust
let _ = if let Err(e) = x {
    return Err(e);
} else {
    // no side effects
    x.unwrap()
}
```

which doesn't seem worth checking to me. Please correct me if I'm missing something.

changelog: [`question_mark`] don't lint on `if let Err` with `else`

20 months agoAuto merge of #9728 - dswij:uninlined-fargs-pedantic, r=flip1995
bors [Thu, 27 Oct 2022 12:37:28 +0000 (12:37 +0000)]
Auto merge of #9728 - dswij:uninlined-fargs-pedantic, r=flip1995

move `UNINLINED_FORMAT_ARGS` to pedantic

As discussed in zulip, we are moving this lint to pedantic to be backported

changelog: [`UNINLINED_FORMAT_ARGS`]: move to pedantic

20 months agomove `UNINLINED_FORMAT_ARGS` to pedantic
dswijj [Thu, 27 Oct 2022 09:49:43 +0000 (17:49 +0800)]
move `UNINLINED_FORMAT_ARGS` to pedantic

20 months agoAuto merge of #9674 - smoelius:needless-borrow-fp, r=Jarcho
bors [Thu, 27 Oct 2022 05:59:56 +0000 (05:59 +0000)]
Auto merge of #9674 - smoelius:needless-borrow-fp, r=Jarcho

Fix `needless_borrow` false positive

The PR fixes the false positive exposed by `@BusyJay's` example in: https://github.com/rust-lang/rust-clippy/issues/9111#issuecomment-1277114280

The current approach is described in https://github.com/rust-lang/rust-clippy/pull/9674#issuecomment-1289294201 and https://github.com/rust-lang/rust-clippy/pull/9674#issuecomment-1292225232.

The original approach appears below.

---

The proposed fix is to flag only "simple" trait implementations involving references, a concept
that I introduce next.

Intuitively, a trait implementation is "simple" if all it does is dereference and apply the trait
implementation of a type named by a type parameter. `AsRef` provides a good example of a simple
implementation: https://doc.rust-lang.org/std/convert/trait.AsRef.html#impl-AsRef%3CU%3E-for-%26T

We can make this idea more precise as follows. Given a trait implementation, first determine
whether the implementation is "used defined." If so, then examine its nested obligations.
Consider the implementation simple if-and-only-if:
- there is at least one nested obligation for the same trait
- for each type `X` in the nested obligation's substitution, either `X` is the same as that of
  the original obligation's substitution, or the original type is `&X`

For example, the following implementation from `@BusyJay's` example is "complex" (i.e., not simple)
because it produces no nested obligations:

```rust
impl<'a> Extend<&'a u8> for A { ... }
```

On the other hand, the following slightly modified implementation is simple, because it produces
a nested obligation for `Extend<X>`:

```rust
impl<'a, X> Extend<&'a X> for A where A: Extend<X> { ... }
```

How does flagging only simple implementations help? One way of interpreting the false positive in
`@BusyJay's` example is that it separates a reference from a concrete type. Doing so turns a
successful type inference into a failing one. By flagging only simple implementations, we
separate references from type variables only, thereby eliminating this class of false positives.

Note that `Deref` is a special case, as the obligations generated for it already involve the
underlying type.

r? `@Jarcho` (Sorry to keep pinging you with `needless_borrow` stuff. But my impression is no one knows this code better than you.)

changelog: fix `needless_borrow` false positive

20 months agoFix `needless_borrow` false positive
Samuel Moelius [Wed, 26 Oct 2022 23:31:01 +0000 (19:31 -0400)]
Fix `needless_borrow` false positive

20 months ago[`use_self`] fix suggestion when full path to struct was given
kraktus [Wed, 26 Oct 2022 16:10:40 +0000 (18:10 +0200)]
[`use_self`] fix suggestion when full path to struct was given

Previously the following wrong suggestion was given

```rust
impl Error for std::fmt::Error {
    fn custom<T: std::fmt::Display>(_msg: T) -> Self {
-        std::fmt::Error // Should lint
+        Self::Error // Should lint
    }
}
```

Also remove known problem line related to #4140 since it's been closed, and refactor the lint

20 months agoAuto merge of #9717 - Alexendoo:readme-note, r=flip1995
bors [Wed, 26 Oct 2022 08:35:42 +0000 (08:35 +0000)]
Auto merge of #9717 - Alexendoo:readme-note, r=flip1995

Remove note mentioning configuration changes need cargo clean

Missed this in #9707

changelog: none

20 months agoAuto merge of #9723 - Rageking8:fix-dupe-word-typos, r=llogiq
bors [Wed, 26 Oct 2022 05:48:25 +0000 (05:48 +0000)]
Auto merge of #9723 - Rageking8:fix-dupe-word-typos, r=llogiq

Fix dupe word typos

changelog: fix some typos

20 months agofix dupe word typos
Rageking8 [Wed, 26 Oct 2022 04:24:37 +0000 (12:24 +0800)]
fix dupe word typos

20 months ago`question_mark` don't lint on `if let Err` with else
Elliot Bobrow [Wed, 26 Oct 2022 04:16:28 +0000 (21:16 -0700)]
`question_mark` don't lint on `if let Err` with else

20 months agoAuto merge of #9681 - koka831:feat/add-seek-from-current-lint, r=giraffate
bors [Wed, 26 Oct 2022 00:07:16 +0000 (00:07 +0000)]
Auto merge of #9681 - koka831:feat/add-seek-from-current-lint, r=giraffate

feat: add new lint `seek_from_current`

changelog: `seek_from_current`: new lint to suggest using `stream_position` instead of seek from current position with `SeekFrom::Current(0)`

addresses https://github.com/rust-lang/rust-clippy/issues/7886.

This PR is related to https://github.com/rust-lang/rust-clippy/pull/9667, so I will update `methods/mod.rs` if it get conflicted.

20 months agoRemove note mentioning configuration changes need cargo clean
Alex Macleod [Tue, 25 Oct 2022 17:53:48 +0000 (17:53 +0000)]
Remove note mentioning configuration changes need cargo clean

20 months agoAuto merge of #9712 - Alexendoo:old-generated-files, r=flip1995
bors [Tue, 25 Oct 2022 13:20:31 +0000 (13:20 +0000)]
Auto merge of #9712 - Alexendoo:old-generated-files, r=flip1995

Remove `lib.register_*` and `src/docs*` in `cargo dev update_lints`

Follow up to #9709 / #9541

There's a good number of PRs with some leftover `src/docs` files for example, and as a reviewer it's something we're used to ignoring so it can easily slip through

r? `@flip1995`

changelog: none

20 months agoRemove `lib.register_*` and `src/docs*` in `cargo dev update_lints`
Alex Macleod [Tue, 25 Oct 2022 13:18:50 +0000 (13:18 +0000)]
Remove `lib.register_*` and `src/docs*` in `cargo dev update_lints`

20 months agoAuto merge of #9707 - Alexendoo:file-depinfo, r=flip1995
bors [Tue, 25 Oct 2022 12:08:46 +0000 (12:08 +0000)]
Auto merge of #9707 - Alexendoo:file-depinfo, r=flip1995

Track `clippy.toml` and `Cargo.toml` in `file_depinfo`

Causes cargo to re-run clippy when those paths are modified

Also tracks the path to `clippy-driver` in debug mode to remove the workarounds in `cargo dev lint` and `lintcheck` (cc `@matthiaskrgr)`

changelog: Automatically re-run Clippy if `Cargo.toml` or `clippy.toml` are modified

Fixes #2130
Fixes #8512

r? `@flip1995`

20 months agoTrack `clippy.toml` and `Cargo.toml` in `file_depinfo`
Alex Macleod [Tue, 25 Oct 2022 11:32:49 +0000 (11:32 +0000)]
Track `clippy.toml` and `Cargo.toml` in `file_depinfo`

Causes cargo to re-run clippy when those paths are modified

Also tracks the path to `clippy-driver` in debug mode to remove the
workarounds in `cargo dev lint` and `lintcheck`

20 months agoAuto merge of #9692 - llogiq:mutable-key-more-arcs, r=Alexendoo
bors [Tue, 25 Oct 2022 11:27:33 +0000 (11:27 +0000)]
Auto merge of #9692 - llogiq:mutable-key-more-arcs, r=Alexendoo

make ignored internally mutable types for `mutable-key` configurable

We had some false positives where people would create their own types that had interior mutability unrelated to hash/eq. This addition lets you configure this as e.g. `arc-like-types=["bytes::Bytes"]`

This fixes #5325 by allowing users to specify the types whose innards like `Arc` should be ignored (the generic types are still checked) for the sake of detecting inner mutability.

r? `@Alexendoo`

---

changelog: Allow configuring types to ignore internal mutability in `mutable-key`

20 months agoAuto merge of #9709 - koka831:chore/remove-unnecessary-files, r=flip1995
bors [Tue, 25 Oct 2022 07:57:45 +0000 (07:57 +0000)]
Auto merge of #9709 - koka831:chore/remove-unnecessary-files, r=flip1995

chore: remove unnecessary files

removes document text files that are no longer needed by #9541.

changelog: none

r? `@Alexendoo`

20 months agoAuto merge of #9700 - andreubotella:from-raw-with-void-non-box, r=flip1995
bors [Tue, 25 Oct 2022 07:45:32 +0000 (07:45 +0000)]
Auto merge of #9700 - andreubotella:from-raw-with-void-non-box, r=flip1995

Update `from_raw_with_void_ptr` to support types other than `Box`

This PR updates the `from_raw_with_void_ptr` lint, which covered
`Box::from_raw`, to also cover the `from_raw` static method of the
`Rc`, `Arc`, `alloc::rc::Weak` and `alloc::sync::Weak` types.

It also improves the description and error messages of this lint.

---

changelog: [`from_raw_with_void_ptr`]: Now works with the `Rc`, `Arc`, `alloc::rc::Weak` and `alloc::sync::Weak` types.

20 months agofeat: add new lint `seek_from_current`
koka [Tue, 25 Oct 2022 03:26:06 +0000 (12:26 +0900)]
feat: add new lint `seek_from_current`

addresses https://github.com/rust-lang/rust-clippy/issues/7886
added `seek_from_current` complexity lint.
it checks use of `Seek#seek` with `SeekFrom::Current(0)` and
suggests `Seek#stream_position` method

fix: add msrv

fix: register LintInfo

fix: remove unnecessary files

fix: add test for msrv

fix: remove

fix

fix: remove docs

20 months agochore: remove remove-unnecessary-files
koka [Tue, 25 Oct 2022 00:53:16 +0000 (09:53 +0900)]
chore: remove remove-unnecessary-files

removes document text files that are no longer needed by #9541.

20 months agoAuto merge of #9704 - kraktus:fix_use_self, r=giraffate
bors [Tue, 25 Oct 2022 00:29:03 +0000 (00:29 +0000)]
Auto merge of #9704 - kraktus:fix_use_self, r=giraffate

[`use_self`] fix FP when trait impl defined in macro

changelog: [`use_self`] fix FP when trait impl defined in macro

20 months agoAuto merge of #9667 - dorublanzeanu:master, r=giraffate
bors [Tue, 25 Oct 2022 00:14:59 +0000 (00:14 +0000)]
Auto merge of #9667 - dorublanzeanu:master, r=giraffate

add new lint `seek_to_start_instead_of_rewind `

changelog: `seek_to_start_instead_of_rewind`: new lint to suggest using `rewind` instead of `seek` to start

Resolve #8600

20 months agomake arc-likes for `mutable-key` configurable
Andre Bogus [Thu, 20 Oct 2022 21:40:10 +0000 (23:40 +0200)]
make arc-likes for `mutable-key` configurable

We had some false positives where people would create their own types
that had interior mutability unrelated to hash/eq. This addition lets
you configure this as e.g. `arc-like-types=["bytes::Bytes"]`

20 months agoAuto merge of #8437 - est31:let_else_lint, r=flip1995
bors [Mon, 24 Oct 2022 20:21:08 +0000 (20:21 +0000)]
Auto merge of #8437 - est31:let_else_lint, r=flip1995

Add lint to tell about let else pattern

Adds a lint to tell the user if the let_else pattern should be used.

~~The PR is blocked probably on rustfmt support, as clippy shouldn't suggest features that aren't yet fully supported by all tools.~~ Edit: I guess adding it as a restriction lint for now is the best option, it can be turned into a style lint later.

---

changelog: addition of a new lint to check for manual `let else`

20 months agoAlso consider match guards for divergence check
est31 [Sun, 16 Oct 2022 01:56:40 +0000 (03:56 +0200)]
Also consider match guards for divergence check

Plus, add some tests for the divergence check.

20 months agoFix dogfooding
est31 [Tue, 11 Oct 2022 22:04:09 +0000 (00:04 +0200)]
Fix dogfooding

20 months agoDon't fire the lint if there is a type annotation
est31 [Mon, 10 Oct 2022 19:51:24 +0000 (21:51 +0200)]
Don't fire the lint if there is a type annotation

Sometimes type annotations are needed for type inferrence to work,
or because of coercions. We don't know this, and we also don't
want users to possibly repeat the entire pattern.

20 months agoDon't lint if the let is already a let-else
oxalica [Mon, 10 Oct 2022 14:00:33 +0000 (16:00 +0200)]
Don't lint if the let is already a let-else

We cannot apply the lint for 3-branches like in the added example.

20 months agoMake an attempt of creating suggestions
est31 [Mon, 10 Oct 2022 05:17:04 +0000 (07:17 +0200)]
Make an attempt of creating suggestions

They aren't perfect but better than nothing

20 months agoMake the match checking configurable
est31 [Sat, 8 Oct 2022 00:50:30 +0000 (02:50 +0200)]
Make the match checking configurable

20 months agoReplace from_different_macros with equivalent and simpler check
est31 [Thu, 6 Oct 2022 21:07:58 +0000 (23:07 +0200)]
Replace from_different_macros with equivalent and simpler check

20 months agoDon't suggest let else in match if the else arm explicitly mentions non obvious paths
est31 [Sat, 19 Feb 2022 06:15:20 +0000 (07:15 +0100)]
Don't suggest let else in match if the else arm explicitly mentions non obvious paths

20 months agoSupport tuples
est31 [Fri, 18 Feb 2022 04:43:48 +0000 (05:43 +0100)]
Support tuples

20 months agoAlso support linting for match
est31 [Wed, 16 Feb 2022 01:10:42 +0000 (02:10 +0100)]
Also support linting for match

20 months agoAdd lint to tell about let else pattern
est31 [Sun, 13 Feb 2022 02:11:06 +0000 (03:11 +0100)]
Add lint to tell about let else pattern

20 months agoChange lint name to `seek_to_start_instead_of_rewind`
Doru-Florin Blanzeanu [Mon, 24 Oct 2022 15:54:08 +0000 (15:54 +0000)]
Change lint name to `seek_to_start_instead_of_rewind`

- This name makes more sense and highlights the issue

Signed-off-by: Doru-Florin Blanzeanu <blanzeanu.doru@protonmail.com>
20 months ago[`use_self`] fix FP when trait impl defined in macro
kraktus [Mon, 24 Oct 2022 16:25:59 +0000 (18:25 +0200)]
[`use_self`] fix FP when trait impl defined in macro

Found when working on `lintcheck --fix`

20 months agoAdd msrv check for `rewind_instead_of_seek_to_start` lint
Doru-Florin Blanzeanu [Fri, 21 Oct 2022 16:08:04 +0000 (16:08 +0000)]
Add msrv check for `rewind_instead_of_seek_to_start` lint

Signed-off-by: Doru-Florin Blanzeanu <blanzeanu.doru@protonmail.com>
20 months agoAdd new lint `rewind_instead_of_seek_to_start`
Doru-Florin Blanzeanu [Sun, 16 Oct 2022 19:31:03 +0000 (19:31 +0000)]
Add new lint `rewind_instead_of_seek_to_start`

Signed-off-by: Doru-Florin Blanzeanu <blanzeanu.doru@protonmail.com>
20 months agoUpdate `from_raw_with_void_ptr` to support types other than `Box`
Andreu Botella [Sun, 23 Oct 2022 19:14:52 +0000 (21:14 +0200)]
Update `from_raw_with_void_ptr` to support types other than `Box`

This PR updates the `from_raw_with_void_ptr` lint, which covered
`Box::from_raw`, to also cover the `from_raw` static method of the
`Rc`, `Arc`, `alloc::rc::Weak` and `alloc::sync::Weak` types.

It also improves the description and error messages of this lint.

---

changelog: [`from_raw_with_void_ptr`]: Now works with the `Rc`, `Arc`, `alloc::rc::Weak` and `alloc::sync::Weak` types.

20 months agoAuto merge of #9541 - Alexendoo:declare-proc-macro, r=flip1995
bors [Sun, 23 Oct 2022 22:18:04 +0000 (22:18 +0000)]
Auto merge of #9541 - Alexendoo:declare-proc-macro, r=flip1995

Generate lint categories and explanations with `declare_clippy_lint`

This means contributors will no longer have to run `cargo dev update_lints` after changing a lints documentation or its category, which may also mean fewer merge conflicts in general

It works by swapping `declare_clippy_lint` out for a `proc_macro` of the same name. The proc macro emits a `LintInfo` alongside the generated `Lint` which are gathered into `declared_lint::LINTS`. The categories/explanations are then read from `declared_lint::LINTS` at runtime

The removal of `src/docs` is split into a separate commit to be more easily ignored

It is slightly slower though, adding a bit under a second to build time. Less noticeable in full builds or with a slower linker (benchmark uses mold)

```bash
hyperfine --warmup 2 \
    --parameter-list commit "declare-proc-macro,master" \
    --command-name "{commit}" \
    --setup "git checkout {commit}" \
    --prepare "touch clippy_lints/src/lib.rs" \
    "cargo build"
```
```
Benchmark 1: declare-proc-macro
  Time (mean ± σ):     10.731 s ±  0.154 s    [User: 7.739 s, System: 1.791 s]
  Range (min … max):   10.598 s … 11.125 s    10 runs

Benchmark 2: master
  Time (mean ± σ):      9.422 s ±  0.094 s    [User: 7.183 s, System: 1.732 s]
  Range (min … max):    9.287 s …  9.624 s    10 runs

Summary
  'master' ran
    1.14 ± 0.02 times faster than 'declare-proc-macro'
```

r? `@flip1995`
cc `@llogiq` for `--explain`

changelog: none

20 months agoRemove `src/docs`
Alex Macleod [Sun, 23 Oct 2022 20:32:40 +0000 (20:32 +0000)]
Remove `src/docs`

20 months agoGenerate lint categories and explanations with `declare_clippy_lint`
Alex Macleod [Sun, 23 Oct 2022 20:32:26 +0000 (20:32 +0000)]
Generate lint categories and explanations with `declare_clippy_lint`

Changes it to be a proc_macro rather than macro_rules

20 months agoAuto merge of #9690 - royrustdev:boxed_void, r=flip1995
bors [Sun, 23 Oct 2022 17:17:32 +0000 (17:17 +0000)]
Auto merge of #9690 - royrustdev:boxed_void, r=flip1995

add `from_raw_with_void_ptr` lint

This PR `fixes #9679`

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

---

changelog:  [`from_raw_with_void_ptr`]: added new lint

20 months agoadd `boxed_void` lint
royrustdev [Sat, 22 Oct 2022 10:03:12 +0000 (15:33 +0530)]
add `boxed_void` lint

20 months agoAuto merge of #9368 - nahuakang:improve-equatable-if-let, r=flip1995
bors [Sun, 23 Oct 2022 15:31:46 +0000 (15:31 +0000)]
Auto merge of #9368 - nahuakang:improve-equatable-if-let, r=flip1995

Improvement for  `equatable_if_let`

fixes #9221

This PR makes sure that enums or structs not implementing `PartialEq` trait but still using the `if let` patterns can be linted to be rewritten with `matches!`.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[ ] Executed `cargo dev update_lints`
- \[ ] Added lint documentation
- \[x] Run `cargo dev fmt`

---

changelog: Improve [`equatable_if_let`] with additional `matches!` suggestions.

20 months agoAuto merge of #9630 - CatDevz:fix-aawr-lint, r=flip1995
bors [Sun, 23 Oct 2022 15:08:47 +0000 (15:08 +0000)]
Auto merge of #9630 - CatDevz:fix-aawr-lint, r=flip1995

Fix allow_attributes_without_reason applying to external crate macros

Previously the `clippy::allow_attributes_without_reason` lint would apply to external crate macros. Many macros in the Rust ecosystem include these `allow` attributes without adding a reason, making this lint pretty much unusable in any sizable Rust project.

This commit fixes that by adding a check to the lint if the attribute is from an external crate macro and returning early.

```
changelog: [`allow_attributes_without_reason`]: allow_attributes_without_reason no longer applies to external crate macros
```

20 months agoAuto merge of #9689 - koka831:fix/or_fun_call_map_or, r=flip1995
bors [Sun, 23 Oct 2022 14:23:08 +0000 (14:23 +0000)]
Auto merge of #9689 - koka831:fix/or_fun_call_map_or, r=flip1995

fix: support `map_or` for `or_fun_call` lint

fixes https://github.com/rust-lang/rust-clippy/issues/8993

The methods defined in `KNOW_TYPES`, except for `map_or`, accepts only one argument, so the matching `if let [arg] = args` works only for these methods.
This PR adds `rest_arg` argument to `check_general_case` method and handling of cases with two arguments to support `map_or`.

changelog: `or_fun_call` support `map_or`

* add `rest_arg` to pass second argument from `map_or(U, F)`
* extract some procedures into closure

20 months agofix: support `map_or` for `or_fun_call` lint
koka [Sat, 22 Oct 2022 07:36:36 +0000 (16:36 +0900)]
fix: support `map_or` for `or_fun_call` lint

* add `rest_arg` to pass second argument from `map_or(U, F)`
* extract some procedures into closure

refac: rename rest_arg/second_arg

refac: organize function argument order

* put `second_arg` next to `arg` argument

20 months agoAuto merge of #9697 - Alexendoo:let-underscore-uplift, r=flip1995
bors [Sun, 23 Oct 2022 14:11:38 +0000 (14:11 +0000)]
Auto merge of #9697 - Alexendoo:let-underscore-uplift, r=flip1995

Mark `let_underscore_lock` and `let_underscore_drop` as uplifted

Here I've renamed both the uplifted lints, however rustc's `let_underscore_lock` is slightly less capable than the clippy lint as it doesn't catch `parking_lot` types or `Result<Guard, ..>`, should we still remove it? The `Result` change looks like it was unintentional to me so that could probably be fixed upstream

changelog: Uplift [`let_underscore_drop`] to rustc https://github.com/rust-lang/rust/pull/97739
changelog: Remove overlap between rustc's `let_underscore_lock` and Clippy's [`let_underscore_lock`]

r? `@flip1995`

20 months agoRemove overlap between rustc and clippy `let_underscore_lock` lint
Alex Macleod [Sun, 23 Oct 2022 14:04:50 +0000 (14:04 +0000)]
Remove overlap between rustc and clippy `let_underscore_lock` lint

20 months agoMark `let_underscore_drop` as uplifted
Alex Macleod [Sun, 23 Oct 2022 13:45:26 +0000 (13:45 +0000)]
Mark `let_underscore_drop` as uplifted

20 months agoAuto merge of #9654 - alex-semenyuk:enable_test, r=Alexendoo
bors [Sun, 23 Oct 2022 13:35:20 +0000 (13:35 +0000)]
Auto merge of #9654 - alex-semenyuk:enable_test, r=Alexendoo

Enable test no_std_main_recursion

Verified that test actually works on windows
changelog: none

20 months agoAuto merge of #9686 - kraktus:unwrap_in_test_cfg, r=flip1995
bors [Sun, 23 Oct 2022 13:23:38 +0000 (13:23 +0000)]
Auto merge of #9686 - kraktus:unwrap_in_test_cfg, r=flip1995

[`unwrap_used`], [`expect_used`] do not lint in `test` cfg

changelog: [`unwrap_used`], [`expect_used`] do not lint in `test` cfg

fix https://github.com/rust-lang/rust-clippy/issues/9612

I've updated the doc and used `cfg` acronym, not sure if `conditional compiler flag` would have been better

20 months agoAuto merge of #9622 - llogiq:box-dyn-default, r=Alexendoo
bors [Sun, 23 Oct 2022 11:15:19 +0000 (11:15 +0000)]
Auto merge of #9622 - llogiq:box-dyn-default, r=Alexendoo

fix `box-default` ignoring trait objects' types

This avoids removing the turbofish when the `Box` type is a `dyn` or `impl _`.

This fixes #9621.

---

changelog: none

20 months agoAuto merge of #9688 - Alexendoo:msrv-tests, r=Manishearth
bors [Sun, 23 Oct 2022 05:05:23 +0000 (05:05 +0000)]
Auto merge of #9688 - Alexendoo:msrv-tests, r=Manishearth

Move MSRV tests into the lint specific test files

There are currently two ways MSRV tests are done in the ui test suite, adding a case to the `#![clippy::msrv = "1.0"]` `tests/ui/min_rust_version_attr.rs` or adding the two `msrv_1_xx` functions to the test file of the lint in question

This updates the clippy book to suggest the `msrv_1_xx` style, and replaces the tests in `tests/ui/min_rust_version_attr.rs` with ones of that style

Almost the entire diff is just moving stuff around as a result, I made sure to check the line numbers the lints are emitted at correspond with the right `msrv` case, so feel free to only skim that part

changelog: none

20 months agoExplicitly mention [cfg(test)]
kraktus [Sat, 22 Oct 2022 19:07:05 +0000 (21:07 +0200)]
Explicitly mention [cfg(test)]

Co-authored-by: llogiq <bogusandre@gmail.com>
20 months agoAuto merge of #9691 - smoelius:lint-lintcheck, r=llogiq
bors [Sat, 22 Oct 2022 18:42:12 +0000 (18:42 +0000)]
Auto merge of #9691 - smoelius:lint-lintcheck, r=llogiq

Add `lintcheck` to packages linted by `dogfood` test

Currently, `lintcheck` is not checked by the `dogfood` test. I assume that is not intentional. If it is intentional, then this PR can be ignored.

changelog: Add `lintcheck` to packages linted by `dogfood` test

20 months agoApply manual fixes
Samuel Moelius [Sat, 22 Oct 2022 11:12:07 +0000 (07:12 -0400)]
Apply manual fixes

20 months agoApply `--fix` fixes
Samuel Moelius [Sat, 22 Oct 2022 11:37:23 +0000 (07:37 -0400)]
Apply `--fix` fixes

20 months agoAdd `lintcheck` to packages linted by `dogfood` test
Samuel Moelius [Sat, 22 Oct 2022 11:37:10 +0000 (07:37 -0400)]
Add `lintcheck` to packages linted by `dogfood` test

20 months agoMove MSRV tests into the lint specific test files
Alex Macleod [Fri, 21 Oct 2022 21:35:39 +0000 (21:35 +0000)]
Move MSRV tests into the lint specific test files

20 months agoAuto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
bors [Fri, 21 Oct 2022 20:19:30 +0000 (20:19 +0000)]
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet

`ref_option_ref` do not lint when inner reference is mutable

changelog: FP: [`ref_option_ref`]: No longer lints if the inner reference is mutable

fix https://github.com/rust-lang/rust-clippy/issues/9682

20 months agoAuto merge of #9685 - kraktus:collapsible_match, r=llogiq
bors [Fri, 21 Oct 2022 19:27:35 +0000 (19:27 +0000)]
Auto merge of #9685 - kraktus:collapsible_match, r=llogiq

[`collapsible_match`] specify field name when destructuring structs

changelog: [`collapsible_match`] specify field name when destructuring structs

fix https://github.com/rust-lang/rust-clippy/issues/9647

I wasn't the sure about the best way to convey the message in the lint message since it does not use suggestion. Because I liked the former output highlighting both spans, I've left it as before, only modifying the span label.

20 months ago[`unwrap_used`], [`expect_used`] do not lint in `test` cfg
kraktus [Fri, 21 Oct 2022 13:27:25 +0000 (15:27 +0200)]
[`unwrap_used`], [`expect_used`] do not lint in `test` cfg

20 months ago[`collapsible_match`] specify field name when destructuring structs
kraktus [Fri, 21 Oct 2022 12:51:13 +0000 (14:51 +0200)]
[`collapsible_match`] specify field name when destructuring structs

20 months ago`ref_option_ref` do not lint when inner reference is mutable
kraktus [Fri, 21 Oct 2022 11:48:41 +0000 (13:48 +0200)]
`ref_option_ref` do not lint when inner reference is mutable

As it makes the `Option` Non Copy

20 months agoAuto merge of #9635 - smoelius:fix-9386-bug, r=Jarcho
bors [Thu, 20 Oct 2022 15:18:31 +0000 (15:18 +0000)]
Auto merge of #9635 - smoelius:fix-9386-bug, r=Jarcho

Fix bug introduced by #9386

#9386 introduced a potential out-of-bounds array access. Specifically, a location returned by `local_assignments` could have  [`location.statement_index` equal to `mir.basic_blocks[location.block].statements.len()`](https://github.com/rust-lang/rust-clippy/blob/b8a9a507bf9e3149d287841454842116c72d66c4/clippy_utils/src/mir/mod.rs#L129), in which case the location would refer to the block terminator:
https://github.com/rust-lang/rust-clippy/blob/b8a9a507bf9e3149d287841454842116c72d66c4/clippy_lints/src/dereference.rs#L1204-L1206
I suspect the bug is not triggerable now, because of checks leading up to where it occurs. But a future code change could make it triggerable. Hence, it should be fixed.

r? `@Jarcho`

changelog: none

20 months agoAuto merge of #9670 - Alexendoo:missing-trait-methods, r=Jarcho
bors [Thu, 20 Oct 2022 15:05:06 +0000 (15:05 +0000)]
Auto merge of #9670 - Alexendoo:missing-trait-methods, r=Jarcho

Add `missing_trait_methods` lint

Closes #9661

changelog: new lint: [`missing_trait_methods`]

20 months agoAuto merge of #9680 - flip1995:rustup, r=flip1995
bors [Thu, 20 Oct 2022 14:43:03 +0000 (14:43 +0000)]
Auto merge of #9680 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

I ran out of time and will have to do the Clippy->Rust sync tomorrow.

changelog: none

20 months agoBump nightly version -> 2022-10-20
Philipp Krones [Thu, 20 Oct 2022 14:39:44 +0000 (16:39 +0200)]
Bump nightly version -> 2022-10-20

20 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Thu, 20 Oct 2022 14:39:27 +0000 (16:39 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

20 months agoAdd `missing_trait_methods` lint
Alex Macleod [Mon, 17 Oct 2022 21:59:27 +0000 (21:59 +0000)]
Add `missing_trait_methods` lint

20 months agoAuto merge of #9634 - royrustdev:fix_redundant_allocation, r=Manishearth
bors [Wed, 19 Oct 2022 13:58:48 +0000 (13:58 +0000)]
Auto merge of #9634 - royrustdev:fix_redundant_allocation, r=Manishearth

Update Applicability of `redundant_allocation` lint from `MachineApplicable` to `MaybeIncorrect`

This changes `redundant_allocation` lint from MachineApplicable to MaybeIncorrect

```
changelog: [`redundant_allocation]: Change Applicability from MachineApplicable to MaybeIncorrect

```

fixes #6243

---
changelog: [`redundant_allocation`]: Change Applicability from MachineApplicable to MaybeIncorrect

20 months agoUpdate Applicability of `redundant_allocation` lint from
royrustdev [Wed, 12 Oct 2022 12:31:08 +0000 (18:01 +0530)]
Update Applicability of `redundant_allocation` lint from
`MachineApplicable` to `Unspecified`

20 months agoAuto merge of #9637 - Alexendoo:unused-format-specs, r=xFrednet
bors [Mon, 17 Oct 2022 11:51:32 +0000 (11:51 +0000)]
Auto merge of #9637 - Alexendoo:unused-format-specs, r=xFrednet

Add `unused_format_specs` lint

Currently catches two cases:

An empty precision specifier:

```rust
// the same as {}
println!("{:.}", x);
```

And using formatting specs on `format_args!()`:

```rust
// prints `x.`, not `x    .`
println("{:5}.", format_args!("x"));
```

changelog: new lint: [`unused_format_specs`]

20 months agoAdd `unused_format_specs` lint
Alex Macleod [Thu, 13 Oct 2022 12:13:54 +0000 (12:13 +0000)]
Add `unused_format_specs` lint

20 months agoAuto merge of #9609 - kraktus:hexa_f32, r=giraffate
bors [Mon, 17 Oct 2022 00:46:36 +0000 (00:46 +0000)]
Auto merge of #9609 - kraktus:hexa_f32, r=giraffate

[`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as floats

fix https://github.com/rust-lang/rust-clippy/issues/9603

changelog: [`unnecessary_cast`] Do not lint negative hexadecimal literals when cast as floats

20 months agoAuto merge of #9652 - kraktus:octo_89, r=xFrednet
bors [Sun, 16 Oct 2022 21:18:54 +0000 (21:18 +0000)]
Auto merge of #9652 - kraktus:octo_89, r=xFrednet

[`zero_prefixed_literal`] Do not advise to use octal form if not possible

fix https://github.com/rust-lang/rust-clippy/issues/9651

changelog: [`zero_prefixed_literal`] Do not advise to use octal form if not possible