Commit graph

7633 commits

Author SHA1 Message Date
Alex Macleod
2b655d4630 Correct some #[clippy::version]s 2022-06-09 13:50:07 +00:00
bors
4970527296 Auto merge of #8954 - Serial-ATA:doc-comment-issues, r=xFrednet
Improve lint doc consistency

changelog: none

This is a continuation of #8908.

Notable changes:
- Removed empty `Known Problems` sections
- Removed "Good"/"Bad" language (replaced with "Use instead")
- Removed (and added some 😄) duplication
- Ignored the [`create_dir`] example so it doesn't create `clippy_lints/foo` 😄
2022-06-09 11:03:49 +00:00
Serial
649ac36836 Fix [needless_bool] example 2022-06-09 06:54:01 -04:00
bors
919cf5083b Auto merge of #8907 - kyoto7250:fix_8898, r=giraffate
fix(lint): check const context

close: https://github.com/rust-lang/rust-clippy/issues/8898

This PR fixes a bug in checked_conversions.

Thank you in advance.

changelog: check const context in checked_conversions.
2022-06-09 00:04:09 +00:00
bors
50541b90e9 Auto merge of #8950 - Jarcho:derive_non_pub, r=dswij
Fixes for `derive_partial_eq_without_eq`

fixes  #8875

changelog: Don't lint `derive_partial_eq_without_eq` on non-public types
changelog: Better handle generics in `derive_partial_eq_without_eq`
2022-06-08 14:03:50 +00:00
Serial
0e07f55ceb Hide unnecessary code in [implicit_saturating_sub] 2022-06-07 18:51:45 -04:00
Jason Newcomb
bf3ab592f0 Changes to iter_overeager_cloned
* Don't lint on `.cloned().flatten()` when `T::Item` doesn't implement `IntoIterator`
* Reduce verbosity of lint message
* Narrow down the scope of the replacement range
2022-06-07 00:40:32 -04:00
Serial
cab5362d32 Suppress unused in doc examples 2022-06-06 20:28:16 -04:00
bors
ad70bffa9e Auto merge of #8944 - xFrednet:8877-append-doc-idents, r=Manishearth
List configuration values can now be extended instead of replaced

I've seen some `clippy.toml` files, that have a few additions to the default list of a configuration and then a copy of our default. The list will therefore not be updated, when we add new names. This change should make it simple for new users to append values instead of replacing them.

I'm uncertain if the documentation of the `".."` is apparent. Any suggestions are welcome. I've also check that the lint list displays the examples correctly.

<details>
<summary>Lint list screenshots</summary>

