Commit Graph

14533 Commits

Author SHA1 Message Date
alex-semenyuk
2894df3409 match_like_matches_macro does not trigger when one arm contains contains a block with only a bool literal 2022-07-15 09:15:31 +03:00
bors
0f5a38f2d6 Auto merge of #9170 - Rqnsom:box_collection, r=Jarcho
[`box_collection`]: raise warn for all std collections

So far, only [`Vec`, `String`, `HashMap`] were considered.

Extend collection checklist for this lint with:
- `HashSet`
- `VecDeque`
- `LinkedList`
- `BTreeMap`
- `BTreeSet`
- `BinaryHeap`

changelog: [`box_collection`]: raise warn for all std collections
2022-07-14 13:02:06 +00:00
bors
10e85efc53 Auto merge of #9161 - Victor-N-Suadicani:move_format_push_string_to_pedantic, r=flip1995
Move format_push_string to restriction

Fixes #9077 (kinda) by moving the lint to the restriction group. As I noted in that issue, I think the suggested change is too much and as the OP of the issue points out, the ramifications of the change are not necessarily easily understood. As such I don't think the lint should be enabled by default.

changelog: [`format_push_string`]: moved to restriction (see #9077).
2022-07-14 12:11:34 +00:00
Victor Nordam Suadicani
43ac256cd1 Add Known problems section 2022-07-14 13:26:56 +02:00
bors
1b23c0ec1e Auto merge of #9173 - giraffate:fix_the_minimal_version_for_clap, r=xFrednet
Fix the minimal version for `clap`

changelog: none

`clap >= 3.2.0` for lintcheck  has been needed from https://github.com/rust-lang/rust-clippy/pull/8997.
2022-07-14 08:27:58 +00:00
Takayuki Nakata
7fbaf8113b Fix the minimal version for clap 2022-07-14 09:46:46 +09:00
bors
a7162f29b4 Auto merge of #9134 - Jarcho:while_let_iter_closure, r=dswij
Improve `while_let_on_iterator` suggestion inside an `FnOnce` closure

changelog: Improve `while_let_on_iterator` suggestion inside an `FnOnce` closure
2022-07-13 16:20:14 +00:00
Korlo
467e1b23aa box_collection: raise warn for all std collections
So far, only [Vec, String, Hashmap] were considered.

Extend collection checklist for this lint with:
- HashSet
- VecDeque
- LinkedList
- BTreeMap
- BTreeSet
- BinaryHeap
2022-07-13 17:02:09 +02:00
bors
0db9280783 Auto merge of #9159 - alex-semenyuk:fix_typos, r=dswij
Fix typos

changelog: none
2022-07-13 14:48:32 +00:00
bors
0930ac91b9 Fix typos
changelog: none
2022-07-13 14:48:32 +00:00
bors
44be2d4b0e Auto merge of #9169 - Alexendoo:message-convention-regex, r=flip1995
Use `LazyLock` for `lint_message_convention` regexes

They were being recompiled for `Message::new` call, for me this shaves 7s off the time it takes to run the test. Also removes a redundant exception from the list and joins the various `message...` exceptions into one

changelog: none
2022-07-13 14:27:44 +00:00
Alex Macleod
018684dd9a Use LazyLock for lint_message_convention regexes 2022-07-13 14:10:39 +00:00
bors
f78292a4ad Auto merge of #9156 - Rqnsom:manual_flatten, r=Alexendoo
fix [`manual_flatten`] help texts order

fixes  #8948

Whenever suggestion for this lint does not fit in one line,
legacy solution has some unexpected/unhandled behavior:
lint will then generate two help messages which seem to be shown in the wrong order.
The second help message in that case will contain the suggestion.

The first help message always refers to a suggestion message,
and **it should adapt** depending on the location of the suggestion:
- inline suggestion within the error/warning message
- suggestion separated into a second help text

This is my first contribution here, so I hope I didn't miss anything for creating this PR.

changelog: fix [`manual_flatten`] help texts order
2022-07-13 12:52:08 +00:00
Victor Nordam Suadicani
565d3fd67d Move to restriction 2022-07-13 12:59:55 +02:00
Korlo
852c38c543 fix for manual_flatten help texts order
Whenever suggestion for this lint does not fit in one line,
lint will generate two help messages. The second help message
will always contain the suggestion.

The first help message refers to suggestion message,
and it should adapt depending on the location of the suggestion:
- inline suggestion within the error/warning message
- suggestion separated into second help text
2022-07-13 09:33:17 +02:00
Victor-N-Suadicani
c26188e327 Moves format_push_string to pedantic. 2022-07-12 23:11:19 +02:00
bors
07ab0e8741 Auto merge of #9157 - Rqnsom:pull_request_template, r=flip1995
update pull request template

Improved suggestion for formatting lint names in the PR template to use this format:
[`lint_name`]

changelog: none
2022-07-12 16:07:38 +00:00
bors
9ebacd4874 Auto merge of #8703 - aldhsu:add_repeated_where_clause_or_trait_bound, r=flip1995
Add `repeated_where_clause_or_trait_bound` lint

I thought I would try and scratch my own itch for #8674.

1. Is comparing the `Res` the correct way for ensuring we have the same trait?
2. Is there a way to get the spans for the bounds and clauses for suggestions?
I tried to use `GenericParam::bounds_span_for_suggestions` but it only gave me an empty span at the end of the spans.
I tried `WhereClause::span_for_predicates_or_empty_place` and it included the comma.
3. Is there a simpler way to get the trait names? I have used the spans of the traits because I didn't see a way to get it off the `Res` or `Def`.

changelog: Add ``[`repeated_where_clause_or_trait_bound`]`` lint.
2022-07-12 15:48:55 +00:00
Korlo
7f4e5d8cc4 update pull request template
Improved suggestion for formatting lint names in the template:

    changelog: [`lint_name`]: your change
2022-07-12 17:26:30 +02:00
Allen Hsu
8878d674b1 Lint for repeated traits within trait bounds or where clauses. 2022-07-12 22:03:55 +10:00
bors
eabad8ea53 Auto merge of #9149 - kyoto7250:issue_9013, r=Jarcho
change applicability type to MaybeIncorrect in `explicit_counter_loop`

close #9013

This PR changes  applicability type to `MaybeIncorrect`,  because the suggestion is not `MachineApplicable`.

changelog: change applicability type to MaybeIncorrect in `explicit_counter_loop`
2022-07-12 06:43:42 +00:00
kyoto7250
134d0dee41 declare span variable before call 2022-07-12 11:28:15 +09:00
bors
3206fb4eb1 Auto merge of #9138 - Jarcho:branches_sharing_code_2, r=giraffate
Fixes for `branches_sharing_code`

fixes #7198
fixes #7452
fixes #7555
fixes #7589

changelog: Don't suggest moving modifications to locals used in any of the condition expressions in `branches_sharing_code`
changelog: Don't suggest moving anything after a local with a significant drop in `branches_sharing_code`
2022-07-12 00:38:54 +00:00
bors
8a801c7b83 Auto merge of #9154 - CeleritasCelery:master, r=flip1995
Remove broken link in CONTRIBUTING.md

changelog: none
2022-07-11 21:14:23 +00:00
Troy Hinckley
57a8f6dd9d Fix broken link in CONTRIBUTING.md 2022-07-11 15:49:11 -05:00
bors
7c1598b399 Auto merge of #9152 - mati865:patch-2, r=xFrednet
Fix Clippy version in `derive_partial_eq_without_eq` lint

It was first added to Rust in https://github.com/rust-lang/rust/pull/97248 which missed 1.62 just by few days.

changelog: none
2022-07-11 15:07:33 +00:00
Mateusz Mikuła
c8d32e53a2
Fix Clippy version in derive_partial_eq_without_eq lint
It was first added to Rust in https://github.com/rust-lang/rust/pull/97248 which missed 1.62 just by few days.
2022-07-11 17:01:46 +02:00
bors
8a62b6f523 Auto merge of #9144 - alex-semenyuk:or_fun_call_span_fix, r=giraffate
Fix span for or_fun_call

Closes #9033
changelog: [`or_fun_call`]: span points to the `unwrap_or` only instead of through the entire method chain expression
2022-07-11 09:03:20 +00:00
alex-semenyuk
c3c4cda50b Address review 2022-07-11 10:34:01 +03:00
bors
7ea4592a8b Auto merge of #9056 - Jarcho:let_unit_indirect, r=llogiq
Allow `let_unit_value` in more cases

fixes #8998

changelog: Lint `let_unit_value` less aggressively when the type is specified
2022-07-10 18:58:09 +00:00
kyoto7250
25fe4193ec change applicability type to MaybeIncorrect 2022-07-10 23:09:15 +09:00
alex-semenyuk
783992e693 Fix dogfood issue for or_fun_call 2022-07-10 13:34:58 +03:00
alex-semenyuk
97cd46fa33 Fix span for or_fun_call 2022-07-10 13:11:19 +03:00
bors
4d1b976b1d Auto merge of #9141 - alex-semenyuk:grammar_fix, r=dswij
Fix small mistakes

changelog: none
2022-07-09 15:58:58 +00:00
bors
3468294b58 Auto merge of #9140 - Jarcho:sig_drop, r=flip1995
Ignore `into_iter` in `significant_drop_in_scrutinee`

fixes #9135
changelog: Ignore the `IntoIterator::into_iter` call from for loops in `significant_drop_in_scrutinee`
2022-07-09 12:34:03 +00:00
Jason Newcomb
95b78799c3 Ignore the IntoIterator::into_iter call from for loops in significant_drop_in_scrutinee 2022-07-09 08:15:13 -04:00
alex-semenyuk
9015884325 Fix small mistakes 2022-07-09 13:00:24 +03:00
Jason Newcomb
55563f9ce1 Fixes for branches_sharing_code
* Don't suggest moving modifications to locals used in any of the condition expressions
* Don't suggest moving anything after a local with a significant drop
2022-07-08 20:07:55 -04:00
bors
526f02ef05 Auto merge of #9137 - alex-semenyuk:small_cosmetic_fix, r=xFrednet
Fix example header

changelog: fix example header
2022-07-08 19:14:51 +00:00
alexey semenyuk
4e60134ec3
Fix example header 2022-07-08 22:07:44 +03:00
Jason Newcomb
d251bd96e7 Add for_each_expr 2022-07-08 12:54:20 -04:00
bors
49f73e14a9 Auto merge of #8356 - J-ZhengLi:master-issue8288, r=dswij
Simplify if let statements

fixes: #8288

---

changelog: Allowing [`qustion_mark`] lint to check `if let` expressions that immediatly return unwrapped value
2022-07-08 16:12:00 +00:00
bors
d0b8f7508c Simplify if let statements
fixes: #8288

---

changelog: Allowing [`qustion_mark`] lint to check `if let` expressions that immediatly return unwrapped value
2022-07-08 16:12:00 +00:00
Jason Newcomb
9fa12def3c Improve while_let_on_iterator suggestion inside an FnOnce closure 2022-07-07 22:10:24 -04:00
Jason Newcomb
2872b7e0a4 Allow let () = .. as type inference for let_unit_value 2022-07-07 20:06:37 -04:00
Jason Newcomb
196174ddad Changes to let_unit_value
* View through locals in `let_unit_value` when determining if inference is required
* Don't remove typed let bindings for more functions
2022-07-07 20:06:36 -04:00
bors
54feac18d1 Auto merge of #8958 - Alexendoo:simple_filter_map, r=giraffate
Lint simple expressions in `manual_filter_map`, `manual_find_map`

changelog: Lint simple expressions in [`manual_filter_map`], [`manual_find_map`]

The current comparison rules out `.find(|a| a.is_some()).map(|b| b.unwrap())` because `a` being a reference can effect more complicated expressions, this adds a simple check for that case and adds the necessary derefs

There's some overlap with `option_filter_map` so `lint_filter_some_map_unwrap` now returns a `bool` to indicate it linted
2022-07-07 23:39:12 +00:00
bors
2058b92777 Auto merge of #9120 - anall:bugfix/ice9041, r=Jarcho
Fix ICE in sugg::DerefDelegate with (named) closures

rustc comiler internals helpfully tell us how to fix the issue:
```
  to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`
```
Fixes ICE in #9041

This also makes this code in `sugg::DerefDelegate` match a different use `typ.fn_sig(…)` I found: in `mixed_read_write_in_expression` -- being strict on the value of `typ.kind()` will hopefully reduce any future possibility of ICE crashes in this area.

---

changelog: none
2022-07-07 23:04:29 +00:00
Andrea Nall
782b484b79 Fix ICE in sugg::DerefDelegate with (named) closures
rustc comiler internals helpfully tell us how to fix the issue:

  to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()`

Fixes ICE in #9041
2022-07-07 16:10:36 -05:00
bors
7142a59674 Auto merge of #9132 - hellow554:maybe_trait_bound_on_type_repetition, r=Manishearth
Maybe trait bound on type repetition

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

changelog: fix maybe trait on [`type_repetition_in_bounds`] lint

I simplified the two for loops, which did exactly the same. Only downside is, that I need a `copied`, but that's to convert from `&&` to `&`, to that should be a noop?

One more thing: I only handle [`TraitBoundModifier::Maybe`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.TraitBoundModifier.html#variant.Maybe). Can anyone give me an example (and testcase) for [`TraitBoundModifier::MaybeConst`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.TraitBoundModifier.html#variant.MaybeConst)?

closes #8770
2022-07-07 15:29:43 +00:00