Commit graph

10289 commits

Author SHA1 Message Date
Michael Goulet
56794fa5f1 Fix clippy 2023-10-04 21:09:54 +00:00
y21
e6f29f1900 dogfood 2023-10-04 18:08:30 +02:00
y21
31fd282732 [get_first]: lint on non-primitive types 2023-10-04 18:07:54 +02:00
Ikko Eltociear Ashimine
faacd55741 Fix typo in attrs.rs
documenation -> documentation
2023-10-05 00:03:04 +09:00
xFrednet
eab0a75ff9
Update version attribute for 1.73 lints 2023-10-04 01:08:45 +02:00
bors
b437069f59 Auto merge of #11603 - koka831:fix/11599, r=y21
Fix: avoid changing drop order

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

changelog: [`redundant_locals`] No longer lints which implements Drop trait to avoid reordering
2023-10-03 15:49:28 +00:00
koka
c7152679ef
Apply review suggestions from @y21 2023-10-04 00:13:53 +09:00
koka
1a56f90ee5
Fix: avoid changing drop order 2023-10-03 21:28:01 +09:00
koka
e465264d47
Avoid invoking ignored_unit_patterns in macro definition 2023-10-03 20:36:35 +09:00
bors
81400e2db8 Auto merge of #11589 - koka831:fix/10198, r=giraffate
std_instead_of_core: avoid lint inside of proc-macro

- fixes https://github.com/rust-lang/rust-clippy/issues/10198