![image](https://user-images.githubusercontent.com/17087237/171999434-393f2f83-09aa-4bab-8b05-bd4973150f27.png)

![image](https://user-images.githubusercontent.com/17087237/171999401-e6942b53-25e6-4b09-89e5-d867c7463156.png)

</details>

---

changelog: enhancement: [`doc_markdown`]: Users can now indicate, that the `doc-valid-idents` should extend the default and not replace it
changelog: enhancement: [`blacklisted-name`]: Users can now indicate, that the `blacklisted-names` should extend the default and not replace it

Closes: #8877

That's it. Have a fantastic weekend to everyone reading this. Here is a cookie 🍪
2022-06-06 16:34:27 +00:00
bors
0f6e50fe1b Auto merge of #8933 - DennisOSRM:needless_braces_range_literal, r=dswij
Add new lint [`needless_parens_on_range_literals`]

changelog: Adds a new lint [`needless_parens_on_range_literals`] to warn on needless braces on literals in a range statement

For example, the lint would catch

```log
error: needless parenthesis on range literals can be removed
  --> $DIR/needless_parens_on_range_literals.rs:8:13
   |
LL |     let _ = ('a')..=('z');
   |             ^^^^^ help: try: `'a'`
   |
   = note: `-D clippy::needless-parens-on-range-literals` implied by `-D warnings`
```
2022-06-06 10:58:33 +00:00
bors
3e771624e1 Auto merge of #8951 - mikerite:needless-late-init-20220605, r=giraffate
Some refactoring in `needless_late_init`

changelog: none
2022-06-06 00:25:14 +00:00
Dennis Luxen
8ba377a783 Fix names to use plural 2022-06-05 22:47:21 +02:00
Dennis Luxen
bf7a786481 Apply suggestions from code review
Co-authored-by: dswij <dharmasw@outlook.com>
2022-06-05 22:47:15 +02:00
Dennis Luxen
58a605f453 Rerun cargo dev update_lints 2022-06-05 22:47:08 +02:00
Dennis Luxen
c0aa1f78b4 Implement suggestion generation with snippet_with_applicability(.) 2022-06-05 22:47:01 +02:00
Dennis Luxen
0409306bb0 Implement support for implicit start and end 2022-06-05 22:46:53 +02:00
Dennis Luxen
2e6903ccf9 Move description into lint macro 2022-06-05 22:46:41 +02:00
Dennis Luxen
90c8463d7e Rewrite check to account for floating point literals 2022-06-05 22:46:34 +02:00
Dennis Luxen
5948959c7e Fix misnomer braces -> parenthesis 2022-06-05 22:46:23 +02:00
Dennis Luxen
8bc1be17d6 Update clippy_lints/src/needless_braces_on_range_literal.rs
Co-authored-by: Alex <69764315+Serial-ATA@users.noreply.github.com>
2022-06-05 22:46:11 +02:00
Dennis Luxen
3058cb941c Update clippy_lints/src/needless_braces_on_range_literal.rs
Co-authored-by: Alex <69764315+Serial-ATA@users.noreply.github.com>
2022-06-05 22:46:03 +02:00
Dennis Luxen
ba43f0aee9 Add new lint [needless_braces_on_range_literal] 2022-06-05 22:45:57 +02:00
Serial
0902f3ca81 Make [create_dir] example ignored 2022-06-05 16:06:47 -04:00
Serial
9aeed6b9bf Improve lint doc consistency 2022-06-05 16:03:18 -04:00
bors
3e52dee646 Auto merge of #8941 - DevAccentor:for_loops_over_fallibles, r=llogiq
improve [`for_loops_over_fallibles`] to detect the usage of iter, iter_mut and into_iterator

fix #6762

detects code like
```rust
for _ in option.iter() {
    //..
}
```

changelog: Improve [`for_loops_over_fallibles`] to detect `for _ in option.iter() {}` or using `iter_mut()` or `into_iterator()`.
2022-06-05 11:16:37 +00:00
Michael Wright
a2de34720d needless_late_init refactoring
Remove the unneeded wrapping and unwrapping in suggestion creation.
Collecting to Option<Vec<_>> only returns None if one of the elements is
None and that is never the case here.
2022-06-05 07:30:59 +02:00
Michael Wright
2a1a80d80c needless_late_init refactoring
Simplify the creation of suggestions by using `flat_map` instead of
`chain`. Note that the order of the suggestions is not important.
2022-06-05 07:30:59 +02:00
Michael Wright
94e321a6ff needless_late_init refactoring
Remove duplication in creating suggestions by first mapping assignments
to spans and then suggestions.
2022-06-05 07:30:59 +02:00
Jason Newcomb
648dbebfb1 Actually get the correct ParamEnv in derive_partial_eq_without_eq 2022-06-04 20:35:41 -04:00
Jason Newcomb
a0821fbd75 Don't lint derive_partial_eq_without_eq on private types 2022-06-04 17:28:23 -04:00
xFrednet
c31b4a9d21
List configuration values can now be extended instead of replaced 2022-06-04 16:03:25 +02:00
bors
542d474d38 Auto merge of #8930 - kyoto7250:issue_8920, r=Alexendoo
fix(manual_find_map and manual_filter_map): check clone method

close #8920

Added conditional branching when the clone method is used.

Thank you in advance.

---

changelog: check `clone()` and other variant preserving methods in [`manual_find_map`] and [`manual_filter_map`]
2022-06-04 13:05:27 +00:00
kyoto7250
42cf98553a refactor: check copied and cloned 2022-06-04 21:28:14 +09:00
Philipp Krones
7f402b15c7
Merge remote-tracking branch 'upstream/master' into rustup 2022-06-04 12:53:27 +02:00
bors
8ef490871c Auto merge of #8843 - Serial-ATA:collect-renamed, r=xFrednet
Collect renamed lints

changelog: Display past names of renamed lints on Clippy's lint list

cc #7172

r? `@xFrednet`
2022-06-04 09:49:27 +00:00
DevAccentor
5a49918f36 improve for_loops_over_fallibles to detect the usage of iter, iter_mut and into_iterator 2022-06-04 11:11:00 +02:00
kyoto7250
990f8bf5a6 refactor: Add some methods 2022-06-04 17:15:55 +09:00
bors
b1a3e7e9c8 Auto merge of #8937 - Jarcho:merge_match_passes, r=llogiq
Merge various passes into `Matches`

changelog: None
2022-06-04 07:41:27 +00:00
Jason Newcomb
68c411ff94 Move ManualMap into Matches lint pass 2022-06-03 19:09:50 -04:00
Jason Newcomb
67cb5ec29f Move TryErr into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
dbc7753fb2 Merge SignificantDropInScrutinee into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
8c8a52eeeb Move MatchStrCaseMismatch into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
3d8d734150 Move MatchOnVecItems into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
b337f9e62e Merge ManualUnwrapOr into Matches lint pass 2022-06-03 19:09:49 -04:00
Jason Newcomb
81e44502ac Merge CollapsibleMatch into Matches lint pass 2022-06-03 12:14:24 -04:00
DevAccentor
64fe4e32db add as_underscore lint 2022-06-03 18:11:23 +02:00
Camille GILLOT
1e86cc5194 Manipulate lifetimes by LocalDefId for region resolution. 2022-06-03 12:03:20 +02:00
Ariel Uy
58cd01c2fc Add new lint mismatching_type_param_order
Add new lint for checking if type parameters are consistent between type
definitions and impl blocks.
2022-06-03 00:04:55 -07:00
bors
1194c6369e Auto merge of #8932 - dswij:pr-8879, r=giraffate
`needless_return` checks for macro expr in return stmts

closes #8879

Macro expressions in returns were not checked by `needless_return`. The test added in [this commit](6396a7a425 (diff-a869168cfafb7e6e5010feb76a16389d6c96d59e98113dee5c2b304a5160e43aR51-R55)) seems to have regressed.

changelog: [`needless_return`] checks for macro exprs in return statements
2022-06-03 00:00:23 +00:00
bors
97e5449a70 Auto merge of #8902 - PrestonFrom:add_suggestion_for_move_and_clone_when_not_ref, r=flip1995
When setting suggestion for significant_drop_in_scrutinee, add suggestion for MoveAndClone for non-ref

When trying to set the current suggestion, if the type of the expression
is not a reference and it is not trivially pure clone copy, we should still
trigger and emit a lint message. Since this fix may require cloning an
expensive-to-clone type, do not attempt to offer a suggested fix.

This change means that matches generated from TryDesugar and AwaitDesugar
would normally trigger a lint, but they are out of scope for this lint,
so we will explicitly ignore matches with sources of TryDesugar or
AwaitDesugar.

changelog: Update for ``[`significant_drop_in_scrutinee`]`` to correctly
emit lint messages for cases where the type is not a reference *and*
not trivially pure clone copy.
changelog: [`significant_drop_in_scrutinee`]: No longer lint on Try `?`
and `await` desugared expressions.
2022-06-02 17:16:43 +00:00