]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agotest: update tests for manual_instant_elapsed lint
Nadir Fejzic [Mon, 7 Nov 2022 20:37:04 +0000 (21:37 +0100)]
test: update tests for manual_instant_elapsed lint

20 months agorefactor: improve code re-use in InstantSubtraction lint pass
Nadir Fejzic [Mon, 7 Nov 2022 20:34:24 +0000 (21:34 +0100)]
refactor: improve code re-use in InstantSubtraction lint pass

20 months agodocs: update docs for unchecked duration subtr. lint
Nadir Fejzic [Mon, 7 Nov 2022 19:59:55 +0000 (20:59 +0100)]
docs: update docs for unchecked duration subtr. lint

20 months agorefactor: lint man. instant elapsed and unch. dur. subtr. in single pass
Nadir Fejzic [Mon, 7 Nov 2022 19:58:49 +0000 (20:58 +0100)]
refactor: lint man. instant elapsed and unch. dur. subtr. in single pass

20 months agostyle: remove `dbg!` call
Nadir Fejzic [Sat, 1 Oct 2022 14:50:56 +0000 (16:50 +0200)]
style: remove `dbg!` call

20 months agodocs: add docs for `unchecked_duration_subtraction` lint
Nadir Fejzic [Sat, 1 Oct 2022 14:50:45 +0000 (16:50 +0200)]
docs: add docs for `unchecked_duration_subtraction` lint

20 months agotest: add tests for 'unchecked_duration_subtraction' lint
Nadir Fejzic [Sat, 1 Oct 2022 14:02:57 +0000 (16:02 +0200)]
test: add tests for 'unchecked_duration_subtraction' lint

20 months agofeat: add and implement unchecked_duration_subtraction lint
Nadir Fejzic [Sat, 1 Oct 2022 13:58:10 +0000 (15:58 +0200)]
feat: add and implement unchecked_duration_subtraction lint

20 months agoAuto merge of #9813 - Jarcho:issue_9811, r=xFrednet
bors [Wed, 9 Nov 2022 14:06:42 +0000 (14:06 +0000)]
Auto merge of #9813 - Jarcho:issue_9811, r=xFrednet

Fix `explicit_auto_deref` fp

fixes #9763
fixes #9811

changelog: `explicit_auto_deref`: Don't lint when the target type is a projection with generic arguments

20 months agoAuto merge of #9817 - mgrachev:patch-1, r=Manishearth
bors [Tue, 8 Nov 2022 16:07:32 +0000 (16:07 +0000)]
Auto merge of #9817 - mgrachev:patch-1, r=Manishearth

Update lint example for `collapsible_str_replace`

To fix this warning:
```
warning: the borrowed expression implements the required traits
  --> src/fixes/quote_character.rs:16:43
   |
16 |         let hello = "hesuo worpd".replace(&['s', 'u', 'p'], "l");
   |                                           ^^^^^^^^^^^^^^^^ help: change this to: `['s', 'u', 'p']`
   |
   = note: `#[warn(clippy::needless_borrow)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
```

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none

20 months agoAuto merge of #9791 - smoelius:issues-9739-9782, r=Jarcho
bors [Tue, 8 Nov 2022 14:15:40 +0000 (14:15 +0000)]
Auto merge of #9791 - smoelius:issues-9739-9782, r=Jarcho

Address issues 9739 and 9782

This PR fixes #9739 in the manner I suggested in https://github.com/rust-lang/rust-clippy/issues/9739#issuecomment-1296802376.

This PR also fixes the compilation failures in #9782 (but doesn't address `@e00E's` other objections).

Fixes #9739

r? `@Jarcho`

changelog: Fix two `needless_borrow` false positives, one involving borrows in `if`-`else`s, the other involving qualified function calls

20 months agoAuto merge of #9818 - rs017991:patch-1, r=Jarcho
bors [Tue, 8 Nov 2022 13:58:04 +0000 (13:58 +0000)]
Auto merge of #9818 - rs017991:patch-1, r=Jarcho

