Commit graph

19004 commits

Author SHA1 Message Date
bors
7dfa6ced9b Auto merge of #12266 - granddaifuku:fix/ice-12253-index-exceeds-usize, r=Manishearth
fix: ICE when array index exceeds usize

fixes #12253

This PR fixes ICE in `indexing_slicing` as it panics when the index of the array exceeds `usize`.

changelog: none
2024-02-12 19:08:14 +00:00
bors
b0e7640fd7 Auto merge of #12267 - Jarcho:issue_12254, r=Alexendoo
Don't allow derive macros to silence `disallowed_macros`

fixes #12254

The implementation is a bit of a hack, but "works". A derive expanding to another derive won't work properly, but we shouldn't be linting those anyways.

changelog: `disallowed_macros`: Don't allow derive macros to silence their own expansion
2024-02-12 13:19:52 +00:00
bors
75f57cf4c2 Auto merge of #12248 - GuillaumeGomez:extend-NONMINIMAL_BOOL, r=blyxyas
Extend `NONMINIMAL_BOOL` lint

Fixes #5794.

r? `@blyxyas`

changelog: Extend `NONMINIMAL_BOOL` lint
2024-02-11 23:25:40 +00:00
Guillaume Gomez
5e7c437d41 Extend NONMINIMAL_BOOL to check inverted boolean values 2024-02-11 21:22:33 +01:00
Guillaume Gomez
a18e0a11f7 Extend NONMINIMAL_BOOL lint 2024-02-11 21:22:33 +01:00
bors
fff46c1667 Auto merge of #12231 - Alexendoo:y21, r=y21
Add y21 to the review rotation

https://github.com/rust-lang/team/pull/1342

r? `@ghost,` when you're ready to be added to the rotation ``@bors` r+` this `@y21`

changelog: none
2024-02-11 18:20:52 +00:00
bors
d427b70fcf Auto merge of #12274 - nyurik:nit-format-impl, r=xFrednet
Minor refactor format-impls

Move all linting logic into a single format implementations struct

This should help with the future format-args improvements.

TODO: do the same with format_args.rs, perhaps in the same PR

**NOTE TO REVIEWERS**:  use "hide whitespace" in the github diff -- most of the code has shifted, but relatively low number of lines actually modified.

changelog: none
2024-02-11 17:53:31 +00:00
bors
9a253fa68e Auto merge of #12269 - y21:implied_bounds_in_impls_refactor, r=xFrednet
Refactor `implied_bounds_in_impls` lint

Some refactors in `implied_bounds_in_impls` that I wanted to make while working on something else in that file, but I found them "large" enough that I didn't want them in the same PR and instead wanted them reviewed separately (since itd just be distracting).

This just splits up the two phases of "collect all the supertraits from each of the `impl Trait` bounds" and "find those `impl Trait` bounds that are mentioned in one of the previously-collected supertraits" into separate functions. Before, this was all in a single function.

Reviewing it commit by commit might make it easier. I can squash it down later.

changelog: none
2024-02-11 17:41:39 +00:00
bors
9b2021235a Auto merge of #12040 - J-ZhengLi:issue12016, r=y21
stop linting [`blocks_in_conditions`] on `match` with weird attr macro case

should fixes: #12016

---

changelog: [`blocks_in_conditions`] - fix FP on `match` with weird attr macro

This might not be the best solution, as the root cause (i think?) is the `span` of block was incorrectly given by the compiler?

I'm open to better solutions
2024-02-11 13:26:18 +00:00
J-ZhengLi
4cc7b7e092 stop linting [blocks_in_conditions] on match on proc macros 2024-02-12 04:16:11 +08:00
bors
ae38a6753d Auto merge of #12272 - Luk-ESC:master, r=xFrednet
Fix broken URL in `Lint Configuration`

Pretty sure it's meant to be `struct_field_names` and not `struct_variant_names`.

This change is gargantuan!!! review carefully

changelog: none
2024-02-11 13:17:29 +00:00
Lukas Eschbacher
2b89cd4bf6
fix broken URL in Lint Configuration
Signed-off-by: Lukas Eschbacher <eschbacher.lukas@gmail.com>
2024-02-11 13:20:25 +01:00
bors
d29f2eebdd Auto merge of #12261 - Jarcho:issue_12257, r=dswij
Don't lint `incompatible_msrv` in test code

