Commit graph

11277 commits

Author SHA1 Message Date
J-ZhengLi
666e2f2868 fix [large_stack_arrays] linting in vec macro & add matching_root_macro_call function in clippy_utils 2024-04-17 11:31:41 +08:00
Guillaume Gomez
c4f14ed785 Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkin
Move `SourceMap` initialization

So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward.

r? `@WaffleLapkin`
2024-04-16 21:41:23 +02:00
Nicholas Nethercote
0aea3edb38 Avoid lots of hir::HirId{,Map,Set} qualifiers.
Because they're a bit redundant.
2024-04-16 16:29:15 +10:00
Nicholas Nethercote
c0bc812227 Always use ty:: qualifier for TyKind enum variants.
Because that's the way it should be done.
2024-04-16 16:29:13 +10:00
Nicholas Nethercote
b64c5f991c Avoid unnecessary rustc_span::DUMMY_SP usage.
In some cases `DUMMY_SP` is already imported. In other cases this commit
adds the necessary import, in files where `DUMMY_SP` is used more than
once.
2024-04-16 15:55:24 +10:00
Nicholas Nethercote
3e11360497 Construct SourceMap at the same time as SessionGlobals.
Currently `SourceMap` is constructed slightly later than
`SessionGlobals`, and inserted. This commit changes things so they are
done at the same time.

Benefits:
- `SessionGlobals::source_map` changes from
  `Lock<Option<Lrc<SourceMap>>>` to `Option<Lrc<SourceMap>>`. It's still
  optional, but mutability isn't required because it's initialized at
  construction.
- `set_source_map` is removed, simplifying `run_compiler`, which is
  good because that's a critical function and it's nice to make it
  simpler.

This requires moving things around a bit, so the necessary inputs are
available when `SessionGlobals` is created, in particular the `loader`
and `hash_kind`, which are no longer computed by `build_session`. These
inputs are captured by the new `SourceMapInputs` type, which is threaded
through various places.
2024-04-16 13:02:53 +10:00
León Orell Valerian Liehr
ac174ae8d2 Rollup merge of #123926 - compiler-errors:no-ann, r=estebank
Fix pretty HIR for anon consts in diagnostics

