Commit graph

9766 commits

Author SHA1 Message Date
y21
5b6ba204a7 fmt 2023-06-14 17:01:57 +02:00
y21
2ba1926955 [derivable_impls]: don't lint if expr unsize-coerces 2023-06-14 16:52:02 +02:00
Centri3
830d307d0a refactor a bit 2023-06-14 08:41:20 -05:00
Centri3
27a701a670 [match_same_arms]: don't lint if non_exhaustive_omitted_patterns
formatting :/
2023-06-14 08:36:09 -05:00
Kisaragi Marine
79f93a655a
missing_panics_doc: pickup expect method 2023-06-14 22:26:57 +09:00
Centri3
72aa180798 use rustc's criteria for a temporary 2023-06-14 06:56:38 -05:00
bors
1d0d686f10 Auto merge of #10950 - KisaragiEffective:ignore_main_in_notest_doc_block, r=xFrednet
[`needless_doctest_main`]: ignore `main()` in `no_test` code fences

close #10491

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

changelog: [`needless_doctest_main`]: ignore `main()` in `no_test` code fence
2023-06-14 10:09:57 +00:00
bors
a59236ffb4 Auto merge of #10919 - y21:issue10579, r=blyxyas,xFrednet
[`map_unwrap_or`]: don't lint when referenced variable is moved

Fixes #10579.

The previous way of checking if changing `map(f).unwrap_or(a)` to `map_or(a, f)` is safe had a flaw when the argument to `unwrap_or` moves a binding and the `map` closure references that binding in some way.

It used to simply check if any of the identifiers in the `unwrap_or` argument are referenced in the `map` closure, but it didn't consider the case where the moved binding is referred to through references, for example:
```rs
let x = vec![1, 2];
let x_ref = &x;
Some(()).map(|_| x_ref.clone()).unwrap_or(x);
```
This compiles as is, but we cannot change it to `map_or`. This lint however did suggest changing it, because the simple way of checking if `x` is referenced anywhere in the `map` closure fails here. The safest thing to do here imo (what this PR does) is check if the moved value `x` is referenced *anywhere* in the body (before the `unwrap_or` call). One can always create a reference to the value and smuggle them into the closure, without actually referring to `x`. The original, linked issue shows another one such example:
```rs
    let x = vec![1,2,3,0];
    let y = x.strip_suffix(&[0]).map(|s| s.to_vec()).unwrap_or(x);
```
`x.strip_suffix(&[0])` creates a reference to `x` that is available through `s` inside of the `map` closure, so we can't change it to `map_or`.

changelog: [`map_unwrap_or`]: don't lint when referenced variable is moved
2023-06-14 09:48:22 +00:00
bors
b9b453748d Auto merge of #10945 - Centri3:no_effect, r=llogiq
[`no_effect`]: Suggest adding `return` if applicable

Closes #10941

Unfortunately doesn't catch anything complex as `no_effect` already wouldn't, but I'm fine with that (it catches `ControlFlow` at least :D)

changelog: [`no_effect`]: Suggest adding `return` if statement has same type as function's return type and is the last statement in a block
2023-06-14 06:39:44 +00:00
Kisaragi Marine
062b209904
Ignore main() in no_test code fences 2023-06-14 12:31:49 +09:00
Centri3
d2725402a9 [borrow_as_ptr]: Ignore temporaries 2023-06-13 17:53:36 -05:00
Centri3
74a0c9c62f [needless_lifetimes]' suggestion now points at the lifetimes 2023-06-13 14:05:22 -05:00
Centri3
d255e7a53f [no_effect]: suggest adding return if applicable
make cargo test pass

Revert "Make it `Unspecified`"

This reverts commit 774863041c1878ab7fb6e27c1c61c04de0e25bc8.

Make it `Unspecified`
2023-06-13 13:23:33 -05:00
bors
72332b2598 Auto merge of #10944 - GuillaumeGomez:cleanup-needless-pass-by-value, r=xFrednet
Remove dead code in `needless_pass_by_value`

The `spans_need_deref` is never used so I removed it alongside all linked code as well.

changelog: none
2023-06-13 15:58:10 +00:00
Guillaume Gomez
bcaf655b70 Remove dead code in needless_pass_by_value 2023-06-13 17:08:51 +02:00
blyxyas
d5b2f11340
Now cargo collect-metadata updates the CHANGELOG.md 2023-06-13 16:52:18 +02:00
Centri3
357e80ea0d Ignore more type aliases in unnecessary_cast 2023-06-13 06:51:56 -05:00
bors
8a1f0cd765 Auto merge of #10935 - Alexendoo:needless-if-cases, r=Manishearth
Don't lint non-statement/faux empty `needless_if`s

Also has a basic fall-back for `if` statements that have attributes applied to them and incorporates https://github.com/rust-lang/rust-clippy/pull/10921#pullrequestreview-1474008780 while I was there

r? `@Manishearth`

changelog: none
2023-06-13 04:34:37 +00:00
bors
7c2bf28365 Auto merge of #10358 - pksunkara:unnecessary-unwrap, r=llogiq
Add `unnecessary_literal_unwrap` lint