fixes #12257

changelog: `incompatible_msrv`: Don't lint in test code
2024-02-11 11:55:28 +00:00
Yuri Astrakhan
a595a2c98b Minor refactor format-impls
* Move all linting logic into a single format implementations struct

This should help with the future format-args improvements.

TODO: do the same with format_args.rs, perhaps in the same PR
2024-02-11 04:22:32 -05:00
y21
a38f44ca93 extract finding implied bound to separate function 2024-02-11 00:33:28 +01:00
y21
d1acbf576e extract supertrait collection to separate function 2024-02-11 00:17:21 +01:00
Jason Newcomb
ac7c6e5417 Don't allow derive macros to silence disallowed_macros for their own call. 2024-02-10 16:10:05 -05:00
granddaifuku
c4d11083d9 fix: ICE when array index exceeds usize 2024-02-11 03:51:26 +09:00
bors
51c89a45d9 Auto merge of #12264 - y21:issue12263, r=Jarcho
[`to_string_trait_impl`]: avoid linting if the impl is a specialization

Fixes #12263

Oh well... https://github.com/rust-lang/rust-clippy/pull/12122#issuecomment-1887765238 🙃

changelog: [`to_string_trait_impl`]: avoid linting if the impl is a specialization
2024-02-10 18:48:02 +00:00
bors
e67b7e02da Auto merge of #12258 - tgross35:similiar-names-update, r=Alexendoo
[`similar_names`]: don't raise if the first character is different

A lot of cases of the "noise" cases of `similar_names` come from two idents with a different first letter, which is easy enough to differentiate visually but causes this lint to be raised.

Do not raise the lint in these cases, as long as the first character does not have a lookalike.

Helps with https://github.com/rust-lang/rust-clippy/issues/10926 (does not fix)

This is per-commit reviewable, the first commit is just refactoring.

changelog: [`similar_names`]: don't raise if the first character is different
2024-02-10 17:17:41 +00:00
y21
b3b9919d1b [to_string_trait_impl]: take specialization into account 2024-02-10 17:37:51 +01:00
Jason Newcomb
9012d55c02 Don't lint incompatible_msrv in test code 2024-02-10 09:35:29 -05:00
J-ZhengLi
92537a0e5b add test case with a proc macro fake_desugar_await 2024-02-10 22:26:50 +08:00
Trevor Gross
5250afb77d Remove '#[expect(clippy::similar_names)]' where needed to pass dogfood tests 2024-02-09 23:39:36 -06:00
Trevor Gross
09f18f61c6 [similar_names] don't raise if the first character is different
A lot of cases of the "noise" cases of `similar_names` come from two
idents with a different first letter, which is easy enough to
differentiate visually but causes this lint to be raised.

Do not raise the lint in these cases, as long as the first character
does not have a lookalike.

Link: https://github.com/rust-lang/rust-clippy/issues/10926
2024-02-09 23:19:27 -06:00
Trevor Gross
4a5e30dca7 Refactor a portion of 'non_expressive_names.rs' for clarity 2024-02-09 22:56:07 -06:00
bors
28443e63fb Auto merge of #12070 - roife:fix/issue-12034, r=Centri3
Fix issue #12034: add autofixes for unnecessary_fallible_conversions

fixes #12034

Currently, the `unnecessary_fallible_conversions` lint was capable of autofixing expressions like `0i32.try_into().unwrap()`. However, it couldn't autofix expressions in the form of `i64::try_from(0i32).unwrap()` or `<i64 as TryFrom<i32>>::try_from(0).unwrap()`.

This pull request extends the functionality to correctly autofix these latter forms as well.

changelog: [`unnecessary_fallible_conversions`]: Add autofixes for more forms
2024-02-09 17:37:26 +00:00
bors
fb398a5777 Auto merge of #12251 - blyxyas:on-vacation, r=blyxyas
Temporary review vacation to focus on performance

