Commit Graph

19610 Commits

Author SHA1 Message Date
bors
7063e3435c Auto merge of #12094 - yuxqiu:search_is_some, r=xFrednet,ARandomDev99
fix: incorrect suggestions when `.then` and `.then_some` is used

fixes #11910

In the current implementation of `search_is_some`, if a `.is_none` call is followed by a `.then` or `.then_some` call, the generated `!` will incorrectly negate the values returned by the `then` and `.then_some` calls. To fix this, we need to add parentheses to the generated suggestions when appropriate.

changelog: [`search_is_some`]: add parenthesis to suggestions when appropriate
2024-04-14 19:27:42 +00:00
bors
832fdb6d30 Auto merge of #12573 - modelflat:recognize-common-prepositions-in-module-name-repetitions, r=Jarcho
[`module_name_repetition`] Recognize common prepositions

Fixes #12544

changelog: [`module_name_repetition`]: don't report an item name if it consists only of a prefix from `allowed-prefixes` list and a module name (e.g. `AsFoo` in module `foo`). Prefixes allowed by default: [`to`, `from`, `into`, `as`, `try_into`, `try_from`]
2024-04-12 18:53:03 +00:00
bors
0d84f00156 Auto merge of #12635 - Alexendoo:doc-check-attributes, r=Jarcho
Use `check_attributes` in doc lints

Ensures we catch all the places that doc comments could occur, found one that we were currently missing - docs on `extern` items

changelog: none
2024-04-12 18:40:31 +00:00
bors
6b1c828d91 Auto merge of #12661 - jqnatividad:unsafe_derive_deserialize-why_is_this_bad-typo, r=Alexendoo
unsafe_derive_deserialize: `Why is this bad?` explanation typo

changelog: [`unsafe_derive_deserialize`]: Correct `Why is this bad?` explanation typo
2024-04-11 15:05:58 +00:00
bors
7dca8152cf Auto merge of #12660 - jqnatividad:fix-various-typos, r=Alexendoo
Fix various typos

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

changelog: fix several typos
2024-04-11 14:55:44 +00:00
bors
46323751ad Auto merge of #12665 - cowlicks:patch-1, r=Alexendoo
Fix typo in needless_borrows_for_generic_args.rs

fix small typo

changelog: none
2024-04-11 14:45:31 +00:00
bors
dfd41ad426 Auto merge of #12668 - Alexendoo:remark-version, r=flip1995
Pin `remark-lint-maximum-line-length` version