Add lint for more unnecessary unwraps and suggest fixes for them.

Fixes #10352

- [x] 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`

r? `@llogiq`

---

changelog: New lint [`unnecessary_literal_unwrap`]
[#10358](https://github.com/rust-lang/rust-clippy/pull/10358)
<!-- changelog_checked -->
2023-06-12 18:04:22 +00:00
bors
da56c3502a Auto merge of #10933 - y21:issue2262-followup, r=Centri3
[`useless_vec`]: lint on `vec![_]` invocations that adjust to a slice

Fixes #2262 (well, actually my PR over at #10901 did do most of the stuff, but this PR implements the one last other case mentioned in the comments that my PR didn't fix)

Before this change, it would lint `(&vec![1]).iter().sum::<i32>()`, but not `vec![1].iter().sum::<i32>()`. This PR handles this case.
This also refactors a few things that I wanted to do in my other PR but forgot about.

changelog: [`useless_vec`]: lint on `vec![_]` invocations that adjust to a slice
2023-06-12 16:25:59 +00:00
Centri3
6702c7a7a6 Add lint [single_range_in_vec_init] 2023-06-12 11:09:52 -05:00
Pavan Kumar Sunkara
6e4c5561be Preserve type annotations when present 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
6e4dc93e24 Support suggesting panics 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
69af0e13b2 Recognize Err 2023-06-12 16:19:26 +01:00
rsdy
6e0e09c8f7 Track init and unwrap of expr 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
7ed7283e0f Recognize unwrap_or_else method 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
8f83502989 Recognize unwrap_or methods 2023-06-12 16:19:26 +01:00
rsdy
1d159e7d11 Recognize Ok 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
daf6197481 Implement the suggestion 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
21b88ce290 Implement the lint for expect 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
0b1bb5fbf3 Implement the lint 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
2902359b3c Add the lint to the lib 2023-06-12 16:19:26 +01:00
rsdy
5bb768177e Add hook 2023-06-12 16:19:26 +01:00
Pavan Kumar Sunkara
e707447a86 Boilerplate for the new lint 2023-06-12 16:19:26 +01:00
Alex Macleod
5e20a572ee Don't lint non-statement/faux empty needless_ifs 2023-06-12 15:19:00 +00:00
y21
b309875fd8 [useless_vec]: detect unnecessary vec![_] 2023-06-12 15:48:04 +02:00
bors
b095247ab6 Auto merge of #10911 - lochetti:fix_9657, r=Alexendoo
Don't linting `as_conversions` in proc macros

Don't linting `as_conversions` if code was generated by procedural macro.

This PR fixes https://github.com/rust-lang/rust-clippy/issues/9657

I implemented the fix changing the lint code to be a `LateLintPass` in order to be able to use the `is_from_proc_macro` out of the box. If the reviwer thinks that it would be better to do the other way (implementing `WithSearchPat`) just let me know. I might need some help in implementing it for the `ustc_ast::ast::Expr`

changelog: [`as_conversions`] avoiding warnings in macro-generated code
2023-06-12 12:28:36 +00:00
y21
de7d43bc61 make lint description easier to read, prevent ICE 2023-06-12 12:21:38 +02:00
y21
7aa4babb5c rename "drawbacks" to "known issues" 2023-06-12 12:21:38 +02:00
y21
6b232fdee9 use span_lint_and_note 2023-06-12 12:21:38 +02:00
y21
52c6ef77fd fmt 2023-06-12 12:21:38 +02:00
y21
760f91f895 cargo dev update_lints 2023-06-12 12:21:38 +02:00
y21
7312a93a06 new lint: large_stack_frames 2023-06-12 12:21:38 +02:00
Centri3
29c1c6e104 refactor and add link to issue 2023-06-12 03:22:01 -05:00
Centri3
95d1bff225 add to tests and configuration 2023-06-12 03:22:01 -05:00
Centri3
243943ff56 make it work for locals as well
oopos
2023-06-12 03:22:01 -05:00
Centri3
7cdd87ca4a ignore generics and allow arbitrary threshold 2023-06-12 03:22:01 -05:00
Centri3
03c8db048e make cargo test pass + example 2023-06-12 03:21:43 -05:00
Centri3
e2ecb132a5 rename the lint 2023-06-12 03:21:43 -05:00
Centri3
52cfc997af Add lint single_letter_idents 2023-06-12 03:21:43 -05:00
bors
903fe3b9f2 Auto merge of #10894 - Centri3:type_repetition_in_bounds, r=blyxyas,xFrednet
[`type_repetition_in_bounds`]: Don't lint on derived code

fixes #10504.

changelog: [`type_repetition_in_bounds`]: Don't lint on derived code
2023-06-12 07:18:39 +00:00
bors
841f2199e0 Auto merge of #10416 - Jarcho:explicit_iter_loop_ext, r=Manishearth
Extend `explicit_iter_loop` and `explicit_into_iter_loop`

fixes #1518

Some included cleanups
* Split `for_loop` test into different files for each lint (partially).
* Move handling of some `into_iter` cases from `explicit_into_iter`.

---

changelog: Enhancement: [`explicit_iter_loop`]: Now also handles types that implement `IntoIterator`.
[#10416](https://github.com/rust-lang/rust-clippy/pull/10416)

changelog: Sugg: [`explicit_into_iter_loop`]: The suggestion now works on mutable references.
[#10416](https://github.com/rust-lang/rust-clippy/pull/10416)
<!-- changelog_checked -->
2023-06-12 05:30:32 +00:00
bors
21e6235b4c Auto merge of #10921 - Centri3:needless_if, r=blyxyas,Manishearth
Add `needless_if` lint

first off: Sorry about the large diff. Seems a ton of tests do this (understandably so).

this is basically everything I wanted in #10868, while it doesn't lint *all* unnecessary empty blocks, it lints needless if statements; which are basically the crux of the issue (for me) anyway. I've committed code that includes this far too many times 😅 hopefully clippy can help me out soon

closes #10868

changelog: New lint [`needless_if`]
2023-06-12 04:18:50 +00:00
y21
c9daec2585 [unnecessary_fold]: suggest turbofish if necessary 2023-06-12 03:20:55 +02:00
y21
e305b0730f fix docs 2023-06-12 00:20:54 +02:00
y21
7280ad9f7b [redundant_closure_call]: handle nested closures 2023-06-11 23:54:48 +02:00
Centri3
108c04acf0 Stop visiting once it's found Let 2023-06-11 09:43:26 -05:00
Centri3
59bca098f9 don't lint on if let
don't lint on `if let`
2023-06-11 07:02:20 -05:00
Centri3
4c7bc1785d ignore more type aliases in unnecessary_cast
ignore more type aliases in unnecessary_cast
2023-06-11 06:59:01 -05:00
Centri3
b2bdc37a55 add description
add description
2023-06-11 05:46:18 -05:00
bors
e986b6444e Auto merge of #10917 - Centri3:module_inception, r=xFrednet
allow disabling module inception on private modules

Fixes #10842

changelog: Enhancement [`module_inception`]: Added `allow-private-module-inception` configuration.
[#10917](https://github.com/rust-lang/rust-clippy/pull/10917)
<!-- changelog_checked -->
2023-06-10 13:21:48 +00:00
Centri3
b303e2053c allow disabling module inception on private modules
allow disabling module inception on private modules
2023-06-10 08:09:07 -05:00
bors
9011c4d248 Auto merge of #10918 - Centri3:patch-2, r=xFrednet
Fix `excessive_nesting` example

whoops 😅

changelog: none
2023-06-10 13:06:44 +00:00
Centri3
26f50395ba Add needless_if lint 2023-06-10 06:51:03 -05:00
Urgau
edb3266b91 Drop uplifted clippy:cmp_nan 2023-06-10 11:13:01 +02:00
Jason Newcomb
949712c90a Reborrow mutable references in explicit_iter_loop 2023-06-09 21:40:03 -04:00
Jason Newcomb
482baf2bcc Fix explicit_into_iter_loop with mutable references 2023-06-09 21:40:03 -04:00
bors
d44ea7c5c5 Auto merge of #10785 - Centri3:diverting_sub_expression, r=Jarcho
Fix `diverging_sub_expression` not checking body of block

Fixes #10776

This also adds a warning to the test `ui/never_loop.rs`, not sure if this is correct or not.

changelog: [`diverging_sub_expression`]: Fix false negatives with body of block
2023-06-10 00:16:43 +00:00
y21
9d58a42623 [map_unwrap_or]: don't lint when referenced variable is moved 2023-06-10 01:38:04 +02:00
Jason Newcomb
b6fa4d43d3 Extend explicit_iter_loop to all types 2023-06-09 19:24:55 -04:00
Catherine
d1957b87c8
Update excessive_nesting.rs 2023-06-09 16:29:34 -05:00
Catherine
b7fedb88cf
Update excessive_nesting.rs 2023-06-09 16:28:01 -05:00
bors
476efe92e7 Auto merge of #10672 - Centri3:excessive-width-lints, r=Alexendoo
Add `excessive_nesting` lint

changelog: new lint [`excessive_nesting`]
2023-06-09 20:47:06 +00:00
Centri3
35aff1ae86 refactor 2023-06-09 15:32:42 -05:00
Centri3
c1c134a288 ensure there are no stmts for expr check 2023-06-09 11:44:59 -05:00
Centri3
0c545c7bcc also lint single expression blocks
Update mixed_read_write_in_expression.rs

Update diverging_sub_expression.stderr
2023-06-09 11:44:59 -05:00
bors
b356491a31 Auto merge of #111530 - Urgau:uplift_undropped_manually_drops, r=compiler-errors
Uplift `clippy::undropped_manually_drops` lint

This PR aims at uplifting the `clippy::undropped_manually_drops` lint.

## `undropped_manually_drops`

(warn-by-default)

The `undropped_manually_drops` lint check for calls to `std::mem::drop` with a value of `std::mem::ManuallyDrop` which doesn't drop.

### Example

```rust
struct S;
drop(std::mem::ManuallyDrop::new(S));
```

### Explanation

`ManuallyDrop` does not drop it's inner value so calling `std::mem::drop` will not drop the inner value of the `ManuallyDrop` either.

-----

Mostly followed the instructions for uplifting an clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler

-----

For Clippy:

changelog: Moves: Uplifted `clippy::undropped_manually_drops` into rustc
2023-06-09 12:44:23 +00:00
bors
05de787089 Auto merge of #10913 - y21:issue10033, r=Manishearth,Centri3
[`unnecessary_to_owned`]: check that the adjusted type matches target

Fixes #10033.

Before this change, the lint would assume that removing the `.to_string()` in `f(&x.to_string())` would be ok if x is of some type that implements `Deref<Target = str>` and `f` takes a `&str`.
This turns out to not actually be ok if the `to_string` call is some method that exists on `x` directly, which happens if it implements `Display`/`ToString` itself.

changelog: [`unnecessary_to_owned`]: only lint if the adjusted receiver type actually matches
2023-06-09 08:52:44 +00:00
y21
dd084940de check that the adjusted receiver type matches target 2023-06-09 04:13:00 +02:00
bors
384cf37612 Auto merge of #10910 - Alexendoo:unnecessary-pointer-casts, r=llogiq
Ignore more pointer types in `unnecessary_cast`

Spotted this because

e2c655b4c0/tests/ui/suspicious_to_owned.rs (L9-L10)

currently fails on `aarch64-unknown-linux-gnu` as `c_char` is `u8` there

The current implementation checks for `as alias`, `as _`. This adds things like
- `as *const alias`
- `as *const cfg_dependant`
- `as *const _`

changelog: none
2023-06-08 19:38:12 +00:00
Alex Macleod
4346c992cb Ignore more pointer types in unnecessary_cast 2023-06-08 18:19:35 +00:00
Renato Lochetti
55c9100334
Don't ling as_conversions in proc macros 2023-06-08 19:04:35 +01:00
Alex Macleod
96697d2ee7 Fix useless_vec suggestion in for _ in vec![..] 2023-06-08 17:27:12 +00:00
bors
b7c330fc78 Auto merge of #10905 - y21:issue10684, r=Alexendoo
[`redundant_closure`]: special case inclusive ranges

Fixes #10684.

`x..=y` ranges need a bit of special handling in this lint because it desugars to a call to the lang item `RangeInclusiveNew`, where the callee span would be the same as the range expression itself, so the suggestion looked a bit weird. It now correctly suggests `RangeInclusive::new`.

changelog: [`redundant_closure`]: special case `RangeInclusive`
2023-06-08 12:15:35 +00:00
bors
60258b061d Auto merge of #10898 - avborhanian:master, r=Manishearth,Centri3
Adds new lint `arc_with_non_send_or_sync`

Fixes #653

Adds a new lint to check for uses of non-Send/Sync types within Arc.

```
changelog: [`arc_with_non_send_sync`]: Added a lint to detect uses of non-Send/Sync types within Arc.
```
2023-06-08 09:46:01 +00:00
Urgau
f47e9156a4 Drop uplifted clippy::undropped_manually_drops 2023-06-08 11:41:34 +02:00
avborhanian
20548eba6c Swapping to matches macro. 2023-06-08 00:38:18 -07:00
avborhanian
2f5d1c748a Adding extra check to ignore generic args. 2023-06-08 00:22:04 -07:00
Andrew Xie
737cba0c37 Whoops, submodule change was actually valid - undoing fixup 2023-06-08 01:05:38 -04:00
Andrew Xie
ecd6afaa12 fixup! Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:40:29 -04:00
Andrew Xie
f2f342adb4 Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:38:50 -04:00
bors
177c6fea1f Auto merge of #10901 - y21:smarter-useless-vec, r=Manishearth,Centri3
[`useless_vec`]: lint `vec!` invocations when a slice or an array would do

First off, sorry for that large diff in tests. *A lot* of tests seem to trigger the lint with this new change, so I decided to `#![allow()]` the lint in the affected tests to make reviewing this easier, and also split the commits up so that the first commit is the actual logic of the lint and the second commit contains all the test changes. The stuff that changed in the tests is mostly just line numbers now. So, as large as the diff looks, it's not actually that bad. 😅
I manually went through all of these to find out about edge cases and decided to put them in `tests/ui/vec.rs`.