We are at Feb. 9, I have done practically nothing in regards to performance and bors just keeps giving me reviews, so I'm going to set myself on vacation on this repo and reroll some PRs. Sadly I cannot postpone performance for reviews.

I'll revert this commit on 12-15 days. I'd love to the discussion in this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/review.20queue.20.26.20capacity) to make some progress so that I don't have to get into version control my busyness status.

changelog:none
r? ghost
2024-02-09 08:50:25 +00:00
blyxyas
0d696023c4
(NOT INCLUDE IN RUST-SYNC) Temporary vacation to focus on performance 2024-02-09 09:48:02 +01:00
bors
60cb29c5e4 Auto merge of #12246 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2024-02-08 19:17:05 +00:00
Philipp Krones
2ca6c84194
Bump Clippy version -> 0.1.78 2024-02-08 19:13:40 +01:00
Philipp Krones
031c46dd90
Bump nightly version -> 2024-02-08 2024-02-08 19:13:28 +01:00
Philipp Krones
d2f76f7e6e
Merge remote-tracking branch 'upstream/master' into rustup 2024-02-08 19:13:13 +01:00
roife
3c76b2ceff Merging the calculation of sugg and applicability 2024-02-08 13:45:57 +08:00
bors
62dcbd672b Auto merge of #12177 - y21:issue12154, r=Jarcho
[`unconditional_recursion`]: compare by `Ty`s instead of `DefId`s

Fixes #12154
Fixes #12181 (this was later edited in, so the rest of the description refers to the first linked issue)

Before this change, the lint would work with `DefId`s and use those to compare types. This PR changes it to compare types directly. It fixes the linked issue, but also other false positives I found in a lintcheck run. For example, one of the issues is that some types don't have `DefId`s (primitives, references, etc., leading to possible FNs), and the helper function used to extract a `DefId` didn't handle type parameters.

Another issue was that the lint would use `.peel_refs()` in a few places where that could lead to false positives (one such FP was in the `http` crate). See the doc comment on one of the added functions and also the test case for what I mean.

The code in the linked issue was linted because the receiver type is `T` (a `ty::Param`), which was not handled in `get_ty_def_id` and returned `None`, so this wouldn't actually *get* to comparing `self_arg != ty_id` here, and skip the early-return:
70573af31e/clippy_lints/src/unconditional_recursion.rs (L171-L178)

This alone could be fixed by doing something like `&& get_ty_def_id(ty).map_or(true, |ty_id)| self_arg != ty_id)`, but we don't really need to work with `DefId`s in the first place, I don't think.

changelog: [`unconditional_recursion`]: avoid linting when the other comparison type is a type parameter
2024-02-07 16:18:33 +00:00
bors
08c8cd5014 Auto merge of #12216 - bpandreotti:redundant-type-annotations-fix, r=Jarcho
Fix false positive in `redundant_type_annotations` lint

This PR changes the `redundant_type_annotations` lint to allow slice type annotations (i.e., `&[u8]`) for byte string literals. It will still consider _array_ type annotations (i.e., `&[u8; 4]`) as redundant. The reasoning behind this is that the type of byte string literals is by default a reference to an array, but, by using a type annotation, you can force it to be a slice. For example:
```rust
let a: &[u8; 4] = b"test";
let b: &[u8] = b"test";
```

Now, the type annotation for `a` will still be linted (as it is still redundant), but the type annotation for `b` will not.

Fixes #12212.

changelog: [`redundant_type_annotations`]: Fix false positive with byte string literals
2024-02-07 16:02:28 +00:00
bors
b1e5a58427 Auto merge of #11812 - Jarcho:issue_11786, r=Alexendoo
Return `Some` from `walk_to_expr_usage` more

fixes #11786
supersedes #11097

The code removed in the first commit would have needed changes due to the second commit. Since it's useless it just gets removed instead.

changelog: `needless_borrow`: Fix linting in tuple and array expressions.
2024-02-06 15:20:07 +00:00
bors
d910f77c2c Auto merge of #12235 - nyurik:patch-1, r=flip1995
Fix release year in CHANGELOG.md

Fixes a typo in #12224

CC: `@xFrednet` `@Manishearth`