Fixed Typo

changelog: none

20 months agoFixed Typo
Ryan Scheidter [Tue, 8 Nov 2022 13:48:39 +0000 (07:48 -0600)]
Fixed Typo

20 months agoUpdate lint example for `collapsible_str_replace`
Grachev Mikhail [Tue, 8 Nov 2022 12:33:50 +0000 (15:33 +0300)]
Update lint example for `collapsible_str_replace`

20 months agoAuto merge of #9765 - koka831:feat/manual_is_ascii_check, r=xFrednet
bors [Tue, 8 Nov 2022 09:20:52 +0000 (09:20 +0000)]
Auto merge of #9765 - koka831:feat/manual_is_ascii_check, r=xFrednet

Add `manual_is_ascii_check` lint

Addresses https://github.com/rust-lang/rust-clippy/issues/9290

This PR adds new lint `manual_is_ascii_check`, which detects comparison with ascii ranges using `matches!` macros.

As I mentioned as following in the Issue;
> Yes, that's true. we'll start small and then grow it.
> So I'll try to handle matches! macro with single range as suggested above.

However during writing first version, I was thinking that the changes to support alphabetic and digits will be small patch, so I made a single PR in hope review cost can be reduced.

changelog: add new lint [`manual_is_ascii_check`]

r? `@xFrednet`

20 months agoAuto merge of #8744 - Jarcho:needless_collect_fp, r=llogiq
bors [Mon, 7 Nov 2022 20:47:27 +0000 (20:47 +0000)]
Auto merge of #8744 - Jarcho:needless_collect_fp, r=llogiq

Extend `needless_collect`

Extends when `is_empty` and `contains` are linted.

`is_empty` will be linted when `<IterTy as Iterator>::Item` is the same as `<CollectTy as IntoIterator>::Item`. This can be a false positive if the `FromIterator` implementation filters out items, but I don't know of any which do that also implement `IntoIterator` with a matching `Item` type.

`contains` will be linted when the argument type is `&<IterTy as Iterator>::Item`. It has the same false positives as `is_empty` with the same note that I know of nothing that actually causes that in practice.

changelog: Lint `needless_collect` when `is_empty` or `contains` is called on some non-std types

20 months agoDon't lint `explicit_auto_deref` when the target type is a projection containing...
Jason Newcomb [Mon, 7 Nov 2022 19:08:40 +0000 (14:08 -0500)]
Don't lint `explicit_auto_deref` when the target type is a projection containing a generic argument

20 months agoLint `needless_collect` on non-std collection types
Jason Newcomb [Wed, 20 Apr 2022 20:10:18 +0000 (16:10 -0400)]
Lint `needless_collect` on non-std collection types

20 months agoMove `needless_collect` into the `methods` lint pass
Jason Newcomb [Fri, 22 Apr 2022 22:49:15 +0000 (18:49 -0400)]
Move `needless_collect` into the `methods` lint pass

20 months agoAuto merge of #9705 - jntrnr:disable_needless_collect, r=Manishearth
bors [Mon, 7 Nov 2022 17:08:10 +0000 (17:08 +0000)]
Auto merge of #9705 - jntrnr:disable_needless_collect, r=Manishearth

Move needless_collect to nursery

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`needless_collect`]: Move `needless_collect` to nursery (Now allow-by-default)

After chatting with a few folks, it seems like `needless_collect` is giving false positives pretty regularly (https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+needless_collect). We're big supporters of clippy in Nushell, and it's one of the passes we require for CI, but we've had to disable this particular lint. Perhaps it should be moved to the nursery until it's improved?

