Commit Graph

20010 Commits

Author SHA1 Message Date
Jason Newcomb
e18b310874 Add more types to is_from_proc_macro 2024-06-16 20:15:09 -04:00
bors
9f5d60f160 Auto merge of #12893 - kyleoneill:field_scoped_visibility_modifiers, r=blyxyas
Add field_scoped_visibility_modifiers lint

changelog: [`field_scoped_visibility_modifiers`]: Add a lint which checks for struct fields using Restricted (not inherited, not public) visibility modifiers.
2024-06-16 20:14:20 +00:00
kyle oneill
3405ce3bca Add field_scoped_visibility_modifiers lint 2024-06-16 15:54:48 -04:00
bors
8065e0f61c Auto merge of #12939 - Alexendoo:lintcheck-popular-crates, r=xFrednet
Merge lintcheck popular-crates bin as a subcommand

Also rewrites it to use `ureq` to drop some heavy dependencies as `crates_io_api` brings in `reqwest`

r? `@xFrednet`

changelog: none
2024-06-16 19:19:48 +00:00
Alex Macleod
3a983c399a Merge lintcheck popular-crates bin as a subcommand 2024-06-16 18:28:00 +00:00
bors
a2c9782128 Auto merge of #10398 - Alexendoo:auto-lintcheck, r=xFrednet
Run a diff of lintcheck against the merge base for pull requests

changelog: none
<!-- changelog_checked -->

This is an MVP of sorts, it consists of #9764 + a GitHub action that feeds the output to the [job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary). It doesn't yet do anything fancy like `--recursive` or adding comments to the PR, so you'd have to click through to the action to see the results

Example output of a change (0be1ab82f8): https://github.com/Alexendoo/rust-clippy/actions/runs/4264858870#summary-11583333018

r? `@flip1995`
2024-06-16 10:03:12 +00:00
bors
82345c30ae Auto merge of #12937 - AurelienFT:add_msrv_manual_patter_char_comparison, r=Alexendoo
Add MSRV for manual_pattern_char_comparison

Fixes #12936

changelog: [`manual_pattern_char_comparison`]: Add MSRV 1.58
2024-06-15 23:33:49 +00:00
AurelienFT
51c6630d4f Change MSRV check for manual_pattern_char_comparison only for pattern arrays 2024-06-15 21:52:42 +02:00
AurelienFT
63388cbab8 add MSRV for manual_pattern_char_comparison 2024-06-15 21:45:35 +02:00
bors
0dc265ff82 Auto merge of #12756 - y21:assigning_clones_lifetimes, r=Alexendoo
Avoid emitting `assigning_clones` when cloned data borrows from the place to clone into

Fixes #12444
Fixes #12460
Fixes #12749
Fixes #12757
Fixes #12929

I think the documentation for the function should describe what- and how this is fixing the issues well.
It avoids emitting a warning when the data being cloned borrows from the place to clone into, which is information that we can get from `PossibleBorrowerMap`. Unfortunately, it is a tiny bit tedious to match on the MIR like that and I'm not sure if this is possibly relying a bit too much on the exact MIR lowering for assignments.

Things left to do:
- [x] Handle place projections (or verify that they work as expected)
- [x] Handle non-`Drop` types

changelog: [`assigning_clones`]: avoid warning when the suggestion would lead to a borrow-check error
2024-06-15 18:25:42 +00:00
Alex Macleod
feb0671893 Add lintcheck diff github action 2024-06-15 13:58:10 +00:00
Alex Macleod
477b0c6a78 lintcheck: Add JSON output, diff subcommand 2024-06-15 13:58:10 +00:00
bors
73c1bfbc57 Auto merge of #12880 - bitfield:fix_doc_nits_b, r=Alexendoo
Fix doc nits

Clippy is wonderful, and reading its lints is a great way to learn about Rust. While doing this, I noticed a few little copyedits, such as adding trailing periods to sentences, or tweaking wording very slightly to improve its readability. I hope you will accept these suggestions as an act of love for the project, with my thanks for all the maintainers' hard work.

