Commit graph

15491 commits

Author SHA1 Message Date
koka
7c4611c7e1
Allow return types for closures with lifetime binder 2022-11-15 12:58:17 +09:00
bors
3c7f74de0b Auto merge of #9848 - lukas-code:vec-box, r=Jarcho
Fix `vec-box-size-threshold` off-by-one error

The docs for `vec-box-size-threshold` say "The size of the boxed type in bytes, where boxing in a `Vec` is allowed", but previously a boxed type of exactly that size wasn't allowed in `Vec`.

changelog: [`vec_box`]: Fix off-by-one error for `vec-box-size-threshold` configuration.
2022-11-14 15:54:45 +00:00
Lukas Markeffsky
b8357ffd1f fix vec-box-size-threshold off-by-one error 2022-11-14 16:06:21 +01:00
bors
a5995279fb Auto merge of #9837 - DesmondWillowbrook:never_loop, r=dswij
fix never_loop false positive

fixes #9831

changelog: [`never_loop`]: fixed false positive on unconditional break in internal labeled block
2022-11-13 15:44:14 +00:00
bors
493b78885a Auto merge of #9829 - hrxi:pr_or_fun_call, r=llogiq
Make it clear that `or_fun_call` can be a false-positive

Also move it to nursery so that the false-positives can be dealt with.

CC #8574

changelog: [`or_fun_call`]: Mention false-positives, move to nursery.
2022-11-13 14:29:42 +00:00
bors
6ba3a00b94 Auto merge of #9822 - Veykril:unnecessary-safety-doc, r=Jarcho
Add `unnecessary_safety_doc` lint

changelog: [`unnecessary_safety_doc`]: Add `unnecessary_safety_doc` lint

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

This lint does not trigger for private functions, just like `missing_safety_docs`. Reason for that was implementation simplicity and because I figured asking first would make more sense, so if it should trigger for private functions as well let me know and I'll fix that up as well.
2022-11-13 14:18:04 +00:00
bors
a8151409a0 Auto merge of #9698 - kraktus:xc_bool, r=xFrednet
[`fn_params_excessive_bools`] Make it possible to allow the lint at the method level

changelog: FP: [`fn_params_excessive_bools`]: `#[allow]` now works on methods

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

Tested without committing but `#[allow]`ing now works. Also rewrote the lint to be a late lint while at it :)
r? `@xFrednet`
2022-11-13 09:57:36 +00:00
hrxi
243661b739 Make it clear that or_fun_call can be a false-positive
Also move it to nursery so that the false-positives can be dealt with.

CC #8574
2022-11-12 22:26:09 +01:00
bors
9f283c97e1 Auto merge of #9835 - koka831:fix/9035, r=Alexendoo
Avoid linting unsized mutable reference

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

changelog: [`mut_mut`] avoid suggesting to reborrow unsized mutable reference
2022-11-12 21:07:18 +00:00
bors
bb326e761b Auto merge of #9836 - koka831:patch-9300, r=Alexendoo
Fix is_async_fn to check FnKind::Method

This is a follow-up PR of https://github.com/rust-lang/rust-clippy/pull/9828 to support also async methods.

changelog: [`cognitive_complexity`] support async method

r? `@Alexendoo`
2022-11-12 20:54:39 +00:00
Kartavya Vashishtha
989986144c
fix never_loop false positive
on unconditional break to internal labeled block

ref #9831
2022-11-12 20:36:30 +05:30
koka
34c4520eae
Fix is_async_fn to check FnKind::Method 2022-11-12 22:36:20 +09:00
bors
755fe4dc24 Auto merge of #9834 - koka831:refac/manual-is-ascii-check, r=xFrednet
refac: remove unnecessary mutability

refactor `manual_is_ascii_check` lint.

* remove unnecessary mutability
* fix typo

changelog: none

r? `@xFrednet`
2022-11-12 11:44:22 +00:00
koka
93edc127a0
Avoid lint to unsized mutable reference 2022-11-12 20:31:25 +09:00
koka
39398e163a
fix: use HasPlaceholders
* remove unnecessary mutability
* fix typo
2022-11-12 20:29:24 +09:00
bors
cad0d3d6da Auto merge of #9662 - ebobrow:result-large-err, r=dswij
`result_large_err` show largest variants in err msg

fixes #9538

changelog: Sugg: [`result_large_err`]: Now show largest enum variants in error message
2022-11-11 06:58:59 +00:00
bors
3c0ad8a0e0 Auto merge of #9830 - hrxi:pr_bool_to_int_with_if, r=Manishearth
Make `bool_to_int_with_if` a pedantic lint

In all the cases I've observed, it did not make the code clearer. Using bools as integer is frowned upon in some languages, in others it's simply not possible.

You can find comments on the original pull request #8131 that agree with this point of view.

changelog: [`bool_to_int_with_if`]: Change the categorization to pedantic
2022-11-10 19:37:05 +00:00
hrxi
3790aa3d5d Make bool_to_int_with_if a pedantic lint
In all the cases I've observed, it did not make the code clearer. Using
bools as integer is frowned upon in some languages, in others it's
simply not possible.

You can find comments on the original pull request #8131 that agree with
this point of view.
2022-11-10 19:42:20 +01:00
bors
4f1698db60 Auto merge of #9828 - koka831:fix/9300, r=Alexendoo
fix: cognitive_complexity for async fn

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

changelog: [`cognitive_complexity`] support async fn
2022-11-10 17:40:46 +00:00
koka
2bc04bdac2
fix: cognitive_complexity for async fn 2022-11-11 00:14:18 +09:00
Lukas Wirth
146bd1e13d Add unnecessary_safety_doc lint 2022-11-10 10:09:33 +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
Elliot Bobrow
80e5856b02 result_large_err show largest variants in err msg 2022-11-07 18:00:35 -08: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
kraktus
3d4b73c26d [excessive_bools] lint trait functions even without bodies 2022-11-07 21:00:37 +01: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
kraktus
13b737d5b8 [fn_params_excessive_bools] whitelist in signle function in test 2022-11-07 19:49:43 +01:00
kraktus
9e1c7febe2 excessive_bools, do not lint in trait impls
Should not lint because the trait might not be changeable by the user
We only lint in the trait definition
2022-11-07 19:49:43 +01:00
kraktus
d9b940e2c3 dogfood 2022-11-07 19:49:43 +01:00
kraktus
e8c2c3d1c6 refactor has_repr_attr 2022-11-07 19:49:43 +01:00
kraktus
9c69e93595 Rewrite ExcessiveBools to be a LateLintPass lint
changelog: [`fn_params_excessive_bools`] Make it possible to allow the lint at the method level
2022-11-07 19:49:43 +01:00
kraktus
586bd3f735 refactor to avoid potential ICE 2022-11-07 19:49:43 +01: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