Commit graph

5980 commits

Author SHA1 Message Date
bors
1fd9975249 Auto merge of #7095 - Y-Nak:match_single_binding, r=giraffate
match_single_binding: Fix invalid suggestion when match scrutinee has side effects

fixes #7094

changelog: `match_single_binding`: Fix invalid suggestion when match scrutinee has side effects

---
`Expr::can_have_side_effects` is used to determine the scrutinee has side effects, while this method is a little bit conservative for our use case. But I'd like to use it to avoid reimplementation of the method and too much heuristics. If you think this is problematic, then I'll implement a custom visitor to address it.
2021-05-13 13:55:47 +00:00
Jason Newcomb
4713e25ab0
Cleanup of while_let_on_iterator 2021-05-12 21:51:19 -04:00
Jason Newcomb
daca50a515
Improvements to while_let_on_iterator
* Suggest `&mut iter` when the iterator is used after the loop.
* Suggest `&mut iter` when the iterator is a field in a struct.
* Don't lint when the iterator is a field in a struct, and the struct is
used in the loop.
* Lint when the loop is nested in another loop, but suggest `&mut iter`
unless the iterator is from a local declared inside the loop.
2021-05-12 21:49:22 -04:00
Yoshitomo Nakanishi
8214bf0445 match_single_binding: Fix invalid suggestion when match scrutinee has side effects 2021-05-13 10:36:09 +09:00
bors
aa15a5442a Auto merge of #7197 - xFrednet:4310-depreciated-lints-collection, r=flip1995
Metadata collection monster eating deprecated lints

This adds the collection of deprecated lints to the metadata collection monster. The JSON output has the same structure with the *new* lint group "DEPRECATED". Here is one of fourteen examples it was able to dig up in Clippy's code:

```JSON
  {
    "id": "assign_op_pattern",
    "id_span": {
      "path": "src/assign_ops.rs",
      "line": 34
    },
    "group": "clippy::style",
    "docs": " **What it does:** Checks for `a = a op b` or `a = b commutative_op a` patterns.\n\n **Why is this bad?** These can be written as the shorter `a op= b`.\n\n **Known problems:** While forbidden by the spec, `OpAssign` traits may have\n implementations that differ from the regular `Op` impl.\n\n **Example:**\n ```rust\n let mut a = 5;\n let b = 0;\n // ...\n // Bad\n a = a + b;\n\n // Good\n a += b;\n ```\n",
    "applicability": {
      "is_multi_part_suggestion": false,
      "applicability": "MachineApplicable"
    }
  }
