Commit Graph

16304 Commits

Author SHA1 Message Date
Samuel Tardieu
d5429eab8a Add new redundant_async_block lint 2023-03-08 10:48:54 +01:00
bors
5eefbb39a9 Auto merge of #10466 - samueltardieu:popular-crates, r=llogiq
Add the `popular-crates` binary

This program downloads crates info from <https://crates.io/> and builds a TOML file that can be fed to `lintcheck`.

I have been asked, on various pull requests, what the result of `lintcheck` was. However, the default configuration file for lintcheck is limited. This `popular-crates` program allows building a recent list of the recently most downloaded crates from <https://crates.io> and feed it to `lintcheck`. Using it, it was easy to test two new lints against the 500 recently most downloaded crates to ensure that there was no regression.

changelog: none
2023-03-08 09:19:39 +00:00
bors
216aefbe30 Auto merge of #10362 - unexge:missing-assert-message-lint, r=llogiq
Add `missing_assert_message` lint

Fixes https://github.com/rust-lang/rust-clippy/issues/6207.

changelog: new lint: [`missing_assert_message`]: A new lint for checking assertions that doesn't have a custom panic message.
[#10362](https://github.com/rust-lang/rust-clippy/pull/10362)
<!-- changelog_checked -->

r? `@llogiq`
2023-03-08 09:07:15 +00:00
unexge
b554ff4cd8 Add Known problems section
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:52:19 +00:00
unexge
87f58a1a4f Use late lint pass for missing_assert_message lint
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:52:17 +00:00
unexge
682d52cf7c Update assertion macro parsing logic for Rust 1.52 changes
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:51:52 +00:00
unexge
e7065efc76 Revert tests/ui/filter_map_next_fixable.rs
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:51:52 +00:00
unexge
b4b2b1235a Revert "Dogfood missing_assert_message on Clippy"
This reverts commit ec653570ad50d11ecc3b5649dd28e29ed96199d3.
2023-03-08 08:51:50 +00:00
unexge
6fac73b987 Move lint to restriction category
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:51:26 +00:00
unexge
4eb6ccc973 Update lint description and add help section
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:51:26 +00:00
Burak
099d610640 Apply suggestions from code review
Co-authored-by: llogiq <bogusandre@gmail.com>
2023-03-08 08:51:26 +00:00
Burak Varlı
8f3ac65227 Dogfood missing_assert_message on Clippy
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:51:24 +00:00
Burak Varlı
ea2547b8c6 Add missing_assert_message lint
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:50:21 +00:00
Samuel "Sam" Tardieu
ce3415e87b Add the popular-crates binary
This program downloads crates info from https://crates.io/ and builds
a TOML file that can be fed to `lintcheck`.
2023-03-08 09:43:28 +01:00
bors
41fa24cef8 Auto merge of #10415 - schubart:collection_is_never_read, r=llogiq
Add `collection_is_never_read`

Fixes #9267

`@flip1995` and `@llogiq,` I talked with you about this one at Rust Nation in London last week. :-)

This is my first contribution to Clippy, so lots of feedback would be greatly appreciated.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