For more context, I wrote about the idea of this PR here: https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-1579155257 (that explains the logic)

Basically, it now also considers the case where a `Vec` is put in a local variable and the user only ever does things with it that one could also do with a slice or an array. This should catch a lot more cases, and (at least from looking at the tests) it does.

changelog: [`useless_vec`]: lint `vec!` invocations when a slice or an array would do (also considering local variables now)
2023-06-08 04:33:26 +00:00
bors
9ca1344d9a Auto merge of #10904 - lochetti:fix_10273, r=Centri3
`suspicious_else_formatting`: Don't warn if there is a comment between else and curly bracket

This PR fixes https://github.com/rust-lang/rust-clippy/issues/10273

The idea is that if the only thing after `else` and before `{` is a comment, we will not warn because, probably, the line break was "made" by rustfmt.

changelog: [`suspicious_else_formatting`]: Don't warn if the only thing between `else` and curly bracket is a comment
2023-06-08 04:18:08 +00:00
avborhanian
8330887e1b Updating documentation and lint formatting. 2023-06-07 20:53:52 -07:00
avborhanian
339cd14f27 Adds new lint arc_with_non_send_or_sync 2023-06-07 20:53:48 -07:00
Centri3
5da34559ee Check if from proc macro and better tests 2023-06-07 18:34:34 -05:00
Centri3
725399a178 move to complexity but don't lint by default 2023-06-07 18:34:34 -05:00
Centri3
378d77584a work with lint attributes 2023-06-07 18:34:34 -05:00
Centri3
493a23e957 check non-inline modules, ignore all macros 2023-06-07 18:34:34 -05:00
Centri3
88143ac295 decided against reinventing the wheel 2023-06-07 18:34:34 -05:00
Catherine
a9da61b115 couple more notes 2023-06-07 18:34:34 -05:00
Centri3
e68dbc3308 add excessive_nesting
Close code block in example
2023-06-07 18:34:34 -05:00
Centri3
4af3ac1cd8 change it to nursery category 2023-06-07 18:22:50 -05:00
Centri3
97c10075ec add the excessive_* style lints 2023-06-07 18:22:50 -05:00
bors
2360f80143 Auto merge of #10897 - y21:issue10887, r=Alexendoo
[`missing_fields_in_debug`]: don't ICE when self type is a generic param