changelog: Docs [ mut_range_bound ]: fix doc nits
changelog: Docs [ needless_for_each ]: fix doc nits
changelog: Docs [ arc_with_non_send_sync ]: fix doc nits
changelog: Docs [ allow_attributes ]: fix doc nits
changelog: Docs [ allow_attributes_without_reason ]: fix doc nits
2024-06-15 13:43:53 +00:00
bors
3e5a02b13b Auto merge of #12921 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2024-06-13 10:25:51 +00:00
Philipp Krones
89658ef820
Bump nightly version -> 2024-06-13 2024-06-13 12:24:17 +02:00
Philipp Krones
614966b0c3
Bump Clippy version -> 0.1.81 2024-06-13 12:24:14 +02:00
Philipp Krones
cc63143bbf
Merge remote-tracking branch 'upstream/master' into rustup 2024-06-13 12:24:08 +02:00
bors
aaade2d12d Auto merge of #12855 - tesuji:fix-author-lint, r=Jarcho
Fix typos of author lint

changelog: none
2024-06-11 22:49:18 +00:00
bors
38d12a9bc0 Auto merge of #12681 - y21:issue12677, r=Jarcho
Let `qualify_min_const_fn` deal with drop terminators

Fixes #12677

The `method_accepts_droppable` check that was there seemed overly conservative.
> Returns true if any of the method parameters is a type that implements `Drop`.
> The method can't be made const then, because `drop` can't be const-evaluated.

Accepting parameters that implement `Drop` should still be fine as long as the parameter isn't actually dropped, as is the case in the linked issue where the droppable is moved into the return place. This more accurate analysis ("is there a `drop` terminator") is already done by `qualify_min_const_fn` [here](f5e250180c/clippy_utils/src/qualify_min_const_fn.rs (L298)), so I don't think this additional check is really necessary?