Pins the remark versions to the ones from before the most recent set of updates which errors on [some line lengths](https://github.com/remarkjs/remark-lint/issues/318) that aren't clear how to resolve

Currently blocking CI

changelog:  none
2024-04-11 14:20:42 +00:00
Alex Macleod
fb2e827c64 Pin remark-lint-maximum-line-length version 2024-04-11 14:17:10 +00:00
cowlicks
8b5447c622
Fix typo in needless_borrows_for_generic_args.rs 2024-04-10 12:57:24 -05:00
Joel Natividad
d7a8622bf4
Why is this bad explanation typo 2024-04-10 08:46:03 -04:00
Joel Natividad
8de0a1bdbd
fix varname typo 2024-04-10 08:37:30 -04:00
Joel Natividad
e5b6d433fb
fix various comment typos 2024-04-10 08:37:02 -04:00
bors
62fd1d5377 Auto merge of #12646 - GuillaumeGomez:regression-test-12537, r=blyxyas
Turn `duplicated_attributes` into a late lint

Fixes #12537.

changelog: Turn `duplicated_attributes` into a late lint
2024-04-09 15:05:42 +00:00
Guillaume Gomez
f7d49a340d Turn duplicated_attributes into a late lint 2024-04-09 16:42:26 +02:00
bors
ccc93f91b2 Auto merge of #12649 - flip1995:book-readme-sync, r=xFrednet
Consistent lint group table in book and README

The lint table and the restriction group description was improved in #10385, but only in the README. Apply the same changes to the book.

r? `@xFrednet`

I noticed that I left review comments about this in #10385, but never submitted them. So to this day they are listed as "pending" in the GitHub UI.

This is just copy and paste of the current README file on `master`.

changelog: none
2024-04-09 09:13:35 +00:00
bors
54e8ad88b6 Auto merge of #12652 - Wilfred:patch-2, r=Alexendoo
Fix markdown syntax in str_split_at_newline docs

changelog: [`str_split_at_newline`] Fix formatting of docs
2024-04-09 09:03:37 +00:00
Philipp Krones
23225e15d0
Consistent lint group table in book and README
The lint table and the restriction group description was improved in #10385,
but only in the README. Apply the same changes to the book.
2024-04-09 10:48:29 +02:00
modelflat
3705073a71 Recognize common prefixes when checking for items with module name suffix
Fixes #12544.

- don't report an item name if it consists only of a prefix from `allowed-prefixes` list and a module name (e.g. `AsFoo` in module `foo`).
- configured by `allowed-prefixes` config entry
- prefixes allowed by default: [`to`, `from`, `into`, `as`, `try_into`, `try_from`]
- update docs
2024-04-09 09:47:54 +02:00
bors
1b6561f59b Auto merge of #12630 - mira-eanda:master, r=Manishearth
Correct parentheses for [`needless_borrow`] suggestion

This fixes #12268

Clippy no longer adds unnecessary parentheses in suggestions when the expression is part of a tuple.

---

changelog: Fix [`needless_borrow`] unnecessary parentheses in suggestion.
2024-04-08 23:17:42 +00:00
Mariana Miranda
8ae7eaefdc fix: Refactor dereference code and fix test 2024-04-08 23:35:19 +01:00
Wilfred Hughes
db3a927432
Fix markdown syntax in str_split_at_newline docs 2024-04-08 12:50:28 -07:00
bors
2202493a67 Auto merge of #12626 - folkertdev:incorrect-boolean-simplification, r=blyxyas
fix incorrect suggestion for `!(a as type >= b)`

fixes #12625

The expression  `!(a as type >= b)` got simplified to `a as type < b`, but because of rust's parsing rules that `<` is interpreted as a start of generic arguments for `type`.  This is fixed by recognizing this case and adding extra parens around the left-hand side of the comparison.

changelog: [`nonminimal_bool`]: fix incorrect suggestion for  `!(a as type >= b)`
2024-04-08 11:05:09 +00:00
bors
1c9e96536b Auto merge of #12610 - ARandomDev99:manual_unwrap_or_default-12564, r=dswij
[`manual_unwrap_or_default`]: Check for Default trait implementation in initial condition when linting and use `IfLetOrMatch`

Fixes #12564

changelog: Fix [`manual_unwrap_or_default`] false positive when initial `match`/`if let` condition doesn't implement `Default` but the return type does.
2024-04-08 07:24:17 +00:00
Folkert
6a2cb33029
fix incorrect suggestion for !(a as type >= b) 2024-04-07 19:17:49 +02:00
bors
367f7aac5a Auto merge of #12604 - xFrednet:00000-review-vacation, r=matthiaskrgr
Prevent PR assignments to `@matthiaskrgr`, `@giraffate`, and `@Centri3`

When commenting r? clippy, rustbot takes a random member from the team. I'm setting you kings and queen to be on vacation, so that rustbot doesn't target you.

---

changelog: none

cc: `@matthiaskrgr` `@giraffate` and `@Centri3`
2024-04-06 10:11:18 +00:00
xFrednet
2a34f231e9
Prevent PR assignments to @matthiaskrgr, @giraffate, and @Centri3 2024-04-06 12:08:55 +02:00
bors
eecff6d07b Auto merge of #12439 - Jacherr:issue-12185, r=blyxyas
fix ice reporting in lintcheck

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

This PR fixes the lack of reported ICEs within lintcheck by modifying the way in which data is collected from each crate being linted.

Instead of lintcheck only reading `stdout` for warnings, it now also reads `stderr` for any potential ICE (although admittedly, it is not the cleanest method of doing so). If it is detected, it parses the ICE into its message and backtrace separately, and then adds them to the list of outputs via clippy.

Once all outputs are collected, the formatter then proceeds to generate the file as normal.

Note that this PR also has a couple of side effects:
- When clippy fails to process a package, but said failure is not an ICE, the `stderr` will be sent to the console;
- Instead of `ClippyWarning` being the primary struct for everything reported, there is now `ClippyCheckOutput`, an enum which splits the outputs into warnings and ICEs.

changelog: none
2024-04-05 18:16:07 +00:00
Jacherr
42d09703b4 Add support for ICE reporting in lintcheck 2024-04-05 20:14:38 +02:00
Alex Macleod
d4a8f61eb3 Use check_attributes in doc lints 2024-04-05 16:12:07 +00:00
bors
08dac852a5 Auto merge of #12631 - franciscoBSalgueiro:11738, r=blyxyas
Allow `cast` lints in macros

closes: #11738

Removed the `from_expansion` guard clause for cast lints, so that these warnings can be generated for internal macros.

changelog: allow `cast` lints in macros
2024-04-04 23:02:55 +00:00
bors
8253040b3f Auto merge of #12591 - y21:issue12585, r=Jarcho
type certainty: clear `DefId` when an expression's type changes to non-adt

Fixes #12585

The root cause of the ICE in the linked issue was in the expression `one.x`, in the array literal.

The type of `one` is the `One` struct: an adt with a DefId, so its certainty is `Certain(def_id_of_one)`. However, the field access `.x` can then change the type (to `i32` here) and that should update that `DefId` accordingly. It does do that correctly when `one.x` would be another adt with a DefId:

97ba291d5a/clippy_utils/src/ty/type_certainty/mod.rs (L90-L91)

but when it *isn't* an adt and there is no def id (which is the case in the linked issue: `one.x` is an i32), it keeps the `DefId` of `One`, even though that's the wrong type (which would then lead to a contradiction later when joining `Certainty`s):
97ba291d5a/clippy_utils/src/ty/type_certainty/mod.rs (L92-L93)

In particular, in the linked issue, `from_array([one.x, two.x])` would try to join the `Certainty` of the two array elements, which *should* have been `[Certain(None), Certain(None)]`, because `i32`s have no `DefId`, but instead it was `[Certain(One), Certain(Two)]`, because the DefId wasn't cleared from when it was visiting `one` and `two`. This is the "contradiction" that could be seen in the ICE message

... so this changes it to clear the `DefId` when it isn't an adt.

cc `@smoelius` you implemented this initially in #11135, does this change make sense to you?

changelog: none
2024-04-04 22:17:50 +00:00
bors
a73e751d19 Auto merge of #12609 - Alexendoo:arc-with-non-send-sync-message, r=Jarcho
Reword `arc_with_non_send_sync` note and help messages

Addresses https://github.com/rust-lang/rust-clippy/issues/12608#issuecomment-2029688054

Makes the note more concise and reframes the `Rc` suggestion around whether it crosses threads currently due to a manual `Send`/`Sync` impl or may do in the future

changelog: none
2024-04-04 21:59:21 +00:00
bors
9725c4a162 Auto merge of #12632 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2024-04-04 17:50:22 +00:00
Philipp Krones
bb023e90d8
Bump nightly version -> 2024-04-04 2024-04-04 19:48:53 +02:00
Philipp Krones
277303b210
Merge remote-tracking branch 'upstream/master' into rustup 2024-04-04 19:48:31 +02:00
bors
5a9e9b0e65 Auto merge of #12628 - franciscoBSalgueiro:fix-book-links, r=flip1995
Add missing links in the book

Added a few missing links marked with FIXME in the development book.

changelog: none
2024-04-04 11:39:45 +00:00
Mariana Miranda
38b8056fc6 Fix: #12268: Correct parentheses for needless_borrow suggestion
Clippy no longer adds unnecessary parentheses in suggestion when the expression is a part of a tuple.
2024-04-04 10:24:25 +01:00
bors
398a52a8dc Auto merge of #12340 - not-elm:fix/issue-12334, r=llogiq
FIX(12334): manual_swap auto fix

Fixed: #12334

Initialization expressions are now generated as needed if the slice index is bound to a variable.

----

changelog: Fix [`manual_swap`]
2024-04-04 09:16:44 +00:00
Francisco Salgueiro
ac225a3b1f
Fix #11738: allow cast lints in macros
Removed the `from_expansion` guard clause for cast lints, so that these warnings can be generated for internal macros.
2024-04-03 21:43:06 +01:00
bors
e80ca2f381 Auto merge of #12615 - Kobzol:fix-recursive-clone-from, r=blyxyas
Do not suggest `assigning_clones` in `Clone` impl

This PR modifies `assigning_clones` to detect situations where the `clone` call is inside a `Clone` impl, and avoids suggesting the lint in such situations.

r? `@blyxyas`

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

changelog: Do not invoke `assigning_clones` inside `Clone` impl
2024-04-03 19:07:51 +00:00
Jakub Beránek
571118f4b0 Do not suggest assigning_clones in Clone impl 2024-04-03 20:55:34 +02:00
Francisco Salgueiro
b6486fae5c
add missing links in development guide 2024-04-03 17:07:12 +01:00
joboet
53e31dc45c rename expose_addr to expose_provenance 2024-04-03 16:00:38 +02:00
Jacob Pratt
e530b3d19c Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance

As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066).