Fixes #10887

This PR fixes an ICE that happens when the implementor (self type) of a `Debug` impl is a generic parameter.
The lint calls `TyCtxt::type_of` with that self type, which ICEs when called with generic parameters, so this just adds a quick check before getting there to ignore them.

That can only happen inside of core itself (afaik) because the orphan rules forbid defining an impl such as `impl<T> Debug for T` outside of core, so I'm not sure how to add a test for this.
It seems like this impl in particular caused this: https://doc.rust-lang.org/stable/std/fmt/trait.Debug.html#impl-Debug-for-F

changelog: [`missing_fields_in_debug`]: don't ICE on blanket `Debug` impl in core
2023-06-07 22:35:52 +00:00
y21
9ff34acf21 actually don't lint for inclusive range 2023-06-08 00:34:23 +02:00
y21
2c7cf2cfa1 handle RangeInclusive function desugar 2023-06-07 22:57:15 +02:00
Renato Lochetti
3e8f53b51d
Don't warn if there is a comment between else and curly bracket 2023-06-07 09:42:37 +01:00
y21
7af77f74da don't allow as_slice for now 2023-06-07 08:54:32 +02:00
bors
f729147325 Auto merge of #10865 - Centri3:let_with_type_underscore_tracing, r=Jarcho
[`let_with_type_underscore`]: Don't emit on locals from procedural macros