Fixing the other, second case in the linked issue was only slightly more involved, since `Vec::new()` is a function call that has the ability to panic, so there must be a `drop()` terminator for cleanup, however we should be able to freely ignore that. [Const checking ignores cleanup blocks](https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/transform/check_consts/check.rs#L382-L388), so we should, too?

r? `@Jarcho`

----

changelog: [`missing_const_for_fn`]: continue linting on fns with parameters implementing `Drop` if they're not actually dropped
2024-06-11 22:38:52 +00:00
bors
740b72ef79 Auto merge of #12849 - AurelienFT:manual-char-comparison-pattern, r=Alexendoo
Add lint to check manual pattern char comparison

This PR adds a new lint asked in https://github.com/rust-lang/rust-clippy/issues/12490

This lint catches manual char comparison in pattern of string functions and propose to use `char` or array of `char` instead.

As it's my first contribution i'm not feeling very safe about not matching too much or missing some cases.

Thanks in advance for taking time to review and propose feedback !

changelog: new lint [`manual_pattern_char_comparison`]
2024-06-11 22:15:43 +00:00
AurelienFT
c86b19f1ef Add lint to check manual pattern char comparison and merge its code with single_char_pattern lint 2024-06-11 21:56:14 +02:00
bors
9ddea51a73 Auto merge of #12912 - lochetti:fix_12824, r=dswij
Don't lint indexing_slicing lints on proc macros

This pr fixes https://github.com/rust-lang/rust-clippy/issues/12824

Even though the issue mentions the indexing case only, it was easy to apply the fix to the slicing case as well.

changelog: [`out_of_bounds_indexing`, `indexing_slicing`]: Don't lint on procedural macros.
2024-06-11 15:27:36 +00:00
bors
87c895ad83 Auto merge of #12915 - belyakov-am:lint/single_char_add_str, r=xFrednet
Handle single chars with `to_string()` for `single_char_add_str`

Add support for single chars / literals with `to_string()` call for `push_str()` and `insert_str()`.

changelog: [`single_char_add_str`]: handle single chars with `to_string()` call

Closes #12775
2024-06-11 11:08:45 +00:00
bors
dbdc43738b Auto merge of #12913 - alex-semenyuk:ui_fix, r=xFrednet
Filter from first typed symbol on gh-pages

Cosmetic fix
Don't see the reason that now filter on gh-pages is starting work after 3 symbols typing so remove this condition

Before:

https://github.com/rust-lang/rust-clippy/assets/5480441/fa3b780e-30dc-4fdb-bf2d-5a99337eca4e

After:

https://github.com/rust-lang/rust-clippy/assets/5480441/977e15af-8be5-462c-a703-f10c05e6109c

changelog: gh-pages
2024-06-11 10:58:05 +00:00
bors
acdf564692 Auto merge of #12904 - Jarcho:issue_10750, r=xFrednet
Normalize type aliases when checking significant drops.

fixes #10750

No test as I'm not sure exactly how the type alias caused a stack overflow here. Also removes an unnecessary `HashSet`.

changelog: none
2024-06-11 10:47:49 +00:00
Matthias Krüger
35f54fd439 Rollup merge of #126159 - RalfJung:scalarint-size-mismatch, r=oli-obk
ScalarInt: size mismatches are a bug, do not delay the panic

Cc [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Why.20are.20ScalarInt.20to.20iN.2FuN.20methods.20fallible.3F)

r? ``@oli-obk``
2024-06-10 21:12:25 +02:00
Ralf Jung
8c1f953772 ScalarInt: size mismatches are a bug, do not delay the panic 2024-06-10 13:43:16 +02:00
Renato Lochetti
f7515ae905
Don't lint indexing_slicing lints on proc macros 2024-06-10 09:08:56 +01:00
Artem Belyakov
f7723cada7 Fix dogfood test 2024-06-09 21:23:59 +03:00
Artem Belyakov
55344c84a5 Handle single chars with to_string() for single_char_add_str 2024-06-09 21:01:00 +03:00
alexey semenyuk
3f9c5872b9
Filter from first typed symbol 2024-06-09 17:37:05 +05:00
clubby789
5acc25e700 Update icu4x dependencies 2024-06-09 07:47:42 +01:00
Lzu Tao
2855a876a7 fix typos of author lint 2024-06-08 12:31:49 +00:00
bors
48686adf48 Auto merge of #12805 - Alexendoo:blocks-in-conditions-closures, r=dswij
Don't lint blocks in closures for blocks_in_conditions

Seemed like an outlier for the lint which generally caught only the syntactically confusing cases, it lints blocks in closures but excludes closures passed to iterator methods, this changes it to ignore closures in general

changelog: none
2024-06-08 09:45:22 +00:00
Jason Newcomb
75e1d72093 Normalize type aliases when checking significant drops. 2024-06-08 01:19:05 -04:00
León Orell Valerian Liehr
fe6f332193 Rollup merge of #125951 - slanterns:error_in_core_stabilization, r=Amanieu
Stabilize `error_in_core`

Closes: https://github.com/rust-lang/rust/issues/103765.

`@rustbot` label: +T-libs-api

r? libs-api
2024-06-08 04:25:44 +02:00
bors
0ea88b90d8 Auto merge of #12900 - Alexendoo:no-lazy-static, r=llogiq
Remove `lazy_static` mention

I planned to replace any mention with `LazyLock` but I think `thread_local` is more appropriate here - `const`s that aren't `Sync` wouldn't be able to go in a `lazy_static`/`static LazyLock` either

Also removed a test file that was mostly commented out so wasn't testing anything

changelog: none
2024-06-07 22:54:02 +00:00
bors
d553ebef57 Auto merge of #12851 - samueltardieu:issue12846, r=y21
Add required parentheses around method receiver

Fix #12846

changelog: [`needless_bool`]: Add missing parentheses around method receiver
2024-06-07 21:27:46 +00:00
y21
c3d3a3f301 remove unnecessary const error handling in missing_const_for_fn 2024-06-07 21:54:33 +02:00
y21
973f318514 qualify_min_const_fn: ignore cleanup bbs 2024-06-07 20:56:22 +02:00
y21
6fdf295664 let qualify_min_const_fn deal with drop checks 2024-06-07 20:56:22 +02:00
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