(apologies if this isn't the right approach to disabling a lint by default. I tried to follow the idea I saw other PRs doing in the past)

20 months agoAuto merge of #9804 - Alexendoo:coc, r=flip1995
bors [Mon, 7 Nov 2022 08:45:48 +0000 (08:45 +0000)]
Auto merge of #9804 - Alexendoo:coc, r=flip1995

Update CoC to rust-lang/rust's

I spotted mentions of IRC channels that no longer exist when grepping, so this updates it to the same as the one in https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md

r? `@flip1995`

changelog: none

20 months agofeat: implement manual_is_ascii_check lint
koka [Mon, 24 Oct 2022 14:49:59 +0000 (23:49 +0900)]
feat: implement manual_is_ascii_check lint

modify

fix: allow unused in test code

fix: types in doc comment

Update clippy_lints/src/manual_is_ascii_check.rs

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
Update clippy_lints/src/manual_is_ascii_check.rs

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
Update clippy_lints/src/manual_is_ascii_check.rs

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
fix ui test result

fix: unnecessary format!

chore: apply feedbacks

* check msrvs also for const fn
* check applicability manually
* modify documents

20 months agoAuto merge of #9760 - SquareMan:let_underscore_future, r=llogiq
bors [Sat, 5 Nov 2022 21:34:24 +0000 (21:34 +0000)]
Auto merge of #9760 - SquareMan:let_underscore_future, r=llogiq

Add new lint [`let_underscore_future`]

This closes #9721
---

changelog: add new lint [`let_underscore_future`]

20 months agoUpdate CoC to rust-lang/rust's
Alex Macleod [Sat, 5 Nov 2022 21:03:14 +0000 (21:03 +0000)]
Update CoC to rust-lang/rust's

20 months agoAuto merge of #9797 - trevarj:print-config, r=xFrednet
bors [Sat, 5 Nov 2022 09:49:40 +0000 (09:49 +0000)]
Auto merge of #9797 - trevarj:print-config, r=xFrednet

Add allow-print-in-tests config

Add a config, allow-print-in-tests, that can be set in clippy.toml which allows the usage of `[e]print[ln]!` macros in tests.

Closes #9795

---

changelog: Enhancement: [print_stdout], [print_stderr]: Can now be enabled in test with the `allow-print-in-tests` config value

20 months agoAuto merge of #9799 - bebecue:patch-1, r=dswij
bors [Sat, 5 Nov 2022 07:03:02 +0000 (07:03 +0000)]
Auto merge of #9799 - bebecue:patch-1, r=dswij

Update lint `suspicious_to_owned`

changelog: [`suspicious_to_owned`]: Use explicit type annotation on lint description instead of `matches!`

20 months agoBless all let_underscore tests
Steven Casper [Sat, 5 Nov 2022 04:21:55 +0000 (21:21 -0700)]
Bless all let_underscore tests

20 months agobless
Steven Casper [Sat, 5 Nov 2022 04:09:26 +0000 (21:09 -0700)]
bless

20 months agoMore backticks
Steven Casper [Sat, 5 Nov 2022 03:59:31 +0000 (20:59 -0700)]
More backticks

20 months agoAuto merge of #9753 - smoelius:changelog, r=xFrednet
bors [Fri, 4 Nov 2022 21:57:46 +0000 (21:57 +0000)]
Auto merge of #9753 - smoelius:changelog, r=xFrednet

Update CONTRIBUTING.md with changelog guidance

`@xFrednet` I cribbed some text of yours from https://github.com/rust-lang/rust-clippy/pull/9743#issuecomment-1295892442 and did some light editing in the hope that others might find it.

r? `@xFrednet`

changelog: Update CONTRIBUTING.md with changelog guidance

20 months agoUpdate lint `suspicious_to_owned`
bebecue [Fri, 4 Nov 2022 20:44:02 +0000 (04:44 +0800)]
Update lint `suspicious_to_owned`

`matches!(data, String)` will matches any type, replace it with explicit type annotation.

20 months agoAdd allow-print-in-tests config
Trevor Arjeski [Fri, 4 Nov 2022 17:33:04 +0000 (20:33 +0300)]
Add allow-print-in-tests config

Add a config, allow-print-in-tests, that can be set in clippy.toml which
allows the usage of `[e]print[ln]!` macros in tests.

Closes #9795

20 months agoAddress issues 9739 and 9782
Samuel Moelius [Fri, 4 Nov 2022 11:19:45 +0000 (11:19 +0000)]
Address issues 9739 and 9782

20 months agoAuto merge of #9779 - koka831:fix/unnecessary-join-message, r=Jarcho
bors [Thu, 3 Nov 2022 16:30:21 +0000 (16:30 +0000)]
Auto merge of #9779 - koka831:fix/unnecessary-join-message, r=Jarcho

fix turbofish in suggest message

changelog: [`unnecessary_join`] fix turbofish in suggest message

20 months agofix turbofish in suggest message
koka [Thu, 3 Nov 2022 14:53:29 +0000 (23:53 +0900)]
fix turbofish in suggest message

20 months agoAuto merge of #9761 - xFrednet:changelog-1-65, r=giraffate,xFrednet
bors [Thu, 3 Nov 2022 14:49:43 +0000 (14:49 +0000)]
Auto merge of #9761 - xFrednet:changelog-1-65, r=giraffate,xFrednet

Changelog for Rust 1.65

Roses are red,
violets are blue,
another 6 weeks,
another changelog, yahoo!

This did not rhyme,
luckily, not a crime.
I want to say something smart,
but I am out of time.

---

Note for the reviewer. This PR is written, as if Rust was already released on 2022-11-03. Please review the changes and approve if you agree, but only merge it after the release. :)