`dogfood` found one true positive (see #9509) and no false positives.

`lintcheck` found no (true or false) positives, even when running on an extended set of crates.

---

changelog: new lint [`collection_is_never_read`]
[#10415](https://github.com/rust-lang/rust-clippy/pull/10415)
<!-- changelog_checked -->
2023-03-07 13:35:07 +00:00
Michael Schubart
4ee65535a7 Add test where container is passed to a function 2023-03-06 22:19:34 +00:00
Michael Schubart
85ad8a6fdc Avoid false positives from extension traits 2023-03-06 07:19:09 +00:00
bors
903595801e Auto merge of #10457 - samueltardieu:issue-10436, r=Manishearth
help: refer to `cargo check --help`

Fixes #10436

changelog: none
2023-03-05 22:31:43 +00:00
Samuel Tardieu
b6f0ebf71c help: refer to cargo check --help 2023-03-05 23:10:13 +01:00
bors
783bc621a1 Auto merge of #10438 - Jarcho:use_snip_ctxt, r=dswij
Use `snippet_with_context` more

No tests at the moment. Need to find a way to write macro tests without writing a pile of macros.

changelog: None
2023-03-05 15:24:36 +00:00
bors
70e85d146f Auto merge of #10403 - smoelius:fix-107877, r=Jarcho
Fix rust-lang/rust#107877, etc.

Fix #10009
Fix #10387
Fix https://github.com/rust-lang/rust/issues/107877

The fix is to verify that the associated item's trait is implemented before trying to project the item's type.

r? `@Jarcho`

---

changelog: ICE: [`needless_borrow`]: No longer panics on ambiguous projections
[#10403](https://github.com/rust-lang/rust-clippy/pull/10403)
<!-- changelog_checked -->
2023-03-05 01:15:46 +00:00
Samuel Moelius
f95d9deafd Handle ambiguous projections 2023-03-04 19:03:40 -05:00
bors
78f0f78826 Auto merge of #10445 - samueltardieu:lintcheck-maintenance, r=llogiq
Lintcheck maintenance

Make `cargo lintcheck -j 0` use all threads instead of panicking, and cleanup (and shorten) lintcheck's parsing code.

changelog: none
2023-03-04 23:37:00 +00:00
Samuel Tardieu
79829d8718 lintcheck: use clap's derive interface
This makes the code shorter and clearer.

The only incompatible change is that an explicit command-line argument
`--crates-toml=` will take precedence over the `LINTCHECK_TOML`
environment variable.
2023-03-04 23:17:27 +01:00
bors
2500f960fc Auto merge of #10439 - giraffate:fix_fp_for_let_unit_value, r=Jarcho
Fix FP for `let_unit_value` when `await` used

Fix https://github.com/rust-lang/rust-clippy/issues/10433

changelog: Fix FP for `let_unit_value` when `await` used
2023-03-04 19:42:26 +00:00
Samuel Tardieu
446ae429a6 lintcheck: fix parallel processing handling
Using `rayon::current_num_threads()` causes a bug:

```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
  ThreadPoolBuildError { kind: GlobalPoolAlreadyInitialized }',
  src/main.rs:632:10
```

Moreover, using the number of threads and dividing it by 2 wouldn't
return the number of physical threads on modern processors which have
a varying number of threads per core.

It makes little sense to restrict ourselves to physical threads,
especially when, in modern architectures, cores with multiple threads
are often faster (performance) while cores with a unique threads are
often slower (efficient). The Rust runtime will make a better choice.
2023-03-04 17:29:58 +01:00
bors
308d680407 Auto merge of #10442 - dtolnay-contrib:letunderscore, r=llogiq
Downgrade let_underscore_untyped to restriction

From reading #6842 I am not convinced of the cost/benefit of this lint even as a pedantic lint.

It sounds like the primary motivation was to catch cases of `fn() -> Result` being changed to `async fn() -> Result`. If the original Result was ignored by a `let _`, then the compiler wouldn't guide you to add `.await`. **However, this situation is caught in a more specific way by [let_underscore_future](https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_future) which was introduced _after_ the original suggestion (#9760).**

In #10410 it was mentioned twice that a <kbd>restriction</kbd> lint might be more appropriate for let_underscore_untyped.

changelog: Moved [`let_underscore_untyped`] to restriction
2023-03-04 16:20:28 +00:00
bors
d423703aba Auto merge of #10443 - dtolnay-contrib:formerids, r=llogiq
Include former name of renamed lints in lints.json

I am interested in having a programmatic way to process [`RENAMED_LINTS`](113c704d22/clippy_lints/src/renamed_lints.rs (L4)) for https://github.com/dtolnay/noisy-clippy/issues/15.

<details>
<summary>lints.json diff</summary>

```diff
60c60,63
<     }
---
>     },
>     "former_ids": [
>       "almost_complete_letter_range"
>     ]
300c303,306
<     }
---
>     },
>     "former_ids": [
>       "option_and_then_some"
>     ]
330c336,340
<     }
---
>     },
>     "former_ids": [
>       "block_in_if_condition_expr",
>       "block_in_if_condition_stmt"
>     ]
450c460,463
<     }
---
>     },
>     "former_ids": [
>       "box_vec"
>     ]
945c958,961
<     }
---
>     },
>     "former_ids": [
>       "cyclomatic_complexity"
>     ]
1335c1351,1354
<     }
---
>     },
>     "former_ids": [
>       "derive_hash_xor_eq"
>     ]
1365c1384,1387
<     }
---
>     },
>     "former_ids": [
>       "disallowed_method"
>     ]
1380c1402,1405
<     }
---
>     },
>     "former_ids": [
>       "blacklisted_name"
>     ]
1410c1435,1438
<     }
---
>     },
>     "former_ids": [
>       "disallowed_type"
>     ]
1890c1918,1922
<     }
---
>     },
>     "former_ids": [
>       "option_expect_used",
>       "result_expect_used"
>     ]
3150c3182,3185
<     }
---
>     },
>     "former_ids": [
>       "zero_width_space"
>     ]
4185c4220,4225
<     }
---
>     },
>     "former_ids": [
>       "option_map_unwrap_or",
>       "option_map_unwrap_or_else",
>       "result_map_unwrap_or_else"
>     ]
4290c4330,4333
<     }
---
>     },
>     "former_ids": [
>       "if_let_some_result"
>     ]
4710c4753,4756
<     }
---
>     },
>     "former_ids": [
>       "eval_order_dependence"
>     ]
4755c4801,4804
<     }
---
>     },
>     "former_ids": [
>       "stutter"
>     ]
5055c5104,5107
<     }
---
>     },
>     "former_ids": [
>       "ref_in_deref"
>     ]
5400c5452,5455
<     }
---
>     },
>     "former_ids": [
>       "new_without_default_derive"
>     ]
5820c5875,5878
<     }
---
>     },
>     "former_ids": [
>       "logic_bug"
>     ]
6330c6388,6391
<     }
---
>     },
>     "former_ids": [
>       "to_string_in_display"
>     ]
6525c6586,6589
<     }
---
>     },
>     "former_ids": [
>       "const_static_lifetime"
>     ]
7065c7129,7132
<     }
---
>     },
>     "former_ids": [
>       "single_char_push_str"
>     ]
8820c8887,8891
<     }
---
>     },
>     "former_ids": [
>       "option_unwrap_used",
>       "result_unwrap_used"
>     ]
8925c8996,8999
<     }
---
>     },
>     "former_ids": [
>       "identity_conversion"
>     ]
```
</details>

changelog: Include `"former_ids": […]` for renamed lints in [lints.json](https://rust-lang.github.io/rust-clippy/master/lints.json)
2023-03-04 16:08:09 +00:00
David Tolnay
cc6180c2f4
Include former name of renamed lints in lints.json 2023-03-03 19:03:54 -08:00
David Tolnay
03b9940b29
Downgrade let_underscore_untyped to restriction 2023-03-03 13:40:07 -08:00
Takayuki Nakata
027f19c8b9 Fix FP for let_unit_value when await used 2023-03-03 22:41:39 +09:00
Jason Newcomb
efbcb99b73 Use snippet_with_context more 2023-03-03 00:55:53 -05:00
Michael Schubart
fbb7fd59c3 Add test for an interesting edge case 2023-02-28 22:09:04 +00:00
Michael Schubart
cb3bb8a5b5 Add tests that show: insert() can be a read or not 2023-02-28 22:09:04 +00:00
Michael Schubart
5770d40d8e More compact use statements 2023-02-28 21:47:07 +00:00
bors
113c704d22 Auto merge of #10427 - xFrednet:changelog-1-68, r=Manishearth
Update version attribute for 1.68 lints

Roses are red,
violets are blue,
I'm running out of rhymes,
changelogs are crimes????

---

changelog: none
<!-- changelog_checked -->
2023-02-28 21:24:26 +00:00
xFrednet
917ebc3af6
Changelog for Rust 1.68 🐶 2023-02-28 22:06:53 +01:00
xFrednet
7fb76a1ea7
Update version attribute for 1.68 lints 2023-02-28 21:56:03 +01:00
bors
2d9ca944fa Auto merge of #10425 - smoelius:docs, r=llogiq
Two small documentation improvements

The `wrong_self_convention` changes are for grammar and accuracy.

The `must_use_candidate` change is because that lint flags only exported functions: 8b65632b6e/clippy_lints/src/functions/must_use.rs (L27-L31)

changelog: `wrong_self_convention` and `must_use_candidate` documentation improvements
2023-02-28 18:16:15 +00:00
bors
ba86a99d24 Auto merge of #10324 - andrewbanchich:fix-missing-private-docs, r=dswij
Scope `missing_docs_in_private_items` to only private items

`missing_docs_in_private_items` currently detects missing docs for public items as well as private. Since `missing_docs`already covers public items, this PR updates `missing_docs_in_private_items` to only cover private items.

Fixes #1895

changelog: [`missing_docs_in_private_items`]: Apply lint only to private items (used to be public and private)
2023-02-28 16:30:49 +00:00
bors
d98873497b Auto merge of #10418 - Jarcho:finish_dogfood, r=flip1995
Run dogfood to completion

Run dogfood on all packages before failing the test. Failing early is painful on lints which trigger on multiple crates.

changelog: None
2023-02-28 15:21:32 +00:00
bors
1a11ad7390 Auto merge of #10405 - Jarcho:issue_10367, r=flip1995
Fix ICE in `multiple_unsafe_ops_per_block`

fixes #10367

changelog: [`multiple_unsafe_ops_per_block`]: Fix ICE when calling a function-like object in an unsafe block
2023-02-28 15:08:34 +00:00
bors
acf70eae4c Auto merge of #10423 - Alexendoo:array-size-threshold, r=flip1995
Fix array-size-threshold config deserialization error

changelog: Fix error when providing an `array-size-threshold` in `clippy.toml`

Not entirely sure why it doesn't want to deserialize a u128, but converting it after the fact is an easy enough fix

Fixes #10422
2023-02-28 14:57:33 +00:00
Samuel Moelius
90ba82bd39 Two small documentation improvements 2023-02-28 09:52:01 -05:00
Jason Newcomb
69a1100776 Run dogfood on all packages before failing 2023-02-28 09:49:54 -05:00
Alex Macleod
2cadea5dc5 Fix array-size-threshold config deserialization error 2023-02-28 14:37:41 +00:00
bors
8b65632b6e Auto merge of #10419 - deining:fix/typos, r=Jarcho
Fixing typos

changelog: none
2023-02-27 20:51:12 +00:00
Andreas Deininger
03a3f74365 Fixing typos 2023-02-27 21:45:26 +01:00
Michael Schubart
08708198fb Fix lint documentation 2023-02-27 19:31:59 +00:00
bors
2742ac0748 Auto merge of #10399 - samueltardieu:issue-10396, r=Manishearth
Do not suggest to derive `Default` on generics with implicit arguments

Fixes #10396

changelog: FP: [`derivable_impls`]: do not suggest to derive `Default` on generics with implicit arguments
2023-02-27 17:12:43 +00:00