This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`.

There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh.

r? estebank
2024-04-16 01:12:38 +02:00
León Orell Valerian Liehr
b3a82d8f9e Rollup merge of #123462 - fmease:rn-mod-sep-to-path-sep, r=nnethercote
Cleanup: Rename `ModSep` to `PathSep`

`::` is usually referred to as the *path separator* (citation needed).

The existing name `ModSep` for *module separator* is a bit misleading since it in fact separates the segments of arbitrary path segments, not only ones resolving to modules. Let me just give a shout-out to associated items (`T::Assoc`, `<Ty as Trait>::function`) and enum variants (`Option::None`).

Motivation: Reduce friction for new contributors, prevent potential confusion.

cc `@petrochenkov`
r? nnethercote or compiler
2024-04-16 01:12:37 +02:00
Michael Goulet
1703109ba0 Fix clippy 2024-04-15 18:48:12 -04:00
Luv-Ray
da0ae33c15 [ptr_as_ptr]: Fix duplicate errors 2024-04-15 18:06:15 +02:00
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
Matthias Krüger
2e989dc280 Rollup merge of #123204 - notriddle:notriddle/include-str-span, r=pnkfelix
rustdoc: point at span in `include_str!`-ed md file

Fixes #118549
2024-04-12 17:41:32 +02:00
Andre Bogus
54de78a212 downgrade to pedantic 2024-04-11 22:24:47 +02:00
Andre Bogus
58c53e8ea9 reduce single_char_pattern to only lint on ascii chars 2024-04-11 18:09:55 +02: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
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
Michael Goulet
d13ccf3392 Add a helper for extending a span to include any trailing whitespace 2024-04-09 14:06:09 -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
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
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
fa2db5a60b Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors
Implement minimal, internal-only pattern types in the type system

rebase of https://github.com/rust-lang/rust/pull/107606

You can create pattern types with `std::pat::pattern_type!(ty is pat)`. The feature is incomplete and will panic on you if you use any pattern other than integral range patterns. The only way to create or deconstruct a pattern type is via `transmute`.

This PR's implementation differs from the MCP's text. Specifically

> This means you could implement different traits for different pattern types with the same base type. Thus, we just forbid implementing any traits for pattern types.

is violated in this PR. The reason is that we do need impls after all in order to make them usable as fields. constants of type `std::time::Nanoseconds` struct are used in patterns, so the type must be structural-eq, which it only can be if you derive several traits on it. It doesn't need to be structural-eq recursively, so we can just manually implement the relevant traits on the pattern type and use the pattern type as a private field.

Waiting on:

* [x] move all unrelated commits into their own PRs.
* [x] fix niche computation (see 2db07f94f44f078daffe5823680d07d4fded883f)
* [x] add lots more tests
* [x] T-types MCP https://github.com/rust-lang/types-team/issues/126 to finish
* [x] some commit cleanup
* [x] full self-review
* [x] remove 61bd325da19a918cc3e02bbbdce97281a389c648, it's not necessary anymore I think.
* [ ] ~~make sure we never accidentally leak pattern types to user code (add stability checks or feature gate checks and appopriate tests)~~ we don't even do this for the new float primitives
* [x] get approval that [the scope expansion to trait impls](https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/Pattern.20types.20types-team.23126/near/427670099) is ok

r? `@BoxyUwU`
2024-04-08 16:25:23 +00:00
Matthias Krüger
ce82fa494d Rollup merge of #123625 - oli-obk:private_fnctxt, r=fee1-dead
Stop exporting `TypeckRootCtxt` and `FnCtxt`.

While they have many convenient APIs, it is better to expose dedicated functions for them

noticed in #122213
2024-04-08 14:31:12 +02:00
Matthias Krüger
4daaf19138 Rollup merge of #122807 - danielhuang:fix-1, r=davidtwco
Add consistency with phrases "meantime" and "mean time"

"mean time" is used in a few places while "meantime" is used everywhere else; this would make usage consistent throughout the codebase.
2024-04-08 14:31:10 +02:00
Oli Scherer
c8388033f3 Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
Oli Scherer
89b48a2e22 Thread pattern types through the HIR 2024-04-08 12:00:07 +00:00
Oli Scherer
02b5e1a159 Stop exporting TypeckRootCtxt and FnCtxt.
While they have many convenient APIs, it is better to expose dedicated functions for them
2024-04-08 11:59:13 +00: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
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
y21
71e02a01a1 use Lrc instead of the aliased type Arc directly 2024-04-05 00:17:27 +02: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
Philipp Krones
0ae4a048c6 Merge commit '9725c4a162502a02c1c67fdca6b797fe09b2b73c' into clippy-subtree-update 2024-04-04 19:52:55 +02:00
Philipp Krones
277303b210
Merge remote-tracking branch 'upstream/master' into rustup 2024-04-04 19:48:31 +02:00
León Orell Valerian Liehr
a1e76af295 Rename ModSep to PathSep 2024-04-04 19:44:04 +02: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
Dan
ca92c0a7a4 update messages 2024-04-03 19:03:12 -04: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
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
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
Yuxiang Qiu
b89fa5364f
fix: fix ci errors 2024-04-01 16:59:46 -04:00
Yuxiang Qiu
9d1f824878
fix: check if receiver's hir_id matches expr's hir_id 2024-04-01 16:57:31 -04:00
Yuxiang Qiu
b2ea5eef44
fix: incorrect suggestions when .then and .then_some is used 2024-04-01 16:57:31 -04:00
J-ZhengLi
b456ed31e4 fix suggestion for [len_zero] with macros 2024-04-02 01:27:17 +08:00
Aneesh Kadiyala
6a6a917fe4 Check for Default trait in initial expression 2024-04-01 20:18:03 +05:30
Alex Macleod
9d4a36841a Reword arc_with_non_send_sync note and help messages 2024-04-01 13:18:27 +00:00
y21
91f514cc83 fix fallout from previous commit 2024-04-01 15:04:45 +02:00
Quinn Sinclair
eee4db928f Replace elided variable in let_unit with () when used
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.

Change: All usages of the elided variable are now replaced with `()`.

fixes: #12594
2024-04-01 13:40:36 +02:00
Alex Macleod
0f63fa8c33 Move box_default to style, do not suggest turbofishes
`Box::default()` had its `#[rustc_box]` attribute removed in 1.69 so is
no longer a perf related lint

