Commit Graph

16293 Commits

Author SHA1 Message Date
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
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
Michael Schubart
2a9c254e23 Add collection_is_never_read 2023-02-27 07:14:55 +00:00
bors
ba7fd68e87 Auto merge of #10408 - cdown:cdown/2023-02-26/exit_lint_sp, r=Alexendoo
exit lint: potentualy -> potentially

changelog: none
2023-02-26 20:51:54 +00:00
Chris Down
5f3df6cfce exit lint: potentualy -> potentially 2023-02-26 17:43:24 +00:00
Samuel Tardieu
c82ff00539 Do not suggest to derive Default on generics with implicit arguments 2023-02-26 15:44:04 +01:00
Jason Newcomb
002e934189 Don't assume paths work with fn_sig in multiple_unsafe_ops_pre_block. 2023-02-26 02:55:52 -05:00
bors
3d193fa17a Auto merge of #10400 - calebcartwright:rustfmt-cleanup, r=Jarcho
chore: remove unneeded rustfmt skip

---

The associated rustfmt bug that originally necessitated these skips was resolved a while back, so these are no longer necessary

changelog: none
2023-02-26 03:03:01 +00:00
bors
e1ac1332b6 Auto merge of #10375 - samueltardieu:issue-10371, r=Manishearth
Do not suggest using Self in const generic parameters

Fixes #10371

changelog: FP: [`use_self`]: do not suggest using `Self` in const generic parameters
2023-02-26 00:52:55 +00:00
Andrew Banchich
49a06ed66f Scope missing_docs_in_private_items to only private items 2023-02-25 19:16:53 -05:00
bors
149392b0ba Auto merge of #10402 - Jarcho:rustup, r=Jarcho
Rustup

Looks like `@flip1995`  is busy.

r? `@ghost`

changelog: None
2023-02-25 23:34:06 +00:00
Jason Newcomb
69c4ff6df8 Emit unnecessary_def_path in source order. 2023-02-25 18:09:24 -05:00
Jason Newcomb
e825adf637 Fix normalization of custom_ice_message test. 2023-02-25 18:08:51 -05:00