Commit graph

15463 commits

Author SHA1 Message Date
Nadir Fejzic
708c2d95c1 feat: add and implement unchecked_duration_subtraction lint 2022-11-10 15:46:41 +01:00
bors
432baf7026 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
2022-11-09 14:06:42 +00:00
bors
c4fbe54ac3 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
2022-11-08 16:07:32 +00:00
bors
b9ca3195ab 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
2022-11-08 14:15:40 +00:00
bors
4e31877ef9 Auto merge of #9818 - rs017991:patch-1, r=Jarcho
Fixed Typo

changelog: none
2022-11-08 13:58:04 +00:00
Ryan Scheidter
43a6d0b39c
Fixed Typo 2022-11-08 07:48:39 -06:00
Grachev Mikhail
70010850e4
Update lint example for collapsible_str_replace 2022-11-08 15:33:50 +03:00
bors
4abe815729 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`
2022-11-08 09:20:52 +00:00
bors
5857a01742 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
2022-11-07 20:47:27 +00:00
Jason Newcomb
5b1e445b9a Don't lint explicit_auto_deref when the target type is a projection containing a generic argument 2022-11-07 14:39:45 -05:00
Jason Newcomb
8bfc8bc5e0 Lint needless_collect on non-std collection types 2022-11-07 14:14:04 -05:00
Jason Newcomb
b0dcb862c6 Move needless_collect into the methods lint pass 2022-11-07 13:15:39 -05:00
bors
213003b887 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)
2022-11-07 17:08:10 +00:00
bors
927f7da20f 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
2022-11-07 08:45:48 +00:00
koka
e4540ad65f
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
2022-11-07 16:39:36 +09:00
bors
d15e5e6ad6 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`]
2022-11-05 21:34:24 +00:00
Alex Macleod
fa694ec809 Update CoC to rust-lang/rust's 2022-11-05 21:03:14 +00:00
bors
e5474113be 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
2022-11-05 09:49:40 +00:00
bors
9e0de8cedc 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!`
2022-11-05 07:03:02 +00:00
Steven Casper
7c5b1887c2 Bless all let_underscore tests 2022-11-04 21:21:55 -07:00
Steven Casper
398f9468df bless 2022-11-04 21:09:26 -07:00
Steven Casper
93dab8fea2 More backticks 2022-11-04 20:59:31 -07:00
bors
4cb9681a28 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
2022-11-04 21:57:46 +00:00
bebecue
f86c35c326
Update lint suspicious_to_owned
`matches!(data, String)` will matches any type, replace it with explicit type annotation.
2022-11-05 04:44:02 +08:00
Trevor Arjeski
ddcfff6d9a 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
2022-11-04 20:33:04 +03:00
Samuel Moelius
50f63a0f24 Address issues 9739 and 9782 2022-11-04 11:19:45 +00:00
bors
704e00cb75 Auto merge of #9779 - koka831:fix/unnecessary-join-message, r=Jarcho
fix turbofish in suggest message

changelog: [`unnecessary_join`] fix turbofish in suggest message
2022-11-03 16:30:21 +00:00
koka
05006e58c0
fix turbofish in suggest message 2022-11-03 23:53:29 +09:00
bors
6b4e7dd547 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
2022-11-03 14:49:43 +00:00
bors
8d7f638816 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
2022-11-02 22:05:20 +00:00
bors
647644b8f6 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.
2022-11-02 15:40:07 +00:00
Alex Macleod
517605e1fd Fix ICE in redundant_allocation 2022-11-02 13:30:58 +00:00
Lukas Markeffsky
d35b7de1d5 shrink missing_{safety,errors,panics}_doc spans 2022-11-02 12:47:46 +01:00
Steven Casper
b7d9af278c Fix examples 2022-11-01 17:53:41 -07:00
Steven Casper
139f2a3cda Surround let with backticks 2022-11-01 14:27:28 -07:00
Steven Casper
9f618b196a Un-ingnore code snippets 2022-11-01 14:26:18 -07:00
xFrednet
30e662d686
Changelog for Rust 1.65 🚥 2022-11-01 15:38:43 +01:00
bors
7600535511 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
2022-11-01 00:25:30 +00:00
Samuel Moelius
c0d928561c Change two <= to == for clarity 2022-10-31 20:12:37 -04:00
xFrednet
9e7996b149
Update lint versions for 1.65 2022-10-31 22:11:17 +01:00
Steven Casper
1f930452b9 update_lints 2022-10-31 12:56:04 -07:00
Steven Casper
6dcade0692 Implement let_underscore_future 2022-10-31 12:50:59 -07:00
bors
37d338c1ef 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`]
2022-10-31 00:28:59 +00:00
bors
60d171873a 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
2022-10-31 00:15:57 +00:00
bors
00610b30f9 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
2022-10-30 22:46:41 +00:00
bors
10e07cc484 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
2022-10-30 22:06:46 +00:00
Alex Macleod
b16a534618 Warn when clippy::restriction is enabled via the command line 2022-10-30 21:15:46 +00:00
Samuel Moelius
bde33a399d Update CONTRIBUTING.md 2022-10-30 08:09:31 -04:00
Samuel Moelius
2c44398487 Adress review comments 2022-10-30 06:47:35 -04:00
kraktus
00cf07b521 [option_if_let_else] do not lint if any arm has guard 2022-10-29 16:44:12 +02:00