Commit graph

16986 commits

Author SHA1 Message Date
bors
4886937212 Auto merge of #10853 - MarcusGrass:fix-from-over-into-self, r=Alexendoo
Ignore fix for `from_over_into` if the target type contains a `Self` reference

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

This is my first time contributing here, and the fix is kind of ugly.
I've worked a bit with `quote` and was trying to figure out a way to replace the type in a better way than just a raw string-replace but couldn't quite figure out how to.

The only thing really required to fix this, is to replace all `Self` references with the type stated in the `from` variable, this isn't entirely simple to do with raw strings without creating a mess though.

We need to find and replace all `Self`'s in a variable with `from` but there could be an arbitrary amount, in a lot of different positions. As well as some type that contains the name self, like `SelfVarSelf` which shouldn't be replaced.

The strategy is essentially, if `"Self"` is surrounded on both sides by something that isn't alphanumeric, then we're golden, then trying to make that reasonably efficient.

I would not be offended if the solution is too messy to accept!

changelog: [from_over_into]: Replace Self with the indicated variable in suggestion and fix.
2023-06-04 17:53:54 +00:00
bors
58befc7de8 Auto merge of #10855 - Centri3:explicit_deref_methods, r=llogiq
Fix suggestion on fully qualified syntax

fixes #10850

changelog: [`explicit_deref_methods`]: Fix malformed suggestion on `Foo::deref(&foo)`
2023-06-04 14:40:50 +00:00
bors
167f249141 Auto merge of #10760 - NanthR:almost_standard_formulation, r=xFrednet
Standard lint formulations

A WIP that fixes #10660. Fix lints that don't conform to the standard formulation.

changelog: none
2023-06-04 10:48:03 +00:00
bors
fdb0b04458 Auto merge of #10881 - y21:explicit-into-iter-fn-arg-followup, r=llogiq
[`useless_conversion`]: pluralize if there are multiple `.into_iter()` calls

context: https://github.com/rust-lang/rust-clippy/pull/10814#issuecomment-1575036086

changelog: [`useless_conversion`]: pluralize if there are multiple `.into_iter()` calls in the chain

r? `@llogiq`
2023-06-03 19:05:01 +00:00
y21
5a7e33e5b2 add plural form to useless_conversion if depth > 0 2023-06-03 19:38:55 +02:00
bors
8a30f2f71a Auto merge of #10814 - y21:issue10743, r=llogiq
new lint: `explicit_into_iter_fn_arg`

Closes #10743.
This adds a lint that looks for `.into_iter()` calls in a call expression to a function that already expects an `IntoIterator`. In those cases, explicitly calling `.into_iter()` is unnecessary.
There were a few instances of this in clippy itself so I fixed those as well in this PR.

changelog: new lint [`explicit_into_iter_fn_arg`]
2023-06-03 15:57:36 +00:00
bors
2490de476a Auto merge of #10866 - est31:manual_let_else_pattern, r=Manishearth
manual_let_else: support struct patterns

This adds upon the improvements of #10797 and:

* Only prints `()` around `Or` patterns at the top level (fixing a regression of #10797)
* Supports multi-binding patterns: `let (u, v) = if let (Some(u_i), Ok(v_i)) = ex { (u_i, v_i) } else ...`
* Traverses through tuple patterns: `let v = if let (Some(v), None) = ex { v } else ...`
* Supports struct patterns: `let v = if let S { v, w, } = ex { (v, w) } else ...`

```
changelog: [`manual_let_else`]: improve pattern printing to support struct patterns
```

fixes #10708
fixes #10424
2023-06-03 14:25:39 +00:00
bors
52c235351a Auto merge of #10879 - Centri3:ptr_cast_constness, r=blyxyas,xFrednet
[`ptr_cast_constness`]: Only lint on casts which don't change type

fixes #10874

changelog: [`ptr_cast_constness`]: Only lint on casts which don't change type
2023-06-03 13:19:59 +00:00
bors
a97a94ab17 Auto merge of #10834 - whee:gh-pages-retain-filter-state, r=xFrednet
Use URL parameters for filter states

This fixes #8510 by storing Clippy Lints page filter configuration in the URL parameters.

This includes:
- Lint levels
- Lint groups
- Version filters

"Filter" was already present in the URL and its behavior is retained. There is existing support for passing a `sel` query parameter; this is also retained, but I am not sure if it used in the wild.

The URL parameters only get included if they are modified after loading the page.

I have these changes available here in case people want to play with it: https://whee.github.io/rust-clippy/master/

An example with levels, groups, and versions set (oddly):

https://whee.github.io/rust-clippy/master/#/?groups=pedantic,perf&levels=allow,warn&versions=gte:53,lte:57,eq:54

Adding a filter:

https://whee.github.io/rust-clippy/master/#/manual_str_repeat?groups=pedantic,perf&levels=allow,warn&versions=gte:53,lte:57,eq:54

---

changelog: Docs: [`Clippy's lint list`] now stores filter parameters in the URL, to allow easy sharing
[#10834](https://github.com/rust-lang/rust-clippy/pull/10834)
<!-- changelog_checked -->
2023-06-03 11:39:02 +00:00
Brian Hetro
ac279efdbc Clippy Lints page - Do not show filters in URL if configured as default values 2023-06-03 00:04:19 -04:00
Brian Hetro
2e4ef8e72c Clippy Lints page - Fix path watch triggering 2023-06-02 22:57:21 -04:00
Raghul Nanth A
50c93bbfd2 refactor(test): Move attribute to lint level 2023-06-03 00:00:45 +05:30
Raghul Nanth A
7ac15f9000 Add lint to check lint formulation messages
Fix lints that don't conform to the standard formulation
2023-06-03 00:00:30 +05:30
Centri3
cd1d7a3c6f weird 2023-06-02 13:26:12 -05:00
Centri3
ad7c44b3e4 only lint when cast_from and cast_to's ty are the same 2023-06-02 13:14:16 -05:00
bors
c85ceeae3f Auto merge of #10821 - Centri3:unnecessary_operation_cast_underscore, r=dswij
Emit `unnecessary_cast` on raw pointers as well

Supersedes(?) #10782, since this and #10567 will cover the original issue.
Does not lint on type aliases or inferred types.

changelog: [`unnecessary_cast`]: Also emit on casts between raw pointers with the same type and constness
2023-06-02 17:23:56 +00:00
bors
00001d6e08 Auto merge of #10699 - blyxyas:book-lint_config, r=flip1995
Clippy Book Chapter Updates Reborn: Refresh Lint Configuration's looks

This PR modernizes and clears up some confusion with the "Lint Configuration Options" chapter from the book.

### Changes

- **Remove 'Option - Default Value" table**

    - Why was it even there?
    - It shouldn't be the first thing an user sees when they enter the chapter. It's clunky, ugly and not useful. The default values for configs are stated in a per-config basis if needed.

- **Add a simple description of what the chapter contains, and the scheme of each configuration option**

- **Minor formatting, mainly adding code fragments to code text**

    - It seemed weird and jarring not having back-ticks on text like "arithmetic_side_effects".
    -  Improves readability and separation between configs.

- **Separate a little bit the Affected Lints list + "Affected lists" message**

    - Not having something indicating that the list is about the lints that use the configuration option is confusing.
    - It isn't as important as the description and example. Therefore should be separated a little bit imo

---

This is an independent effort from #10597, but as it's still a Book Chapter Update, I thought it would be cool to include it here. I'm going to keep the reviewing process for this PR to rustbot's desires.

[Rendered](https://github.com/blyxyas/rust-clippy/blob/book-lint_config/book/src/lint_configuration.md)
[Current](https://github.com/rust-lang/rust-clippy/blob/master/book/src/lint_configuration.md)

changelog: Refresh styling from the "Lint Configuration Options" book chapter.
2023-06-02 12:51:26 +00:00
est31
f538402701 Support struct patterns 2023-06-02 14:46:27 +02:00
est31
86d57b7bd4 Support multi-binding situations as well as tuple patterns 2023-06-02 14:46:27 +02:00
bors
f0dc0bc1c2 Auto merge of #10862 - xFrednet:changelog-1-70, r=flip1995
Update *Current stable* text in `CHANGELOG.md`

Roses are red,
violets are blue,
the new version was released,
and our changelog too

---

changelog: none
2023-06-02 12:37:52 +00:00
bors
7c448a6910 Auto merge of #10860 - ihciah:master, r=Manishearth
add checking for cfg(features = ...)

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

changelog: [`maybe_misused_cfg`]: check if `#[cfg(feature = "...")]` misused as `#[cfg(features = "...")]`

I've found that there is no indication when `#[cfg(features = "...")]` is used incorrectly, which can easily make mistakes hard to spot. When I searched for this code on github, I also found many misuse cases([link](https://github.com/search?q=%23%5Bcfg%28features+language%3ARust&type=code)).

PS: This clippy name is just a temporary name, it can be replaced with a better name.
2023-06-02 09:36:05 +00:00
ihciah
ad76687b2f add checking for cfg(features = ...) 2023-06-02 09:01:51 +00:00
bors
30448e8cf9 Auto merge of #10871 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-06-02 08:22:37 +00:00
Philipp Krones
84f8ce801e
Bump Clippy version -> 0.1.72 2023-06-02 10:18:34 +02:00
Philipp Krones
dfdc25834e
Bump nightly version -> 2023-06-02 2023-06-02 10:18:17 +02:00
Philipp Krones
aa3247c891
Merge remote-tracking branch 'upstream/master' into rustup 2023-06-02 10:17:55 +02:00
bors
50ab3ce6c9 Auto merge of #10607 - beetrees:toml-spans, r=giraffate
Add spans to `clippy.toml` error messages

Adds spans to errors and warnings encountered when parsing `clippy.toml`.

changelog: Errors and warnings generated when parsing `clippy.toml` now point to the location in the TOML file the error/warning occurred.
2023-06-02 08:01:31 +00:00
beetrees
6f13a37499
Add spans to clippy.toml error messages 2023-06-02 00:56:27 +01:00
Centri3
eed466281c ignore Foo::deref altogether 2023-06-01 14:29:56 -05:00
xFrednet
a28eb5995f
Update *Current stable* text in CHANGELOG.md 2023-06-01 21:14:07 +02:00
est31
0a7366897d manual_let_else: only add () around PatKind::Or at the top level
At the top level, () are required, but on the levels below they are not.
2023-06-01 18:55:24 +02:00
bors
9524cff2b4 Auto merge of #10857 - MarcusGrass:update-configuration-file-doc, r=flip1995
Explain which paths clippy searches for configuration in docs

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

Adds information on where to place the configuration files, it may be a bit verbose. Also added a comment to the section of the code where the search happens, to hopefully prevent changing that without updating the docs.

changelog: Make documentation about where to place configuration files clearer.
2023-06-01 15:27:25 +00:00
MarcusGrass
b2c85b31bb
Move bail into lint to prevent no-linting, move to unfixable 2023-06-01 16:02:42 +02:00
MarcusGrass
194343fcea
Explain path-search using a list 2023-06-01 12:54:20 +02:00
MarcusGrass
5f5e2e2ac1
Explain which paths clippy searches for configuration in docs 2023-06-01 12:14:55 +02:00
MarcusGrass
16f1cf8fd4
Ignore from_over_into if it contains Self 2023-06-01 10:46:29 +02:00
Centri3
8188da3614 Fix suggestion on fully qualified syntax 2023-05-31 23:33:30 -05:00
bors
652b4c720d Auto merge of #10616 - y21:missing_field_in_debug, r=Alexendoo
new lint: `missing_fields_in_debug`

Fixes #10429

This PR adds a new lint that looks for manual `Debug` implementations that do not "use" all of the fields.
This often happens when adding a new field to a struct.
It also acts as a style lint in case leaving out a field was intentional. In that case, it's preferred to use [`DebugStruct::finish_non_exhaustive`](https://doc.rust-lang.org/stable/std/fmt/struct.DebugStruct.html#method.finish_non_exhaustive), which indicates that there are more fields that were explicitly not shown.

```
changelog: [`missing_fields_in_debug`]: missing fields in manual `Debug` implementation
```
2023-05-31 22:07:58 +00:00
y21
a859b0e6df don't lint enums, update note in lint description 2023-05-31 23:52:02 +02:00
y21
f74ec6b1b8 new lint: missing_field_in_debug
move some strings into consts, more tests

s/missing_field_in_debug/missing_fields_in_debug

dont trigger in macro expansions

make dogfood tests happy

minor cleanups

replace HashSet with FxHashSet

replace match_def_path with match_type

if_chain -> let chains, fix markdown, allow newtype pattern

fmt

consider string literal in `.field()` calls as used

don't intern defined symbol, remove mentions of 'debug_tuple'

special-case PD, account for field access through `Deref`
2023-05-31 23:52:02 +02:00
MarcusGrass
d4b388eb43
Add from_over_into replace for type in Self reference 2023-05-31 17:46:05 +02:00
bors
594a2cba93 Auto merge of #10852 - Alexendoo:issue-template, r=flip1995
Remove lint name and category fields from the new lint issue form

changelog: none

Picking a name/category is something the implementers/reviewers tend to cover anyway, I think asking people to come up with it at the time of their suggestion is more of a barrier than it's worth

Inspired by the mention in #10849
2023-05-31 15:24:03 +00:00
Alex Macleod
de62139513 Remove lint name and category fields from the new lint issue form 2023-05-31 14:30:00 +00:00
bors
e85869578d Auto merge of #10845 - disco07:master, r=giraffate
nonminimal_bool fix double not

fix issue https://github.com/rust-lang/rust-clippy/issues/10836

changelog: Fix [`nonminimal_bool`] false positive when `!!x`, `x` isn't boolean and implements `Not`
2023-05-31 13:36:09 +00:00
Urgau
1a5db18b11 Drop uplifted clippy::cast_ref_to_mut 2023-05-31 13:42:53 +02:00
disco07
e4927f98fa change booleans file and update tests 2023-05-31 00:17:26 +02:00
y21
d816eba09d fix new failing proc macro tests 2023-05-30 22:32:47 +02:00
y21
de1f410018 merge explicit_into_iter_fn_arg into useless_conversion 2023-05-30 22:32:26 +02:00
bors
8793c2a576 Auto merge of #10848 - charmitro:wildcard-prelude-detection, r=llogiq
[`wildcard_imports`] Modules that contain `prelude` are also allowed

This commit fixes #10846 by checking if the path segment contains the word "prelude", allowing us
`use module_prelude::*`.

changelog: [`wildcard_imports`]: Modules that contain `prelude` are also allowed
2023-05-30 19:17:03 +00:00
Charalampos Mitrodimas
288312463e [wildcard_imports] Modules that contain prelude are also allowed
This commit fixes #10846 by checking if the path segment contains the
word "prelude".

Signed-off-by: Charalampos Mitrodimas <charmitro@gmail.com>
2023-05-30 21:29:04 +03:00