The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".)

The new name nicely matches `ptr::without_provenance`.
2024-04-02 20:37:39 -04:00
Aneesh Kadiyala
ac18c24fe8 Use IfLetOrMatch to avoid repetition of code 2024-04-02 22:49:00 +05:30
bors
f9f854f428 Auto merge of #12617 - y21:issue-12616, r=Alexendoo
avoid an ICE in `ptr_as_ptr` when getting the def_id of a local

Fixes #12616

`Res::def_id` can panic, so avoid calling it in favor of `opt_def_id`, so we can gracefully handle resolutions that don't have a `DefId` (e.g. local variables) and get a false negative in the worst case, rather than an ICE

changelog: Fix ICE in [`ptr_as_ptr`] when the cast expression is a function call to a local variable
2024-04-02 13:40:00 +00:00
not-elm
0478d26c8b FIX(12334): manual_swap auto fix
Initialization expressions are now generated when index is bound to a variable.

FIX: Check to see if variables are used after swap

FIX:  rename StmtKind::Local to StmtKind::Let
2024-04-02 22:30:34 +09:00
y21
e575f05a8b avoid an ICE in ptr_as_ptr when getting the def_id of a local 2024-04-02 15:09:32 +02:00
bors
3b1b654f56 Auto merge of #12613 - y21:vacation, r=dswij
Pause review rotation for y21

Exams are coming up for me and I want to focus on that, so I'd like to pause PR assignments to me for a bit until that's over (will still continue to look at PRs that are assigned to me and might steal some PRs to review if I find the time). :)

--------------

changelog: none
2024-04-01 21:57:50 +00:00
bors
95c45be1ed Auto merge of #12603 - m-rph:12594, r=Manishearth
Elide unit variables linted by `let_unit` and use `()` directly instead

Situation: `let_unit` lints when an expression binds a unit (`()`) to a variable. In some cases this binding may be passed down to another function. Currently, the lint removes the binding without considering usage.

fixes: #12594

changelog: Suggestion Fix [`let_unit`]. Clippy will remove unit bindings and replace all their instances in the body with `()`.
2024-04-01 21:14:32 +00:00