```

And you! Yes you! Sir or Madam can get all of this **for free** in Clippy if this PR gets merged. (Sorry for the silliness ^^)

---

See: #7172 for the full metadata collection to-do list or to suggest a new feature in connection to it 🙃

---

changelog: none

r? `@flip1995`
2021-05-12 08:01:10 +00:00
Fridtjof Stoldt
a988a90e11 Update clippy_lints/src/deprecated_lints.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
2021-05-11 18:33:51 +02:00
xFrednet
d849e9586e Metadata collection monster eating deprecated lints 2021-05-09 21:58:31 +02:00
William Chargin
1b2ca3067e Move inconsistent_struct_constructor to pedantic
The whole point of named fields is that we don't have to worry about
order. The names, not the position, communicate the information, so
worrying about consistency for consistency's sake is pedantic to a *T*.

Fixes #7192.

wchargin-branch: inconsistent-struct-constructor-pedantic
wchargin-source: 4fe078a21c77ceb625e58fa3b90b613fc4fa6a76
2021-05-07 20:24:07 -07:00
bors
65951c969f Auto merge of #7165 - camsteffen:question-mark, r=Manishearth
Fix needless_quesiton_mark false positive

changelog: Fix [`needless_question_mark`] false positive where the inner value is implicity dereferenced by the question mark.

Fixes #7107
2021-05-08 00:04:14 +00:00
bors
af8cf9444c Auto merge of #7183 - th1000s:write_nl_hint, r=flip1995
Handle write!(buf, "\n") case better

Make `write!(buf, "\n")` suggest `writeln!(buf)` by removing
the trailing comma from `writeln!(buf, )`.

changelog: [`write_with_newline`] suggestion on only "\n" improved
2021-05-07 12:13:35 +00:00
Thomas Otto
5f3aae61af Handle write!(buf, "\n") case better
Make `write!(buf, "\n")` suggest `writeln!(buf)` by removing
the trailing comma from `writeln!(buf, )`.

changelog: [`write_with_newline`] suggestion on only "\n" improved
2021-05-07 00:53:13 +02:00
Mateusz Gacek
ab3094b3db wrong_self_convention: For to_* variant don't lint in trait impl taking self when non-Copy type
It relaxes rules for `to_*` variant, so it doesn't lint in trait definitions
and implementations anymore.
Although, non-`Copy` type implementing trait's `to_*` method taking
`self` feels not good (consumes ownership, so should be rather named `into_`), it would be better if this case was a pedantic lint (allow-by-default) instead.
2021-05-06 10:49:31 -07:00
flip1995
d481b38634
Bump Clippy version -> 0.1.54 2021-05-06 11:32:34 +02:00
flip1995
767cc7cd89
Merge remote-tracking branch 'upstream/master' into rustup 2021-05-06 11:32:03 +02:00
bors
796a6f00e1 Auto merge of #7177 - giraffate:add_a_missing_lint_to_msrv_config_doc, r=flip1995
Add a missing lint to MSRV config doc

A follow-up of https://github.com/rust-lang/rust-clippy/pull/6859.

changelog: Add a missing lint to MSRV config doc
2021-05-06 08:43:36 +00:00
bors
7191675ab1 Auto merge of #7166 - TaKO8Ki:refactor_misc_early_module, r=llogiq
Refactor: arrange lints in misc_early module

This PR arranges misc_early lints so that they can be accessed more easily.
Basically, I refactored them following the instruction described in #6680.

cc: `@Y-Nak,` `@flip1995,` `@magurotuna`

changelog: Move lints in misc_early module into their own modules.
2021-05-06 07:46:52 +00:00
Takayuki Nakata
b8046fab23 Add a missing lint to MSRV config doc 2021-05-06 14:04:50 +09:00
bors
9dd87051c7 Auto merge of #7175 - camsteffen:filter-map-none, r=Manishearth
Fix unnecessary_filter_map false positive

changelog: Fix an [`unnecessary_filter_map`] false positive

Fixes #6804
2021-05-05 22:57:05 +00:00
Cameron Steffen
d66d37303c Fix unnecessary_filter_map false positive 2021-05-05 16:44:00 -05:00
bors
93fe3562d0 Auto merge of #7174 - camsteffen:eval-order-async, r=flip1995
Fix eval_order_dependence async false positive

changelog: Fix [`eval_order_dependence`] false positive in async code

Fixes #6925
2021-05-05 21:18:05 +00:00
Cameron Steffen
7a7b8bd3e8 Fix eval_order_dependence async false positive 2021-05-05 15:08:44 -05:00
Cameron Steffen
2b38399920 Improve eval_order_dependence output 2021-05-05 15:03:14 -05:00
bors
182a1853c3 Auto merge of #7170 - flip1995:revert_drop_order, r=llogiq
Fix stack overflow issue in `redundant_pattern_matching`

Fixes #7169

~~cc `@Jarcho` Since tomorrow is release day and we need to get this also fixed in beta, I'll just revert the PR instead of looking into the root issue. Your changes are good, so if you have an idea what could cause this stack overflow and know how to fix it, please open a PR that reverts this revert with a fix.~~

r? `@llogiq`

changelog: none (fixes stack overflow, but this was introduced in this release cycle)
2021-05-05 17:33:46 +00:00
xFrednet
e0eb29c936 Applying PR suggestions (mostly typos)
Co-authored-by: flip1995 <hello@philkrones.com>
Co-authored-by: phansch <dev@phansch.net>
2021-05-05 18:58:57 +02:00
xFrednet
62cafe2c02 Applying PR suggestions 2021-05-05 18:38:26 +02:00
xFrednet
c1fa1102d4 ENABLE_METADATA_COLLECTION env-value to disable default metadata collection 2021-05-05 18:38:26 +02:00
xFrednet
4fc960301b Metadata collection: Rounding up the implementation 2021-05-05 18:38:26 +02:00
xFrednet
35844d0a48 Metadata collection: Resolve lint from locals 2021-05-05 18:35:33 +02:00
xFrednet
2ce5e368d8 Metadata collection: Refining the implementation 2021-05-05 18:35:33 +02:00
xFrednet
6658db1044 Metadata collection: processing emission closures (417/455) 2021-05-05 18:35:33 +02:00
xFrednet
5830fa7c60 Metadata Collection: Collecting direct emission applicabilities (324/455) 2021-05-05 18:35:33 +02:00
xFrednet
ee8a99a114 Metadata collection: Collecting Applicability assign values 2021-05-05 18:35:33 +02:00
xFrednet
a39912cfbb Metadata collection: Some refactoring for readability 2021-05-05 18:35:33 +02:00
xFrednet
ee130d066d Metadata collection: Tracking Applicability mut borrows 2021-05-05 18:35:33 +02:00
xFrednet
8dca1b8f61 Metadata collection: Collecting Applicability assign values 2021-05-05 18:35:33 +02:00
xFrednet
68d702f88d Metadata collection lint: Start Applicability value tracking 2021-05-05 18:35:33 +02:00
xFrednet
060e0e9f93 Metadata collection lint: Basic applicability collection 2021-05-05 18:35:33 +02:00
xFrednet
637751ff62 Metadata collection lint: Basic lint collection
WIP-2021-02-01

WIP-2021-02-01

WIP-2021-02-13
2021-05-05 18:34:24 +02:00
bors
0baf6bf226 Auto merge of #7163 - mgacek8:issue7110_needless_collect_with_type_annotations, r=flip1995
needless_collect: Lint cases with type annotations for indirect usage and recognize `BinaryHeap`

fixes #7110
changelog: needless_collect: Lint cases with type annotations for indirect usage and recognize `BinaryHeap`.
2021-05-05 15:43:02 +00:00
Cameron Steffen
344f04bea6
Fix stack overflow in redundant_pattern_matching 2021-05-05 16:12:39 +02:00
Mateusz Gacek
f79a2a3990 needless_collect: use node_type_opt instead of node_type
It may prevent future ICEs.
2021-05-05 04:52:03 -07:00
Cameron Steffen
83329ec705 Fix unused_unit macro false positive 2021-05-04 17:20:33 -05:00
Takayuki
3fbb060379 replace lit_snip type with &str 2021-05-05 06:53:04 +09:00
Takayuki
2dfb246d8e refactor unseparated_literal_suffix 2021-05-05 06:39:38 +09:00
Cameron Steffen
919ed2ba03 Fix needless_quesiton_mark false positive 2021-05-04 16:28:13 -05:00
Takayuki
b1567f4466 move zero_prefixed_literal to its own module 2021-05-05 06:18:58 +09:00
Mateusz Gacek
1835d8a238 needless_collect: Add BinaryHeap for indirect usage lint 2021-05-04 12:38:30 -07:00
Mateusz Gacek
b1faaaeb0c needless_collect: Lint cases with type annotations 2021-05-04 12:38:30 -07:00
Takayuki
0773d8afdb move mixed_case_hex_literals to its own module 2021-05-05 02:21:26 +09:00
Takayuki
f012e0e3de move unseparated_literal_suffix to its own module 2021-05-05 02:10:24 +09:00