---

changelog: none

20 months agoAuto merge of #9773 - Alexendoo:ice-9746, r=Manishearth
bors [Wed, 2 Nov 2022 22:05:20 +0000 (22:05 +0000)]
Auto merge of #9773 - Alexendoo:ice-9746, r=Manishearth

Fix ICE in `redundant_allocation`

changelog: Fix ICE in `redundant_allocation`

Closes #9746, the original issue was fixed already, this gets the one in https://github.com/rust-lang/rust-clippy/issues/9746#issuecomment-1297132880

20 months agoAuto merge of #9772 - lukas-code:doc-spans, r=Manishearth
bors [Wed, 2 Nov 2022 15:40:07 +0000 (15:40 +0000)]
Auto merge of #9772 - lukas-code:doc-spans, r=Manishearth

Shrink `missing_{safety,errors,panics}_doc` spans

Shrink the spans of `clippy::missing_*_doc` to match `missing_docs` and don't cover the entire item anymore. This helps readability in IDEs by not coloring the entire screen yellow, similar to https://github.com/rust-lang/rust/pull/103749 and https://github.com/rust-lang/rust/pull/90761.

before:
![image](https://user-images.githubusercontent.com/26522220/199483288-af0cf0c2-a9e4-47a8-81e3-50ccf380d939.png)

after:
![image](https://user-images.githubusercontent.com/26522220/199483366-445e5ddd-9f71-4de1-85be-43461c9b7d5d.png)

changelog: [`missing_safety_doc`], [`missing_error_doc`], [`missing_panics_doc`]: These lints no longer span the entire item.

20 months agoFix ICE in `redundant_allocation`
Alex Macleod [Wed, 2 Nov 2022 13:24:34 +0000 (13:24 +0000)]
Fix ICE in `redundant_allocation`

20 months agoshrink `missing_{safety,errors,panics}_doc` spans
Lukas Markeffsky [Wed, 2 Nov 2022 11:47:46 +0000 (12:47 +0100)]
shrink `missing_{safety,errors,panics}_doc` spans

20 months agoFix examples
Steven Casper [Wed, 2 Nov 2022 00:27:43 +0000 (17:27 -0700)]
Fix examples

20 months agoSurround let with backticks
Steven Casper [Tue, 1 Nov 2022 21:27:28 +0000 (14:27 -0700)]
Surround let with backticks

20 months agoUn-ingnore code snippets
Steven Casper [Tue, 1 Nov 2022 21:26:18 +0000 (14:26 -0700)]
Un-ingnore code snippets

20 months agoChangelog for Rust 1.65 :traffic_light:
xFrednet [Mon, 31 Oct 2022 20:24:26 +0000 (21:24 +0100)]
Changelog for Rust 1.65 :traffic_light:

20 months agoAuto merge of #9743 - smoelius:improve-needless-lifetimes, r=Alexendoo
bors [Tue, 1 Nov 2022 00:25:30 +0000 (00:25 +0000)]
Auto merge of #9743 - smoelius:improve-needless-lifetimes, r=Alexendoo

Improve `needless_lifetimes`

This PR makes the following improvements to `needless_lifetimes`.

* It fixes the following false negative, where `foo` is flagged but `bar` is not:
  ```rust
    fn foo<'a>(x: &'a u8, y: &'_ u8) {}

    fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {}
  ```
* It flags more cases, generally. Previously, `needless_borrow` required *all* lifetimes to be used only once. With the changes, individual lifetimes are flagged for being used only once, even if not all lifetimes are.
* Finally, it tries to produce more clear error messages.

changelog: fix `needless_lifetimes` false negative involving functions with multiple unnamed lifetimes
changelog: in `needless_lifetimes`, flag individual lifetimes used only once, rather than require all lifetimes to be used only once
changelog: in `needless_lifetimes`, emit "replace with `'_`" warnings only when applicable, and point to a generic argument

20 months agoChange two `<=` to `==` for clarity
Samuel Moelius [Tue, 1 Nov 2022 00:12:37 +0000 (20:12 -0400)]
Change two `<=` to `==` for clarity

20 months agoUpdate lint versions for 1.65
xFrednet [Mon, 31 Oct 2022 20:28:02 +0000 (21:28 +0100)]
Update lint versions for 1.65

20 months agoupdate_lints
Steven Casper [Mon, 31 Oct 2022 19:56:04 +0000 (12:56 -0700)]
update_lints

20 months agoImplement let_underscore_future
Steven Casper [Mon, 31 Oct 2022 19:50:59 +0000 (12:50 -0700)]
Implement let_underscore_future

20 months agoAuto merge of #9506 - blyxyas:master, r=giraffate
bors [Mon, 31 Oct 2022 00:28:59 +0000 (00:28 +0000)]
Auto merge of #9506 - blyxyas:master, r=giraffate

Add lint for confusing use of `^` instead of `.pow`

fixes #4205
Adds a lint named [`confusing_xor_and_pow`], it warns the user when `a ^ b` is used as the `.pow()` function, it doesn't warn for Hex, Binary... etc.

---

changelog: New lint: [`confusing_xor_and_pow`]

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 agoUpdate CONTRIBUTING.md
Samuel Moelius [Sun, 30 Oct 2022 11:53:40 +0000 (07:53 -0400)]
Update CONTRIBUTING.md

20 months agoAdress review comments
Samuel Moelius [Sun, 30 Oct 2022 10:47:35 +0000 (06:47 -0400)]
Adress review comments

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 adjacent code
Samuel Moelius [Fri, 28 Oct 2022 17:18:07 +0000 (13:18 -0400)]
Fix adjacent code

20 months agoImprove `needless_lifetimes`
Samuel Moelius [Fri, 28 Oct 2022 17:17:36 +0000 (13:17 -0400)]
Improve `needless_lifetimes`

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 agoUpdate clippy_lints/src/suspicious_xor_used_as_pow.rs
Alex ✨ Cosmic Princess ✨ [Thu, 27 Oct 2022 19:32:36 +0000 (21:32 +0200)]
Update clippy_lints/src/suspicious_xor_used_as_pow.rs

Co-authored-by: NAKATA Takayuki <f.seasons017@gmail.com>
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 agoLints updated
Alex [Tue, 25 Oct 2022 18:35:16 +0000 (20:35 +0200)]
Lints updated

20 months agoJust lint changes
Alex [Fri, 21 Oct 2022 17:46:47 +0000 (19:46 +0200)]
Just lint changes

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