---

changelog: none
2024-02-06 09:42:51 +00:00
Yuri Astrakhan
36f7248da0
Fix release year in CHANGELOG.md 2024-02-06 02:43:34 -05:00
Michael Goulet
7895b98712 Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
Alex Macleod
68f6dd41ce Add y21 to the review rotation 2024-02-05 22:52:32 +00:00
bors
fdf819df9a Auto merge of #12227 - y21:issue12225, r=Manishearth
[`redundant_locals`]: take by-value closure captures into account

Fixes #12225

The same problem in the linked issue can happen to regular closures too, and conveniently async blocks are closures in the HIR so fixing closures will fix async blocks as well.

changelog: [`redundant_locals`]: avoid linting when redefined variable is captured by-value
2024-02-05 18:37:05 +00:00
bors
005b6c2424 Auto merge of #11919 - y21:manual_c_str_literals, r=xFrednet
new lint: `manual_c_str_literals`

With rust-lang/rust#117472 merged and `c""` syntax stabilized, I think it'd be nice to have a lint for using `CStr::from_ptr` (and similar constructors) with a string literal as an argument.
We can probably also lint `"foo\0".as_ptr()` and suggest `c"foo".as_ptr()`. I might add that to this PR tomorrow if I find the time.

The byte string literal to c string literal rewriting is ugly but oh well.

changelog: new lint: `manual_c_str_literals`
[#11919](https://github.com/rust-lang/rust-clippy/pull/11919)
2024-02-05 18:15:52 +00:00
y21
7f80b449f5 new lint: manual_c_str_literals 2024-02-05 18:51:49 +01:00
y21
6807977153 also check for coroutines 2024-02-05 15:41:59 +01:00
Matthias Krüger
d13ce192c9 Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillot
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern

These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error.

This is part of implementing https://github.com/rust-lang/rfcs/pull/3535.

Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint.

https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-02-05 11:07:26 +01:00
bors
8baeb26754 Auto merge of #12224 - xFrednet:chaneglog-1-76, r=Manishearth
Changelog for Clippy 1.76 🐈

Roses are red,
Violets are blue,
So many cute cats,
How to choose?

---

### The cat of this release is: *Cabrel* submitted by `@daniel-g-gagnon:`

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/17087237/41aea3dc-7935-4dfe-80ff-a6efd92f76ab" alt="The cats of this Clippy release" />

The cat for the next release can be voted on: [here](https://docs.google.com/forms/d/e/1FAIpQLSfERam31AEi3_5uVsugi1-JHGF9Po1oC7OIiLs8jglprZNy_g/viewform)

The cat for the next next release can be nominated in the comments and will be voted in the next changelog PR (Submission deadline is 2024-02-06 23:59CET)

---

changelog: none
2024-02-05 08:44:34 +00:00
y21
7c3908f86c [redundant_locals]: take by-value closure captures into account 2024-02-04 20:19:27 +01:00
bors
34e4c9fa4a Auto merge of #12087 - marcin-serwin:ref_as_ptr_cast, r=blyxyas
Add new lint: `ref_as_ptr`

Fixes #10130

Added new lint `ref_as_ptr` that checks for conversions from references to pointers and suggests using `std::ptr::from_{ref, mut}` instead.

The name is different than suggested in the issue (`as_ptr_cast`) since there were some other lints with similar names (`ptr_as_ptr`, `borrow_as_ptr`) and I wanted to follow the convention.

Note that this lint conflicts with the `borrow_as_ptr` lint in the sense that it recommends changing `&foo as *const _` to `std::ptr::from_ref(&foo)` instead of `std::ptr::addr_of!(foo)`. Personally, I think the former is more readable and, in contrast to `addr_of` macro, can be also applied to temporaries (cf. #9884).

---

changelog: New lint: [`ref_as_ptr`]
[#12087](https://github.com/rust-lang/rust-clippy/pull/12087)
2024-02-04 17:07:18 +00:00
Marcin Serwin
a3baebcb31
Add ref_as_ptr lint
Author:    Marcin Serwin <marcin.serwin0@protonmail.com>
2024-02-04 17:38:09 +01:00