closes #10498

changelog: [`let_with_type_underscore`]: Don't emit on locals from procedural macros
2023-06-07 05:02:42 +00:00
Centri3
a434a7715d impl WithSearchPat for Ty 2023-06-06 22:16:02 -05:00
Centri3
ba1fb74bf1 check for _ instead 2023-06-06 21:01:14 -05:00
bors
c8a056547b Auto merge of #10564 - asquared31415:cast_doesnt_wrap, r=giraffate
make cast_possible_wrap work correctly for 16 bit {u,i}size

These changes make `cast_possible_wrap` aware of the different pointer widths and fixes the implementation to print the correct pointer widths.

Fixes #9337

changelog: `cast_possible_wrap` does not lint on `u8 as isize` or `usize as i8`, since these can never wrap.
`cast_possible_wrap` now properly considers 16 bit pointer size and prints the correct bit widths.
2023-06-06 23:54:27 +00:00
bors
cc8ead2cce Auto merge of #10570 - AlessioC31:redundant_type_annotations, r=xFrednet
Add redundant type annotations lint

Hello, I'm trying to add the `redundat_type_annotations` lint.

It's still WIP but I'd like to start gathering some feedbacks to be sure that I'm not doing things 100% wrong :)

Right now it still misses lints like:

- [x] `let foo: u32 = 5_u32`,
- [x] `let foo: String = STest2::func()`
- [x] `let foo: String = self.func()` (`MethodCall`)
- [x] refs
- [ ] Generics

I've some problems regarding the second example above, in the `init` part of the `Local` I have:

```rust
init: Some(
                Expr {
                    hir_id: HirId(DefId(0:24 ~ playground[e1bd]::main).58),
                    kind: Call(
                        Expr {
                            hir_id: HirId(DefId(0:24 ~ playground[e1bd]::main).59),
                            kind: Path(
                                TypeRelative(
                                    Ty {
                                        hir_id: HirId(DefId(0:24 ~ playground[e1bd]::main).61),
                                        kind: Path(
                                            Resolved(
                                                None,
                                                Path {
                                                    span: src/main.rs:77:21: 77:27 (#0),
                                                    res: Def(
                                                        Struct,
                                                        DefId(0:17 ~ playground[e1bd]::STest2),
                                                    ),
                                                    segments: [
                                                        PathSegment {
                                                            ident: STest2#0,
                                                            hir_id: HirId(DefId(0:24 ~ playground[e1bd]::main).60),
                                                            res: Def(
                                                                Struct,
                                                                DefId(0:17 ~ playground[e1bd]::STest2),
                                                            ),
                                                            args: None,
                                                            infer_args: true,
                                                        },
                                                    ],
                                                },
                                            ),
                                        ),
                                        span: src/main.rs:77:21: 77:27 (#0),
                                    },
                                    PathSegment {
                                        ident: get_numb#0,
                                        hir_id: HirId(DefId(0:24 ~ playground[e1bd]::main).62),
                                        res: Err,
                                        args: None,
                                        infer_args: true,
                                    },
                                ),
                            ),
                            span: src/main.rs:77:21: 77:37 (#0),
                        },
                        [],
                    ),
                    span: src/main.rs:77:21: 77:39 (#0),
                },
            ),
```

And I'm not sure how to get the return type of the function `STest2::func()` since the resolved path `DefId` points to the struct itself and not the function. Do you have any idea on how I could get this information in this case?

Thanks!

changelog: changelog: [`redundant_type_annotations`]: New lint to warn on redundant type annotations

fixes #9155
2023-06-06 21:10:29 +00:00
y21
566a365d4f make useless_vec smarter 2023-06-06 22:29:13 +02:00
asquared31415
7cd0ec58aa add more info link 2023-06-06 14:58:54 -04:00
bors
7ee3dcdb32 Auto merge of #10859 - MarcusGrass:let-and-ret-known-problems, r=giraffate
Bring up Rust lang #37612 as a known problem for let_and_return

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

I don't think conforming to this lint could trigger the issue immediately, only if subsequent code-changes go wrong, but I may be mistaken.

Since the lint can't trigger it by itself, just closing this issue might be reasonable, if not maybe this PR fixes it.

changelog: Update docs for `let_and_return`, mention rust-lang #37612
2023-06-06 00:09:09 +00:00
y21
1cf95a9d50 don't call type_of on generic params 2023-06-06 01:23:42 +02:00
Centri3
f68ee79864 Update trait_bounds.rs 2023-06-05 14:53:22 -05:00
Centri3
0250c51844 refactor 2023-06-05 14:46:47 -05:00
Centri3
6ea7cd8ec7 Fix #10504, don't lint on derived code 2023-06-05 14:38:38 -05:00
MarcusGrass
6f2497703e
Compact issue link
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2023-06-05 15:48:57 +02:00
Alessio Cosenza
a9b468f2b5
Add Limitations section 2023-06-05 10:22:46 +02:00
Alessio Cosenza
29ab954a2b
Add support to returned refs from MethodCall 2023-06-05 10:22:45 +02:00
Alessio Cosenza
6f26df1c9a
Extract common logic to function 2023-06-05 10:22:45 +02:00
Alessio Cosenza
6776608f21
Move redundant_type_annotations to restriction 2023-06-05 10:22:45 +02:00
Alessio Cosenza
01b1057258
Add redundant type annotations lint 2023-06-05 10:22:42 +02:00
bors
ae880e41a8 Auto merge of #10873 - Alexendoo:redundant-clone-nursery, r=flip1995
Move `redundant_clone` to `nursery`

changelog: [`redundant_clone`]: Move to `nursery`

A bunch of FPs in `redundant_clone` have sprung up after upstream MIR changes: https://github.com/rust-lang/rust/pull/108944

- https://github.com/rust-lang/rust-clippy/issues/10870
- https://github.com/rust-lang/rust-clippy/issues/10577
- https://github.com/rust-lang/rust-clippy/issues/10545
- https://github.com/rust-lang/rust-clippy/issues/10517

r? `@flip1995`
2023-06-05 08:00:51 +00:00
bors
eacd095f76 Auto merge of #10826 - Centri3:endian_bytes, r=Manishearth
Add lints for disallowing usage of `to_xx_bytes` and `from_xx_bytes`

Adds `host_endian_bytes`, `little_endian_bytes` and `big_endian_bytes`

Closes #10765

v - not sure what to put here since this adds 3 lints
changelog: Add `host_endian_bytes`, `little_endian_bytes` and `big_endian_bytes` lints
2023-06-05 02:38:41 +00:00
bors
1841661c80 Auto merge of #10869 - Centri3:allow_attributes, r=Manishearth
[`allow_attributes`, `allow_attributes_without_reason`]: Ignore attributes from procedural macros

I use `lint_reasons` and `clap`, which is a bit overzealous when it comes to preventing warnings in its macros; it uses a ton of allow attributes on everything to, as ironic as it is, silence warnings. These two now ignore anything from procedural macros.

