Commit graph

20122 commits

Author SHA1 Message Date
bors
1e407642e8 Auto merge of #12901 - J-ZhengLi:test_case, r=Manishearth
[`match_same_arms`]: add a test case with lifetimes

as reminded by: #8919

---

changelog: none
2024-06-07 16:38:38 +00:00
J-ZhengLi
1781333ec7 [match_same_arms]: add a test case with lifetimes 2024-06-08 00:06:20 +08:00
Alex Macleod
65af5d7b22 Remove lazy_static mention 2024-06-07 12:51:37 +00:00
Alex Macleod
b21ee38fa9 Don't lint blocks in closures for blocks_in_conditions 2024-06-07 11:21:38 +00:00
bors
336046c5e2 Auto merge of #12889 - xFrednet:changelog-1-79, r=flip1995,dswij
Changelog for Clippy 1.79 🎓

Two cat ears from waffle,
A tail and a dress,
That's our Jyn,
The magnificent cat

~ =^.^=

---

### The cat of this release is: *Jyn* submitted by `@jyn514:`

<img height=600 src="https://github.com/rust-lang/rust-clippy/assets/17087237/2f902dea-9ad5-4ad2-b281-1f152b7ad7c7" alt="The cat(s) of this Clippy release" />

Cats for the next release can be nominated in the comments :D

---

changelog: none
2024-06-07 10:02:32 +00:00
bors
f990ea155e Auto merge of #12844 - Alexendoo:to-string-in-format-args, r=dswij
Fix `to_string_in_format_args` with macro call receiver

Fixes part of #12837

changelog: none
2024-06-07 09:52:17 +00:00
bors
0f87a81882 Auto merge of #12822 - Alexendoo:for-each-expr, r=dswij
Make `for_each_expr` visit closures by default, rename the old version `for_each_expr_without_closures`

A lot of the time `for_each_expr` is picked when closures should be visited so I think it makes sense for this to be the default with the alternative available for when you don't need to visit them.

The first commit renames `for_each_expr` to `for_each_expr_without_closures` and `for_each_expr_with_closures` to `for_each_expr`

The second commit switches a few uses that I caught over to include closures to fix a few bugs

changelog: none
2024-06-07 09:42:37 +00:00
bors
0b441d5ac5 Auto merge of #12877 - y21:const_host_ice, r=dswij
Handle const effects inherited from parent correctly in `type_certainty`