The lint is moved to style but no longer produces suggestions containing
turbofishes, as they're often longer/more annoying to type
2024-03-31 16:46:44 +00:00
bors
797d50dfe6 Auto merge of #12562 - m-rph:12501, r=y21
Allow `filter_map_identity` when the closure is typed

This extends the `filter_map_identity` lint to support typed closures.

For untyped closures, we know that the program compiles, and therefore we can safely suggest using flatten.

For typed closures, they may participate in type resolution. In this case we use `Applicability::MaybeIncorrect`.

Details:
https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Should.20.60filter_map_identity.60.20lint.20when.20closures.20are.20typed.3F

changelog: `filter_map_identity` will now suggest using flatten for typed closures.

r? `@y21` && `@Centri3`
2024-03-31 12:16:01 +00:00
bors
3787a0ccb8 Auto merge of #11350 - y21:issue11349, r=xFrednet
[`type_id_on_box`]: lint on any `Box<dyn _>`

Closes #11349.

It now not only lints when calling `.type_id()` on the type `Box<dyn Any>`, but also on any `Box<dyn Trait>` where `Trait` is a subtrait of `Any`

changelog: FN: [`type_id_on_box`]: lint if `Any` is a sub trait
2024-03-30 21:26:36 +00:00
y21
36e4c2083b lint on any Box<dyn _>, but provide a suggestion for subtypes of dyn Any 2024-03-30 20:52:53 +01:00
bors
cebf879de8 Auto merge of #12312 - pitaj:legacy_numeric_constants, r=xFrednet
new lint `legacy_numeric_constants`

Rework of #10997

- uses diagnostic items
- does not lint imports of the float modules (`use std::f32`)
- does not lint usage of float constants that look like `f32::MIN`

I chose to make the float changes because the following pattern is actually pretty useful
```rust
use std::f32;
let omega = freq * 2 * f32::consts::PI;
```
and the float modules are not TBD-deprecated like the integer modules.

Closes #10995

---