PS, I think `allow_attributes.rs` should be merged with `attrs.rs` in the future.

fixes #10377

changelog: [`allow_attributes`, `allow_attributes_without_reason`]: Ignore attributes from procedural macros
2023-06-05 02:02:19 +00:00
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
Centri3
05bfcbd911 remove tuple 2023-06-03 14:38:16 -05:00
Centri3
7fe200ed05 derive Copy/PartialEq for Prefix 2023-06-03 14:31:40 -05: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
Centri3
b1a21ae347 Update endian_bytes.rs 2023-06-02 14:38:03 -05:00
Centri3
a6c36556c8 use enum for prefix instead of &str 2023-06-02 14:35:54 -05:00
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
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
Matthias Krüger
5a8ec9bbe7 Rollup merge of #112165 - fee1-dead-contrib:rn-defualtness, r=compiler-errors
Rename `impl_defaultness` to `defaultness`

Since this isn't just about the `impl`.
2023-06-02 18:12:45 +02:00
Alex Macleod
e29a68113f Move redundant_clone to nursery 2023-06-02 15:13:55 +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
Philipp Krones
e6dc0efc00 Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup 2023-06-02 11:41:57 +02: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
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
Centri3
143ff2dfc3 Use type snippet instead of init expr for proc macro check 2023-06-01 22:29:06 -05:00
Centri3
0086b6ab0a don't lint allow_attributes on attributes from proc macros 2023-06-01 20:24:41 -05:00
beetrees
6f13a37499
Add spans to clippy.toml error messages 2023-06-02 00:56:27 +01:00
Centri3
0cc1454db5 Fix #10498 2023-06-01 18:13:01 -05:00
Centri3
eed466281c ignore Foo::deref altogether 2023-06-01 14:29:56 -05: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
MarcusGrass
62eb4e7d7b
Bring up Rust lang #37612 as a known problem for let_and_return 2023-06-01 16:10:57 +02:00
MarcusGrass
b2c85b31bb
Move bail into lint to prevent no-linting, move to unfixable 2023-06-01 16:02:42 +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
Deadbeef
c11573d78c Rename impl_defaultness to defaultness 2023-06-01 06:14:06 +00:00
Centri3
8188da3614 Fix suggestion on fully qualified syntax 2023-05-31 23:33:30 -05:00
Centri3
95e8c0b35a don't allocate the names 2023-05-31 17:30:23 -05:00
Centri3
80ae1ec12d unidiomatic if_chain! 2023-05-31 17:30:23 -05:00
Centri3
04b7cae37e refine output 2023-05-31 17:30:23 -05:00
Catherine
48d36a7aa3 weird grammar 2023-05-31 17:30:23 -05:00
Centri3
97a0ccc1d3 implement host_endian_bytes and the other two 2023-05-31 17:30:23 -05:00
Centri3
3ab6aeefb1 to_xx_bytes implemented, from_xx_bytes todo
Mentioned in #10765
2023-05-31 17:30:23 -05: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
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
de1f410018 merge explicit_into_iter_fn_arg into useless_conversion 2023-05-30 22:32:26 +02: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
Nilstrieb
a3ff2b92e6 Rollup merge of #112060 - lcnr:early-binder, r=jackh726
`EarlyBinder::new` -> `EarlyBinder::bind`

for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR.

r? `@jackh726` `@kylematsuda`
2023-05-30 12:57:40 +02:00
Nilstrieb
faf2e5db0c Rollup merge of #111543 - Urgau:uplift_invalid_utf8_in_unchecked, r=WaffleLapkin
Uplift `clippy::invalid_utf8_in_unchecked` lint

This PR aims at uplifting the `clippy::invalid_utf8_in_unchecked` lint into two lints.

## `invalid_from_utf8_unchecked`

(deny-by-default)

The `invalid_from_utf8_unchecked` lint checks for calls to `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut` with an invalid UTF-8 literal.

### Example

```rust
unsafe {
    std::str::from_utf8_unchecked(b"cl\x82ippy");
}
```

### Explanation

Creating such a `str` would result in undefined behavior as per documentation for `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut`.

## `invalid_from_utf8`

(warn-by-default)

The `invalid_from_utf8` lint checks for calls to `std::str::from_utf8` and `std::str::from_utf8_mut` with an invalid UTF-8 literal.

### Example

```rust
std::str::from_utf8(b"ru\x82st");
```

### Explanation

Trying to create such a `str` would always return an error as per documentation for `std::str::from_utf8` and `std::str::from_utf8_mut`.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

````@rustbot```` label: +I-lang-nominated
r? compiler

-----

For Clippy:

changelog: Moves: Uplifted `clippy::invalid_utf8_in_unchecked` into rustc
2023-05-30 12:57:38 +02:00
disco07
d3534a6521 fix issues 10836 2023-05-30 07:43:10 +02:00
bors
423f081089 Auto merge of #10824 - klensy:url-no-serde, r=giraffate
deps: drop serde feature from url, drop rustc-workspace-hack