This fixes a (debug) ICE in `type_certainty` that happened in the [k256 crate]. (I'm sure you can also specifically construct an edge test case that will run into type_certainty false positives visible outside of debug builds from this bug)

<details>
<summary>Minimal ICE repro</summary>

```rs
use std::ops::Add;
Add::add(1_i32, 1).add(i32::MIN);
```
</details>

The subtraction here overflowed:
436675b477/clippy_utils/src/ty/type_certainty/mod.rs (L209)

... when we have something like `Add::add` where `add` fn has 0 generic params but the `host_effect_index` is `Some(2)` (inherited from the parent generics, the const trait `Add`), and we end up executing `0 - 1`.

(Even if the own generics weren't empty and we didn't overflow, this would still be wrong because it would assume that a trait method with 1 generic parameter didn't have any generics).

So, *only* exclude the "host" generic parameter if it's actually bound by the own generics

changelog: none

[k256 crate]: https://github.com/RustCrypto/elliptic-curves/tree/master/k256
2024-06-07 09:33:48 +00:00
bors
d9ae9367ba Auto merge of #12897 - lochetti:manual_unwrap_or_default_result, r=dswij
Lint `manual_unwrap_or_default` for Result as well

This PR is modifying the  `manual_unwrap_or_default` to be applied/linted for `Result`s as well. It is part of the fixes desired by https://github.com/rust-lang/rust-clippy/issues/12618

changelog:[`manual_unwrap_or_default`]: Lint for Result types.
2024-06-07 09:24:22 +00:00
bors
127f3e18c1 Auto merge of #125918 - oli-obk:const_block_ice, r=compiler-errors
Revert: create const block bodies in typeck via query feeding

as per the discussion in https://github.com/rust-lang/rust/pull/125806#discussion_r1622563948

It was a mistake to try to shoehorn const blocks and some specific anon consts into the same box and feed them during typeck. It turned out not simplifying anything (my hope was that we could feed `type_of` to start avoiding the huge HIR matcher, but that didn't work out), but instead making a few things more fragile.

reverts the const-block-specific parts of https://github.com/rust-lang/rust/pull/124650

`@bors` rollup=never had a small perf impact previously

fixes https://github.com/rust-lang/rust/issues/125846

r? `@compiler-errors`
2024-06-07 09:08:59 +00:00
Oli Scherer
abd011638d Revert "Create const block DefIds in typeck instead of ast lowering"
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-07 08:33:58 +00:00
Jubilee
3e43cfcf24 Rollup merge of #126101 - lqd:revert-124099, r=wesleywiser
Revert "Disallow ambiguous attributes on expressions" on nightly

As discussed in [today's t-compiler meeting](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-06-06/near/443079505), this reverts PR #124099 to fix P-critical beta regressions #125199.

r? ``@wesleywiser``

Opening as draft so that ``@wesleywiser`` and ``@apiraino,`` you can tell me whether you wanted:
1. a `beta-accepted` revert of #124099 on nightly (this PR)? That will need to be backported to beta (even though #126093 may be the last of those)
2. a revert of #124099 on beta?
3. all of the above?

I also opened #126102, another draft PR to revert #124099 on beta, should you choose options 2 or 3.
2024-06-06 21:10:11 -07:00
Slanterns
246d4fe791 bless std_instead_of_core 2024-06-07 08:37:05 +08:00
Renato Lochetti
478d44487e
Allow manual_unwrap_or_default at useless_conversion_try tests 2024-06-06 21:44:06 +01:00
Rémy Rakic
5ea5f6351e Revert "Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, r=davidtwco"
This reverts commit 57dad1d75e562ff73051c1c43b07eaf65c7dbd74, reversing
changes made to 36316df9fe6c3e246153fe6e78967643cf08c148.
2024-06-06 20:39:54 +00:00
Renato Lochetti
5b63ab1131
Lint manual_unwrap_or_default for Result as well 2024-06-06 21:33:37 +01:00
bors
16fcbd21e5 Auto merge of #126068 - lqd:revert-124976, r=petrochenkov
Revert "use `tcx.used_crates(())` more" before it reaches beta

There are more open issues caused by #124976 than will be fixed by #125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time.

fixes https://github.com/rust-lang/rust/issues/125474
fixes https://github.com/rust-lang/rust/issues/125484
fixes https://github.com/rust-lang/rust/issues/125646
fixes https://github.com/rust-lang/rust/issues/125707
fixes #126066
fixes #125934
fixes https://github.com/rust-lang/rust/issues/126021

r? `@petrochenkov`
`@bors` p=1
2024-06-06 20:18:43 +00:00
Samuel Tardieu
35b2aa99f3 Add required parentheses around method receiver 2024-06-06 20:53:08 +02:00
Samuel Tardieu
1e23449678 Move is_receiver_of_method_call to clippy_utils for reuse 2024-06-06 20:09:21 +02:00
bors
4e7f97467a Auto merge of #12827 - Alexendoo:lint-groups-priority, r=Jarcho
`lint_groups_priority`: ignore lints & groups at the same level

Fixes #12270

changelog: none
2024-06-06 12:09:58 +00:00
John Arundel
7c86db4ea5 [ mut_range_bound ]: fix doc nits 2024-06-06 12:45:32 +01:00
John Arundel
8da5d64669 [ allow_attributes_without_reason ]: fix doc nits 2024-06-06 12:45:32 +01:00
John Arundel
35d284fcbf [ allow_attributes ]: fix doc nits 2024-06-06 12:45:32 +01:00
John Arundel
7ab4af336c [ needless_for_each ]: fix doc nits 2024-06-06 12:45:22 +01:00
Rémy Rakic
c245cde61c Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing
changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-06 10:06:28 +00:00
bors
ea13653f6f Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk
Unsafe extern blocks

This implements RFC 3484.

Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484

This is better reviewed commit by commit.
2024-06-06 08:14:58 +00:00
Boxy
38de6e1f3a Misc fixes to cranelift/clippy/miri 2024-06-05 22:25:42 +01:00
bors
6cfd4ac955 Auto merge of #10632 - Alexendoo:needless-maybe-sized, r=Jarcho
Add `needless_maybe_sized` lint

changelog: new lint: [`needless_maybe_sized`]

Closes #10600
2024-06-05 20:11:03 +00:00
bors
d955d0a41f Auto merge of #12891 - paultag:paultag/fix-lint-description, r=Manishearth
Fix grammer for the Safety documentation check

The original message ("unsafe function's docs miss `# Safety` section") reads quite awkwardly. I've changed it to "unsafe function's docs are missing a `# Safety` section" to have it read better.

```
changelog: [`missing_headers`]: Tweak the grammar in the lint message
```
2024-06-05 20:00:59 +00:00
bors
1105e9debe Auto merge of #12700 - Luv-Ray:overly_complex_bool_expr, r=Jarcho
[`overly_complex_bool_expr`]: Fix trigger wrongly on never type

fixes #12689

---

changelog: fix [`overly_complex_bool_expr`] triggers wrongly on never type
2024-06-05 19:47:43 +00:00
bors
bc00d7b94d Auto merge of #12845 - cookie-s:dedup-boolmethods-diags, r=Jarcho
Dedup nonminimal_bool_methods diags

Relates to #12379

Fix `nonminimal_bool` lint so that it doesn't check the same span multiple times.

`NotSimplificationVisitor` was called for each expression from `NonminimalBoolVisitor` whereas `NotSimplificationVisitor` also recursively checked all expressions.

---

changelog: [`nonminimal_bool`]: Fix duplicate diagnostics
2024-06-05 19:09:55 +00:00
Paul R. Tagliamonte
35e2027a35 Fix grammer for the Safety documentation check
The original message ("unsafe function's docs miss `# Safety` section")
reads quite awkwardly. I've changed it to "unsafe function's docs are missing
a `# Safety` section" to have it read better.

Signed-off-by: Paul R. Tagliamonte <paultag@gmail.com>
2024-06-05 14:11:56 -04:00
xFrednet
a0e407c7c2
Address PR feedback <3 2024-06-05 16:26:51 +02:00
bors
10d1f32685 Auto merge of #12886 - GuillaumeGomez:fix-needless_character_iteration, r=blyxyas
Fix false positive for `needless_character_iteration` lint

Fixes #12879.

changelog: Fix false positive for `needless_character_iteration` lint
2024-06-05 13:12:39 +00:00
xFrednet
466acfa650
Changelog for Clippy 1.79 🎓 2024-06-05 14:02:11 +02:00
xFrednet
d47ab9f9c9
Update version attribute for 1.79 lints 2024-06-05 13:51:42 +02:00
Nicholas Nethercote
e8d02fe1cb Make top-level rustc_parse functions fallible.
Currently we have an awkward mix of fallible and infallible functions:
```
       new_parser_from_source_str
 maybe_new_parser_from_source_str
       new_parser_from_file
(maybe_new_parser_from_file)        // missing
      (new_parser_from_source_file) // missing
 maybe_new_parser_from_source_file
       source_str_to_stream
 maybe_source_file_to_stream
```
We could add the two missing functions, but instead this commit removes
of all the infallible ones and renames the fallible ones leaving us with
these which are all fallible:
```
new_parser_from_source_str
new_parser_from_file
new_parser_from_source_file
source_str_to_stream
source_file_to_stream
```
This requires making `unwrap_or_emit_fatal` public so callers of
formerly infallible functions can still work.

This does make some of the call sites slightly more verbose, but I think
it's worth it for the simpler API. Also, there are two `catch_unwind`
calls and one `catch_fatal_errors` call in this diff that become
removable thanks this change. (I will do that in a follow-up PR.)
2024-06-05 10:38:03 +10:00
Guillaume Gomez
158b65889c Fix false positive for needless_character_iteration lint 2024-06-04 21:12:08 +02:00
bors
46e33045f8 Auto merge of #12884 - y21:issue12881, r=Alexendoo
Only run `suboptimal_flops` on inherent method calls

Fixes #12881

`suboptimal_flops` was making the wrong assumption that a `.log()` method call on a float literal must choose the inherent log method that will always have an argument present (in which case `args[0]` indexing would be fine), but that wasn't the case in the linked issue because at the point of the method call, the exact float type hadn't been inferred yet (and method selection can't select inherent methods when the exact float type has not yet been inferred, in which case it falls back to looking for trait impls and chooses the one that didn't have any parameters).

This fixes it by actually making sure it's a call to an inherent method (could also fix the linked ICE by simply using fallibly indexing via `.get()`, but this felt like it'd fix the root cause: even if there were one argument, it would still be wrong to emit a warning there because it's not the `log` method the lint was expecting). I'm not sure if we need that extra function be in `clippy_utils` but it feels like it could be useful.

changelog: Fixes an ICE in [`suboptimal_flops`]
2024-06-04 18:20:40 +00:00
Santiago Pastorino
bd0f908242 Add safe/unsafe to static inside extern blocks 2024-06-04 14:19:43 -03:00
Santiago Pastorino
537ce5c8c6 Handle safety keyword for extern block inner items 2024-06-04 14:19:42 -03:00
Michael Goulet
9f4a2dd147 Align Term methods with GenericArg methods 2024-06-03 20:36:27 -04:00
bors
5d568ad7bd Auto merge of #12885 - lochetti:clippy_proper_noun, r=flip1995
Using Clippy as a proper noun when refering to the unique entity Clippy

I was reading some documentation (specially the book) and I notice some few usages of the word `clippy` when refering to the Project/Tool. As we already have in the majority of the documentation, in those cases, Clippy is a proper noun, and because of that should be used capitalized.

This is, for sure, not an exhaustive change: quite the opposity, it was just some cases that I could verify with not so much effort.

changelog: Docs: capitalizing the `clippy` word in some usages.
2024-06-03 19:56:03 +00:00
Renato Lochetti
9173c58e68
Using Clippy as a proper noun when refering to the unique entity Clippy 2024-06-03 20:46:05 +01:00
y21
708ef7955d only run flop lints on inherent method calls 2024-06-03 21:42:00 +02:00
Michael Goulet
e94779a396 Opt-in diagnostics reporting to avoid doing extra work in the new solver 2024-06-03 09:27:52 -04:00
John Arundel
5e60afb6cc [ arc_with_non_send_sync ]: fix doc nits 2024-06-03 12:33:03 +01:00
bors
4f3180adac Auto merge of #12875 - y21:deprecate_cfg_lints, r=flip1995
Deprecate `maybe_misused_cfg` and `mismatched_target_os`

All cases that these two lints would catch are now caught by cargo/rustc's own check-cfg feature.

This was previously discussed on zulip: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Deprecate.20maybe_misused_cfg.20and.20mismatched_target_os

For the most part, this PR was automated with `cargo dev deprecate`

r? `@flip1995` cc `@Urgau`

changelog: deprecate [`maybe_misused_cfg`] and [`mismatched_target_os`]
2024-06-03 08:57:34 +00:00
bors
61d3e14718 Auto merge of #12815 - GuillaumeGomez:add-needless_character_iteration, r=xFrednet
Add `needless_character_iteration` lint

Fixes #4817.

r? `@xFrednet`

changelog: Add `needless_character_iteration` lint
2024-06-03 08:09:18 +00:00
bors
568f4fc732 Auto merge of #12871 - Jacherr:issue-12768, r=blyxyas
Modify str_to_string to be machine-applicable

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

I'm not sure if there is any potential for edge cases with this - since it only ever acts on `&str` types I can't think of any, and especially since the methods do the same thing anyway.

changelog: allow `str_to_string` lint to be automatically applied
2024-06-02 21:11:06 +00:00