changelog: New lint [`legacy_numeric_constants`]
[#12312](https://github.com/rust-lang/rust-clippy/pull/12312)
2024-03-30 17:50:36 +00:00
bors
e0e7ee183f Auto merge of #12563 - J-ZhengLi:issue11513, r=Alexendoo
make sure checked type implements `Try` trait when linting [`question_mark`]

(indirectly) fixes: #12412 and fixes: #11983

---

changelog: make sure checked type implements `Try` trait when linting [`question_mark`]
2024-03-30 13:21:20 +00:00
bors
88d842ed29 Auto merge of #12579 - J-ZhengLi:issue12569, r=Alexendoo
fix [`manual_unwrap_or_default`] suggestion ignoring side-effects

fixes: #12569
closes: #12580

change applicability to `MaybeIncorrect` base on suggestion in [this zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60manual_unwrap_or_default.60.20suggestion.20removes.20comments)

---

changelog: fix [`manual_unwrap_or_default`] suggestion ignoring side-effects, and adjust its applicability.
2024-03-30 12:32:38 +00:00
J-ZhengLi
5750e4670b fix [manual_unwrap_or_default] suggestion ignoring side-effects 2024-03-30 09:18:53 +08:00
y21
37be3e4dd5 [type_id_on_box]: lint of Any subtraits 2024-03-30 01:16:41 +01:00
Michael Howell
24e1071d21 clippy: fix up include_str! spans in diagnostics 2024-03-29 13:34:01 -07:00
bors
971e4355b9 Auto merge of #12543 - Xaeroxe:manual-clamp-const, r=xFrednet,GuillaumeGomez
restrict manual_clamp to const case, bring it out of nursery

Implements the plan that I described in https://github.com/rust-lang/rust-clippy/pull/9484#issuecomment-1374522054

This does two things primarily

1. Restrict `manual_clamp` such that it will only trigger if we are able to guarantee that `clamp` won't panic at runtime.
2. Bring `manual_clamp` out of nursery status and move it into the complexity group.

changelog: [`manual_clamp`]: Restrict this lint such that it only triggers if max and min are const, and max is greater than or equal to min. Then bring it out of the nursery group.
2024-03-29 19:34:44 +00:00
bors
d928657d9d Auto merge of #12587 - shandongbinzhou:master, r=Jarcho
Fix typo in comment

Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change.

It's also helpful for us that the lint name is put within backticks (`` ` ` ``),
and then encapsulated by square brackets (`[]`), for example:
```
changelog: [`lint_name`]: your change
```

If your PR fixes an issue, you can add `fixes #issue_number` into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[x] Followed [lint naming conventions][lint_naming]
- \[ ] Added passing UI tests (including committed `.stderr` file)
- \[ ] `cargo test` passes locally
- \[ ] Executed `cargo dev update_lints`
- \[ ] Added lint documentation
- \[x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR.

---

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

changelog: None
2024-03-29 19:24:01 +00:00
Jacob Kiesel
89588f41f8 Add limitations section, move check 2024-03-29 09:38:59 -06:00
shandongbinzhou
7aac504e41 Fix typo in comment
Signed-off-by: shandongbinzhou <shandongbinzhou@outlook.com>
2024-03-29 16:17:07 +08:00
Kevin Reid
01646457a9 large_stack_frames: print total size and largest component.
Instead of just saying “this function's stack frame is big”, report:

* the (presumed) size of the frame
* the size and type of the largest local contributing to that size
* the configurable limit that was exceeded (once)
2024-03-28 11:00:42 -07:00
bors
124e68bef8 Auto merge of #12570 - J-ZhengLi:issue12569, r=Jarcho
allow [`manual_unwrap_or_default`] in const function

closes: #12568

---

changelog: allow [`manual_unwrap_or_default`] in const function

This is a small fix, I was originally decided to fix it along with `#12568` but there are some problems needs to be addressed (which is why my branch is called `issue12569` 😆 ), so I decide to open a separated PR to fix them one at a time.
2024-03-28 02:00:07 +00:00
Jules Bertholet
11b28d44bd Implement mut ref/mut ref mut 2024-03-27 09:53:23 -04:00
bors
014230ce16 Auto merge of #12572 - y21:mixed_attributes_style_style, r=llogiq
Move `mixed_attributes_style` to style

> It currently is in suspicious. I wouldn't say that the linted code is "most likely wrong or useless"
[...]
> 😅 I would still argue that this doesn't belong in the suspicious group, but rather in the style group.

These are some good points made [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/mixed_attributes_style.20on.20outlined.20modules/near/429823328).

----

changelog: Move [`mixed_attributes_style`] to the `style` category
2024-03-27 13:25:54 +00:00
y21
5b95e9099c move mixed_attributes_style to the style category 2024-03-27 13:06:32 +01:00
J-ZhengLi
c27f52d611 allow [manual_unwrap_or_default] in const function 2024-03-27 16:28:15 +08:00
J-ZhengLi
91f3fad8e7 check for init expr when linting [question_mark] 2024-03-27 08:36:08 +08:00
Matthias Krüger
4b10cb20bc Rollup merge of #123103 - compiler-errors:inherited-is-a-weird-name, r=oli-obk
Rename `Inherited` -> `TypeckRootCtxt`

`Inherited` is a confusing name. Rename it to `TypeckRootCtxt`.

I don't think this needs a type MCP or anything since it's not nearly as pervasive as `FnCtxt` , for example.

r? `@lcnr` `@oli-obk`
2024-03-26 21:23:51 +01:00
Michael Goulet
a6a1f782d6 Inherited -> TypeckRootCtxt 2024-03-26 15:22:46 -04:00
Quinn Sinclair
60937bf2db :adjust applicability for typed identity closures in filter_map_identity 2024-03-26 18:59:57 +01:00
Trevor Gross
57627d254d Change f16 and f128 clippy stubs to be nonpanicking
It turns out there is a bit of a circular dependency - I cannot add
anything to `core` because Clippy fails, and I can't actually add
correct Clippy implementations without new implementations from `core`.

Change some of the Clippy stubs from `unimplemented!` to success values
and leave a FIXME in their place to mitigate this.

Fixes <https://github.com/rust-lang/rust/issues/122587>
2024-03-26 13:37:00 -04:00
Jacob Kiesel
4d7d66462f the power of if let chain compels you 2024-03-26 10:53:41 -06:00
Jacob Kiesel
aecdb921ae short circuit logic better 2024-03-26 10:45:27 -06:00
bors
b8b9b27500 Auto merge of #12555 - GuillaumeGomez:duplicated_attribute, r=blyxyas
Don't emit `duplicated_attribute` lint on "complex" `cfg`s

Part of #12537.

changelog: Don't emit `duplicated_attribute` lint on "complex" `cfg`s
2024-03-26 15:12:23 +00:00
Guillaume Gomez
e3f3a4b7dc Don't emit duplicated_attribute lint on "complex" cfgs 2024-03-26 14:28:32 +01:00
Quinn Sinclair
9655231eb8 Allow filter_map_identity when the closure is typed
This extends the `filter_map_identity` lint to support typed closures.

For untyped closures, we know that the program compiles, and therefore
we can safely suggest using flatten.

For typed closures, they may participate in type resolution. In this case
we use `Applicability::MaybeIncorrect`.

Details:
https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Should.20.60filter_map_identity.60.20lint.20when.20closures.20are.20typed.3F
2024-03-25 23:40:30 +01:00
bors
ca6a647490 Auto merge of #12554 - Kobzol:assigning-clones-unspecified, r=blyxyas
Change applicability of `assigning_clones` to `Unspecified`

Before we deal with https://github.com/rust-lang/rust-clippy/pull/12473 and the borrow checker errors, I think that it would be better to downgrade this lint, since it can break code.

changelog: Change the applicability of `assigning_clones` to `Unspecified`

r? `@blyxyas`
2024-03-25 21:39:32 +00:00
bors
b1b7352880 Auto merge of #12536 - samueltardieu:issue-12505, r=Manishearth
`manual_assert`: do not add extra semicolon

Fixes #12505

changelog: [`manual_assert`]: do not add extra semicolon to suggestion
2024-03-25 20:07:54 +00:00
y21
9e82ad87b9 [let_and_return]: avoid linting when #[cfg] attributes are present 2024-03-25 17:48:05 +00:00
bors
c3948d16b9 Auto merge of #12549 - granddaifuku:fix/suspicious_else_formatting-false-positive-when-commented-else, r=Alexendoo
fix: `suspicious_else_formatting` false positive when else is included …

This PR addresses an issue where invalid suggestions are generated for `if-else` formatting if comments contain the keyword `else`.

The root of the problem is identified [here](95c62ffae9/clippy_lints/src/formatting.rs (L217)). Specifically, when a comment contains the word `else`, the lint mistakenly interprets it as part of an `if-else` clause. This misinterpretation leads to an incorrect splitting of the snippet, resulting in erroneous suggestions.

fixes: #12497

changelog: [`suspicious_else_formatting`]: Fixes invalid suggestions when comments include word else
2024-03-25 16:51:43 +00:00
Stanislav Tkach
e0b6f30397
Remove unnecessary dot in the 'unconditional recursion' lint description 2024-03-25 17:10:26 +01:00