note: The lint for the reported `thiserror::Error` has been suppressed by [Don't lint unstable moves in std_instead_of_core](https://github.com/rust-lang/rust-clippy/pull/9545/files#diff-2cb8a24429cf9d9898de901450d640115503a10454d692dddc6a073a299fbb7eR29) because `thiserror::Error`  internally implements `std::error::Error for (derived struct)`.

changelog: [`std_intead_of_core`]: avoid linting inside proc-macro

I confirmed this change fixes the problem:
<details>
<summary>test result without the change</summary>

```console
error: used import from `std` instead of `core`
  --> tests/ui/std_instead_of_core.rs:65:14
   |
LL |     #[derive(ImplStructWithStdDisplay)]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the derive macro `ImplStructWithStdDisplay` (in Nightly builds, run with -Z macro-backtrace for more info)
```
</details>
2023-10-03 01:26:29 +00:00
bors
08c429f241 Auto merge of #11596 - blyxyas:fix-fp-needless_pass_by_ref_mut, r=Jarcho
Move `needless_pass_by_ref_mut`: `suspicious` -> `nursery`

[Related to [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/needless_pass_by_ref_mut.20isn't.20ready.20for.20stable)]

`needless_pass_by_ref_mut` has been released with some important bugs (notably having a lot of reported false positives and an ICE). So it may not be really ready for being in stable until these problems are solved. This PR changes the lint's category from `suspicious` to `nursery`, just that.
changelog: none
2023-10-02 18:40:32 +00:00
blyxyas
3f0da4dda2
Move needless_pass_by_ref_mut: suspicious -> nursery 2023-10-02 13:28:45 +02:00
bors
331d01e2bf Auto merge of #11265 - Alexendoo:print-literal-unicode-escapes, r=llogiq
Don't escape unicode escape braces in `print_literal`

Fixes #11264

changelog: none
2023-10-01 22:17:18 +00:00
Alex Macleod
258b9a8562 Don't escape unicode escape braces in print_literal 2023-10-01 21:43:09 +00:00
bors
aee3daf90b Auto merge of #11593 - koka831:fix/10511, r=xFrednet
Use Span#from_expansion instead of in_external_macro

- fixes #10511

I checked [the reported repository](https://github.com/rust-lang/rust-clippy/issues/10511#issuecomment-1474271205) and found that clippy hangs at [py_sync.rs#L85](842094068e/crates/python/src/py_sync.rs (L85)), where a macro(`py_function_sync_async`) defines type parameters. this macro is used in the same crate, so `in_external_macro` wouldn't catch them.

This PR fixes the problem by using `Span#from_expansion`.

---

changelog: ICE: [`implicit_hasher`]: No longer lints inside macros, which could cause ICEs
[#11593](https://github.com/rust-lang/rust-clippy/pull/11593)
2023-10-01 16:33:04 +00:00
koka
6f1a78ffa8
Use Span#from_expansion instead of in_external_macro 2023-10-02 00:38:01 +09:00
Victor Song
9dfd60cf4f Remove extraneous #[non_exhaustive] check in lint 2023-10-01 09:54:45 -05:00
bors
3169423ce9 Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum
Partially outline code inside the panic! macro

This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-10-01 05:56:47 +00:00
Victor Song
e683e3eeac Don't lint manual_non_exhaustive when enum explicitly marked as non_exhaustive
There are cases where users create a unit variant for the purposes
of tracking the number of variants for an nonexhaustive enum.
We should check if an enum is explicitly marked as nonexhaustive
before reporting `manual_non_exhaustive` in these cases. Fixes #11583
2023-09-30 22:57:54 -05:00
bors
0e43a04fab Auto merge of #11587 - y21:into_iter_without_iter, r=Jarcho
new lint: `into_iter_without_iter`

Closes #9736 (part 2)

This implements the other lint that my earlier PR missed: given an `IntoIterator for &Type` impl, check that there exists an inherent `fn iter(&self)` method.

changelog: new lint: `into_iter_without_iter`

r? `@Jarcho` since you reviewed #11527 I figured it makes sense for you to review this as well?
2023-09-30 18:43:37 +00:00
y21
8eb586d154 new lint: into_iter_without_iter 2023-09-30 19:38:16 +02:00
koka
44b6aca96b
Avoid linting in external/proc macro 2023-09-30 23:56:11 +09:00
bors
b00236d7f0 Auto merge of #11580 - y21:issue11579, r=Jarcho
[`manual_let_else`]: only omit block if span is from same ctxt

Fixes #11579.

The lint already had logic for omitting a block in `else` if a block is already present, however this didn't handle the case where the block is from a different expansion/syntax context. E.g.
```rs
macro_rules! panic_in_block {
  () => { { panic!() } }
}

let _ = match Some(1) {
  Some(v) => v,
  _ => panic_in_block!()
};
```
It would see this in its expanded form as `_ => { panic!() }` and think it doesn't have to include a block in its suggestion because it is already there, however that's not true if it's from a different expansion like in this case.

changelog: [`manual_let_else`]: only omit block in suggestion if the block is from the same expansion
2023-09-29 18:49:57 +00:00
y21
2d2017942a [manual_let_else]: only omit block if span is from same ctxt 2023-09-29 16:54:50 +02:00
bors
67a83ff057 Auto merge of #11582 - DaniPopes:missing-headers, r=xFrednet
Add missing lint description headers

Discovered in https://github.com/rust-lang/rust-analyzer/pull/15680/files#diff-7cb229b5139c72b6c230e3c195be375724c92226421fd57d5cf08872503e8c27L214-R226

changelog: none
2023-09-29 09:09:52 +00:00
Matthias Krüger
1a82ca0a61 Rollup merge of #116245 - flip1995:clippy-backport, r=Manishearth
Clippy backport: Move needless_raw_string_hashes to pedantic

Really small backport this time. Context: https://github.com/rust-lang/rust-clippy/pull/11415#issuecomment-1739880932

I'd rather get this in 1.74 than waiting another release cycle.

r? `@Manishearth`

cc `@Mark-Simulacrum` This should be merged before beta is branched tomorrow.
2023-09-29 10:11:14 +02:00
DaniPopes
ad5653b296
Add missing lint description headers 2023-09-29 03:08:34 +02:00
DaniPopes
38fd80a112 Remove rustc_lint_defs::lint_array 2023-09-28 23:01:25 +02:00
y21
330ebbb9f9 new lint: iter_without_into_iter 2023-09-28 22:22:36 +02:00
Alex Macleod
82207f4ff4 Move needless_raw_string_hashes to pedantic 2023-09-28 21:24:42 +02:00
bors
91997a4df4 Auto merge of #11565 - RalfJung:mir_to_const, r=Jarcho
mir_to_const improvements

This simplifies some code and also fixes the float array handling to properly take into account the `offset`, and to work with little-endian targets.

Fixes https://github.com/rust-lang/rust-clippy/issues/11488
changelog: none
2023-09-28 17:59:05 +00:00
bors
d18d01a8b1 Auto merge of #11576 - koka831:fix/10128, r=llogiq
write_literal: Fix index of the remaining positional arguments

- fixes https://github.com/rust-lang/rust-clippy/issues/10128
- `clippy --fix` replaces multiple warnings at once
   e.g.)
   ```rust
   writeln!(v, "{0} {1}", "hello", "world");
   // before: `writeln!(v, "hello {1}", "world");`
   // now: `writeln!(v, "hello world");`
   ```

changelog: [`print_literal`], [`write_literal`]: Now handles positional argument properly
2023-09-28 13:40:05 +00:00
bors
29ed6fa119 Auto merge of #11415 - Alexendoo:needless-raw-string-hashes-pedantic, r=flip1995
Move `needless_raw_string_hashes` to `pedantic`

IMO it doesn't improve code enough to be warn by default. [It seems to be unclear to some also](https://github.com/rust-lang/rust-clippy/issues/11402), but that can probably be remedied separately

changelog: Moved [`needless_raw_string_hashes`] to `pedantic` (Now allow-by-default)
[#11415](https://github.com/rust-lang/rust-clippy/pull/11415)

r? `@flip1995`
2023-09-28 10:34:33 +00:00
koka
b413bf6c4e
Fix index of the remaining positional arguments 2023-09-28 17:34:02 +09:00
unexge
62b8ef304a Mention that missing_assert_message lint ignores test functions 2023-09-27 22:06:01 +01:00
bors
3b75db7aa6 Auto merge of #116163 - compiler-errors:lazyness, r=oli-obk
Don't store lazyness in `DefKind::TyAlias`

1. Don't store lazyness of a type alias in its `DefKind`, but instead via a query.
2. This allows us to treat type aliases as lazy if `#[feature(lazy_type_alias)]` *OR* if the alias contains a TAIT, rather than having checks for both in separate parts of the codebase.

r? `@oli-obk` cc `@fmease`
2023-09-27 01:48:53 +00:00
bors
7f132e8e3a Auto merge of #116144 - lcnr:subst-less, r=oli-obk
subst -> instantiate

continues #110793, there are still quite a few uses of `subst` and `substitute`, but changing them all in the same PR was a bit too much, so I've stopped here for now.
2023-09-26 21:32:44 +00:00
bors
4494b6947f Auto merge of #11569 - Alexendoo:needless-raw-string-descr, r=llogiq
Describe the type of string in raw_strings lints

changelog: none
2023-09-26 21:16:33 +00:00
Alex Macleod
ec2f62677f Add manual_hash_one lint 2023-09-26 13:49:15 +00:00
Alex Macleod
6cdff10778 Describe the type of string in raw_strings lints 2023-09-26 11:49:44 +00:00
lcnr
f2efdba6e2 subst -> instantiate 2023-09-26 09:37:55 +02:00
koka
fab90003b8
Do not lint when imported item contains underscore 2023-09-26 12:58:48 +09:00
Michael Goulet
55074827b5 Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
Ralf Jung
84d6894f26 it's not Miri but MIR constants 2023-09-25 16:19:02 +02:00
Alex Macleod
1972cc89c4 Test that each config value exists in a test clippy.toml 2023-09-25 12:38:23 +00:00
Philipp Krones
772296c50e Merge commit '7671c283a50b5d1168841f3014b14000f01dd204' into clippyup 2023-09-25 11:28:58 +02:00
Philipp Krones
903add0c11
Fix dogfood fallout 2023-09-25 10:31:51 +02:00
Philipp Krones
81fe8dc084
Merge remote-tracking branch 'upstream/master' into rustup 2023-09-25 10:26:11 +02:00
bors
aa137a7e57 Auto merge of #11552 - jonboh:ice_threshold_0_enum_variants, r=y21
prevent ice when threshold is 0 and enum has no variants

changelog: [`enum_variant_names`]: prevent ice when threshold is 0 and enum has no variants

r? `@y21`

Fixes the same ice issue raised during review of https://github.com/rust-lang/rust-clippy/pull/11496
2023-09-24 20:58:58 +00:00
Jon
0433e458da
use first instead of get(0)
Co-authored-by: Timo <30553356+y21@users.noreply.github.com>
2023-09-24 21:37:56 +02:00
Camille GILLOT
e2669b27f3 Remove GeneratorWitness and rename GeneratorWitnessMIR. 2023-09-23 13:47:30 +00:00
Camille GILLOT
0a2d39de2e Enable drop_tracking_mir by default. 2023-09-23 13:34:09 +00:00
bors
d732cce0d3 Auto merge of #11553 - mickvangelderen:fix-large-futures-example, r=xFrednet
Fix large_futures example

The value used in the large_futures example was not large enough to trigger the lint given the default threshold. The example also contained more code than necessary. This PR changes the value size from 1kB to 16kB and reduces the example in size.

changelog: [`large_futures`]: Fix and simplify example
2023-09-22 21:19:28 +00:00
bors
50139e6ad2 Auto merge of #11551 - Meczka:fix-fp-needless-pass-by-ref-mut, r=xFrednet
fixed fp caused by moving &mut reference inside of a closure

changelog: [`needless_pass_by_ref mut`]: fixes false positive caused by not covering mutable references passed to a closure inside of a fuction
fixes #11545
2023-09-22 21:07:46 +00:00
Mick van Gelderen
7e46fb9a65
Fix large_futures example
The value used in the large_futures example was not large enough to
trigger the lint given the default threshold.

The example also contained more code than necessary.

This PR changes the value size from 1kB to 16kB and reduces the example
in size.
2023-09-22 19:41:00 +02:00
jonboh
f3a27d20f6 prevent ice when threshold is 0 and enum has no variants 2023-09-22 17:18:49 +02:00
pc-linux
85801f55ef fixed fp caused by moving &mut reference inside of a closure 2023-09-22 16:54:21 +02:00
Michael Goulet
823bcb478b Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
bors
33f084ef78 Auto merge of #11544 - Alexendoo:hir-ty-to-ty, r=Jarcho
Remove most usage of `hir_ty_to_ty`

Removes the usages where there's a suitable query or the type was already available elsewhere. The remaining cases would all require more involved changes

changelog: none

r? `@Jarcho`
2023-09-21 15:25:36 +00:00
bors
4d143d7e16 Auto merge of #11518 - mojave2:issue-11420, r=Alexendoo
fix FP with needless_raw_string_hashes

changelog: Fix [`needless_raw_string_hashes`]: Continue the lint checking of raw string when `needless_raw_strings` is allowed.

fix #11420
2023-09-21 12:27:24 +00:00
Guillaume Gomez
12815e95f9 Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obk
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const

Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`.

Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all.

However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish...

``@oli-obk`` any ideas?
2023-09-21 13:25:39 +02:00
Oli Scherer
238dc2828e Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Ralf Jung
2ea6ac5673 rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
bors
c55669513a Auto merge of #11522 - y21:redundant_guards_pat_lhs, r=giraffate
[`redundant_guards`]: lint if the pattern is on the left side

A tiny improvement to the `redundant_guards` lint. There's no associated issue for this, just noticed it while going through the code.
Right now it warns on `Some(x) if x == 2` and suggests `Some(2)`, but it didn't do that for `Some(x) if 2 == x` (i.e. when the local is on the right side and the pattern on the left side).

changelog: [`redundant_guards`]: also lint if the pattern is on the left side
2023-09-20 23:57:25 +00:00
Alex Macleod
01c25a8eb6 Remove most usage of hir_ty_to_ty 2023-09-20 14:05:00 +00:00
Taiki Endo
77c121e817 Warn missing_enforced_import_renames by default 2023-09-20 19:05:51 +09:00
bors
ddbe110081 Auto merge of #11170 - tgross35:undocumented-unsafe-blocks-defaults, r=Centri3
Change defaults of `accept-comment-above-statement` and `accept-comment-above-attributes`

This patch sets the two configuration options for `undocumented_unsafe_blocks` to `true` by default: these are `accept-comment-above-statement` and `accept-comment-above-attributes`. Having these values `false` by default prevents what many users would consider clean code, e.g. placing the `// SAFETY:` comment above a single-line functino call, rather than directly next to the argument.

This was originally discussed in https://github.com/rust-lang/rust-clippy/issues/11162

changelog: [`undocumented_unsafe_blocks`]: set
`accept-comment-above-statement` and `accept-comment-above-attributes` to `true` by default.
2023-09-20 08:06:54 +00:00
bors
ece3878c8c Auto merge of #11492 - GuillaumeGomez:async-fn-returned-closure, r=Centri3
Fix mutaby used async function argument in closure for `needless_pass_by_ref_mut`

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

The problem was that it needed to go through closures as well in async functions to correctly find the mutable usage of async function arguments.

changelog: Correctly handle mutable usage of async function arguments in closures.

r? `@Centri3`
2023-09-20 07:48:54 +00:00
Trevor Gross
1b3e5dd0fc Change default configuration of undocumented_unsafe_blocks
This patch sets the two configuration options for
`undocumented_unsafe_blocks` to `true` by default: these are
`accept-comment-above-statement` and `accept-comment-above-attributes`.
Having these values `false` by default prevents what many users would
consider clean code, e.g. placing the `// SAFETY:` comment above a
single-line functino call, rather than directly next to the argument.

changelog: [`undocumented_unsafe_blocks`]: set
`accept-comment-above-statement` and `accept-comment-above-attributes`
to `true` by default.
2023-09-20 03:41:33 -04:00
bors
f464149b8f Auto merge of #11516 - mojave2:issue-11458, r=giraffate
fix cast_lossless with macro call

changelog: fix [`cast_lossless`] in the case when the cast operand is a macro call

fix #11458
2023-09-20 00:00:06 +00:00
bors
889e1b99bd Auto merge of #11530 - Alexendoo:zero-ptr-file-location, r=blyxyas
Move zero_ptr to the casts module

Also a bit of a touch up to the code while I was there

changelog: none
2023-09-18 22:19:59 +00:00
bors
5cba09c576 Auto merge of #11526 - Dev380:redundant-as-str, r=Manishearth
Add redundant_as_str lint

This lint checks for `as_str` on a `String` immediately followed by `as_bytes` or `is_empty` as those methods are available on `String` too. This could possibly also be extended to `&[u8]` in the future.

changelog: New lint [`redundant_as_str`] #11526
2023-09-18 21:31:48 +00:00
bors
e9dc753b7b Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function

This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants.

Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized.

I didn't expect this to change diagnostics, but it's just cycle errors that change.

r? `@oli-obk`
2023-09-18 19:41:21 +00:00
bors
4022591cfd Auto merge of #11517 - mojave2:issue-11426, r=Alexendoo
fix ICE by `u64::try_from(<u128>)`

changelog: Fix the ICE in [`cast_possible_truncation`], when the `Shr` bits is larger than `u64::MAX`

fix #11426
2023-09-18 14:21:48 +00:00
Guillaume Gomez
b8b420cc79 Improve code readability by moving the retrieval of closures inside async functions right besides other closures handling.
Add doc comment explaining what `MutablyUsedVariablesCtxt::prev_move_to_closure` is about.
2023-09-18 15:47:24 +02:00
Alex Macleod
b06b915dc0 Move zero_ptr to the casts module 2023-09-18 12:15:51 +00:00
Dev381
01056c5aae Fix missing semicolon in redundant_as_str docstring example 2023-09-17 18:10:21 -04:00
Dev381
1c9f3bef8b Add redundant_as_str lint
This lint checks for `as_str` on a `String` immediately followed by `as_bytes` or `is_empty` as those methods are available on `String` too. This could possibly also be extended to `&[u8]` in the future.
2023-09-17 17:50:45 -04:00
Alex Macleod
32d3387c80 used_underscore_bindings: respect lint levels on the binding definition 2023-09-17 20:40:51 +00:00
bors
251a475b72 Auto merge of #11511 - Jarcho:split_borrow, r=llogiq
Split `needless_borrow` into two lints

Splits off the case where the borrow is used as a generic argument to a function. I think the two cases are different  enough to warrant a separate lint.

The tests for the new lint have been reordered to group related parts together. Two warning have been dropped, one looked like it was testing the generic argument form, but it ends up triggering the auto-deref variant. The second was just a redundant test that didn't do anything interesting.

An issue with cycle detection is also included. The old version was checking if a cycle was reachable from a block when it should have been checking if the block is part or a cycle.

As a side note, I'm liking the style of just jamming all the tests into separate scopes in main.

changelog: Split off `needless_borrows_for_generic_args` from `needless_borrow`
2023-09-17 13:48:40 +00:00
Jason Newcomb
79247d95f7 Split part of needless_borrow into needless_borrows_for_generic_args 2023-09-17 09:48:12 -04:00
y21
558ae4c6a8 [redundant_guards]: lint if the pattern is on the LHS 2023-09-17 15:34:32 +02:00
mojave2
3665a4102b
fix ICE by u64::try_from(<u128>) 2023-09-17 19:44:25 +08:00
bors
7b5e0199da Auto merge of #11515 - y21:filter_map_bool_then_peel_refs, r=Jarcho
[`filter_map_bool_then`]: include multiple derefs from adjustments

In #11506 this lint was improved to suggest one deref if the bool is behind references (fixed the FP #11503), however it might need multiple dereferences if the bool is behind multiple layers of references or custom derefs. E.g. `&&&bool` needs `***b`.

changelog: [`filter_map_bool_then`]: suggest as many dereferences as there are needed to get to the bool
2023-09-17 06:37:45 +00:00
mojave2
5b790ff9e0
fix FP with needless_raw_string_hashes 2023-09-17 12:54:00 +08:00
bors
ef736489e7 Auto merge of #11468 - mojave2:issue-11465, r=blyxyas
add extra `byref` checking for the guard's local

changelog: [`redundant_guards`]: Now checks if the variable is bound using `ref` before linting.

The lint should not be emitted, when the local variable is bind by-ref in the pattern.

fixes #11465
2023-09-16 22:02:10 +00:00
Chen Chen
3cad623716
更新 cast_lossless.rs
Co-authored-by: Timo <30553356+y21@users.noreply.github.com>
2023-09-17 02:42:12 +08:00
mojave2
af2a8478ba
fix cast_lossless with macro call 2023-09-16 23:17:47 +08:00
Chen Chen
67f0ba4af8
Update clippy_lints/src/matches/redundant_guards.rs
fix typo

Co-authored-by: Alejandra González <blyxyas@gmail.com>
2023-09-16 22:12:40 +08:00
y21
2ec6f3b1ed also count derefs through custom Deref impls 2023-09-16 15:13:44 +02:00
y21
860e800fa0 [filter_map_bool_then]: peel as many refs as needed 2023-09-16 14:14:51 +02:00
bors
f54275f20f Auto merge of #11509 - mojave2:issue-11502, r=llogiq
fix FP of let_unit_value on async fn args

changelog: [`let_unit_value`]: fix the FalsePostive on async fn arguments

fix #11502
2023-09-16 10:22:33 +00:00
bors
3f9db9025d Auto merge of #11507 - J-ZhengLi:issue11485, r=dswij
trigger [`transmute_null_to_fn`] on chain of casts

fixes: #11485

changelog: trigger [`transmute_null_to_fn`] on chain of casts
2023-09-16 06:19:09 +00:00
bors
59636a2aa3 Auto merge of #11301 - y21:issue11300, r=dswij
[`useless_conversion`]: don't lint if type parameter has unsatisfiable bounds for `.into_iter()` receiver

Fixes #11300.

Before this PR, clippy assumed that if it sees a `f(x.into_iter())` call and the type at that argument position is generic over any `IntoIterator`, then the `.into_iter()` call must be useless because `x` already implements `IntoIterator`, *however* this assumption is not right if the generic parameter has more than just the `IntoIterator` bound (because other traits can be implemented for the IntoIterator target type but not the IntoIterator implementor, as can be seen in the linked issue: `<[i32; 3] as IntoIterator>::IntoIter` satisfies `ExactSizeIterator`, but `[i32; 3]` does not).

So, this PR makes it check that the type parameter only has a single `IntoIterator` bound. It *might* be possible to check if the type of `x` in `f(x.into_iter())` satisfies all the bounds on the generic type parameter as defined on the function (which would allow removing the `.into_iter()` call even with multiple bounds), however I'm not sure how to do that, and the current fix should always work.

**Edit:** This PR has been changed to check if any of the bounds don't hold for the type of the `.into_iter()` receiver, so we can still lint in some cases.

changelog: [`useless_conversion`]: don't lint `.into_iter()` if type parameter has multiple bounds
2023-09-16 06:04:59 +00:00
Jason Newcomb
fed036a57c Fix cycle detection in needless_borrow 2023-09-15 19:13:34 -04:00
y21
981e96008b new lint: path_ends_with_ext 2023-09-15 16:17:51 +02:00
bors
eaf640dcf0 Auto merge of #11506 - mojave2:issue-11503, r=giraffate
fix filter_map_bool_then with a bool reference

changelog: [`filter_map_bool_then`]: Fix the incorrect autofix when the `bool` in question is a reference.

fix #11503
2023-09-15 13:13:16 +00:00
bors
e609279b2c Auto merge of #11484 - mkrasnitski:fix-11302, r=Jarcho
[`extra_unused_type_parameters`]: Fix edge case FP for parameters in where bounds

Generic parameters can end up being used on the left side of where-bounds if they are not directly bound but instead appear nested in some concrete generic type. Therefore, we should walk the left side of where bounds, but only if the bounded type is *not* a generic param, in which case we still need to ignore the bound.

Fixes #11302

changelog: [`extra_unused_type_parameters`]: Fix edge case false positive for parameters in where bounds
2023-09-15 12:59:15 +00:00
bors
21216297e9 Auto merge of #115851 - Alexendoo:clippy-doc-hidden-headers, r=flip1995
Ignore `#[doc(hidden)]` functions in clippy doc lints

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

The implementation before #115689 had a check for unsugared doc comments that also happened to catch `#[doc(hidden)]`, this adds the check back in more explicitly

852bf4e51b/src/tools/clippy/clippy_lints/src/doc.rs (L526-L529)

r? `@flip1995`
2023-09-15 09:55:31 +00:00
bors
2c629cc137 Auto merge of #11504 - Alexendoo:type-lints-closures, r=xFrednet
Ignore closures for some type lints

Fixes #11417

`hir_ty_to_ty` is used in a couple of the `!is_local` lints, which doesn't play nicely inside bodies

changelog: none
2023-09-15 09:34:13 +00:00