Cargo now have it's own workspace and rustc dropped [`rustc-workspace-hack`](https://github.com/rust-lang/rust/pull/109133), so no need to unify features here; drop rustc-workspace-hack.

changelog: none
2023-05-30 00:16:46 +00:00
lcnr
739530a03c EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
Nicholas Nethercote
53f1e6b7ef Use Cow in {D,Subd}iagnosticMessage.
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment:
```
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?
```
This commit answers that question in the affirmative. It's not the most
compelling change ever, but it might be worth merging.

This requires changing the `impl<'a> From<&'a str>` impls to `impl
From<&'static str>`, which involves a bunch of knock-on changes that
require/result in call sites being a little more precise about exactly
what kind of string they use to create errors, and not just `&str`. This
will result in fewer unnecessary allocations, though this will not have
any notable perf effects given that these are error paths.

Note that I was lazy within Clippy, using `to_string` in a few places to
preserve the existing string imprecision. I could have used `impl
Into<{D,Subd}iagnosticMessage>` in various places as is done in the
compiler, but that would have required changes to *many* call sites
(mostly changing `&format("...")` to `format!("...")`) which didn't seem
worthwhile.
2023-05-29 09:23:43 +10:00
xFrednet
c5b974b55d
Update version attribute for 1.70 lints 2023-05-29 00:46:29 +02:00
Alex Macleod
c10876e6c5 from_over_into: Show suggestions for non-Self expanded paths 2023-05-28 21:50:08 +00:00
Kyle Matsuda
a37852e54b Make EarlyBinder's inner value private; and fix all of the resulting errors 2023-05-28 10:44:53 -06:00
Kyle Matsuda
cfcb7fc859 Replace EarlyBinder(x) with EarlyBinder::new(x) 2023-05-28 10:44:50 -06:00
Renato Lochetti
ffc2bc83b0
Fixing invalid_regex with invalid UTF8. Also, adding more test cases 2023-05-28 12:53:03 +01:00
bors
dc17e7317b Auto merge of #10797 - est31:manual_let_else_pattern, r=llogiq
Improve pattern printing for manual_let_else

* Address a formatting issue pointed out in https://github.com/rust-lang/rust-clippy/pull/10175/files#r1137091002
* Replace variables inside | patterns in the if let: `let v = if let V::A(v) | V::B(v) = v { v } else ...`
* Support nested patterns: `let v = if let Ok(Ok(Ok(v))) = v { v } else ...`
* Support tuple structs with more than one arg: `let v = V::W(v, _) = v { v } else ...`; note that more than one *capture* is still not supported, so it bails for `let (v, w) = if let E::F(vi, wi) = x { (vi, wi)}`
* Correctly handle .. in tuple struct patterns: `let v = V::X(v, ..) = v { v } else ...`

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

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

---

changelog: [`manual_let_else`]: improve variable name in suggestions

Closes #10431 as this PR is adding a test for the `mut` case.
2023-05-27 10:22:40 +00:00
bors
c9ddcf0d06 Auto merge of #10822 - Alexendoo:needless-else-cfg, r=llogiq
Ignore `#[cfg]`'d out code in `needless_else`

changelog: none (same release as #10810)

`#[cfg]` making things fun once more

This lead me to think about macro calls that expand to nothing as well, but apparently they produce an empty stmt in the AST so are already handled, added a test for that

r? `@llogiq`
2023-05-27 10:09:51 +00:00
Urgau
5a2094319b Drop uplifted clippy::invalid_utf8_in_unchecked 2023-05-27 00:16:47 +02:00
bors
f1fd4673bc Auto merge of #10813 - y21:issue10755, r=xFrednet
[`default_constructed_unit_structs`]: do not lint on type alias paths

Fixes #10755.

Type aliases cannot be used as a constructor, so this lint should not trigger in those cases.
I also changed `clippy_utils::is_ty_alias` to also consider associated types since [they kinda are type aliases too](48ec50ae39/compiler/rustc_resolve/src/late/diagnostics.rs (L1520)).

changelog: [`default_constructed_unit_structs`]: do not lint on type alias paths
2023-05-26 15:20:21 +00:00
disco07
0b507c6f04
redundant pattern matches! result 2023-05-26 15:38:38 +02:00
bors
05740adf6e Auto merge of #10807 - y21:issue10800, r=Jarcho
[`unused_async`]: do not consider `await` in nested `async` blocks as used

Fixes #10800.
This PR makes sure that `await` expressions inside of inner `async` blocks don't prevent the lint from triggering.
For example
```rs
async fn foo() {
  async {
    std::future::ready(()).await;
  }
}
```
Even though there *is* a `.await` expression in this function, it's contained in an async block, which means that the enclosing function doesn't need to be `async` too.

changelog: [`unused_async`]: do not consider `await` in nested `async` blocks as used
2023-05-26 00:30:24 +00:00
klensy
609f36f11f deps: drop serde feature from url 2023-05-25 13:03:17 +03:00