about summary refs log tree commit diff
path: root/src/tools/clippy/clippy_utils
AgeCommit message (Collapse)AuthorLines
2025-10-02Auto merge of #147138 - jackh726:split-canonical-bound, r=lcnrbors-2/+2
Split Bound index into Canonical and Bound See [#t-types/trait-system-refactor > perf `async-closures/post-mono-higher-ranked-hang.rs`](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/perf.20.60async-closures.2Fpost-mono-higher-ranked-hang.2Ers.60/with/541535613) for context Things compile and tests pass, but not sure if this actually solves the perf issue (edit: it does). Opening up this to do a perf (and maybe crater) run. r? lcnr
2025-09-30Split Bound into Canonical and Boundjackh726-2/+2
2025-09-26castkind::subtype in clippybeepster4096-2/+2
2025-09-18Merge commit '20ce69b9a63bcd2756cd906fe0964d1e901e042a' into ↵Philipp Krones-79/+198
clippy-subtree-update
2025-09-18Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmannStuart Cook-3/+3
Clean up `ty::Dynamic` 1. As a follow-up to PR rust-lang/rust#143036, remove `DynKind` entirely. 2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait` * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types * `lint` contained dyn-Trait-specific diagnostics+lints only
2025-09-17Remove `DynKind`León Orell Valerian Liehr-3/+3
2025-09-16Remove Rvalue::Len.Camille Gillot-1/+1
2025-09-13Auto merge of #145186 - camsteffen:assoc-impl-kind, r=petrochenkovbors-18/+18
Make `AssocItem` aware of its impl kind The general goal is to have fewer query dependencies by making `AssocItem` aware of its parent impl kind (inherent vs. trait) without having to query the parent def_kind. See individual commits.
2025-09-13Rollup merge of #146389 - jdonszelmann:no-std, r=oli-obkJana Dönszelmann-8/+2
Convert `no_std` and `no_core` to the new attribute infrastructure r? ```@oli-obk``` Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-1/+1
2025-09-12Introduce hir::ImplItemImplKindCameron Steffen-16/+16
2025-09-12Rename AssocItemContainer -> AssocContainerCameron Steffen-2/+2
2025-09-10fixup no_{core,std} handling codeJana Dönszelmann-8/+2
2025-09-10Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhprattMatthias Krüger-1/+0
inclusive `Range`s: change `end` to `last` Tracking issue: rust-lang/rust#125687 ACP: rust-lang/libs-team#511
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-1/+1
2025-09-08change end to lastJeremy Smart-1/+0
2025-09-04Merge commit 'e9b70454e4c9584be3b22ddabd26b741aeb06c10' into ↵Philipp Krones-41/+64
clippy-subtree-update
2025-08-25add span to struct pattern rest (..)Valdemar Erk-1/+1
2025-08-22Merge commit '877967959ae8da9814df4f2614971f4d784bf53f' into ↵Philipp Krones-57/+91
clippy-subtree-update
2025-08-19Prevent impossible combinations in `ast::ModKind`.Nicholas Nethercote-1/+1
`ModKind::Loaded` has an `inline` field and a `had_parse_error` field. If the `inline` field is `Inline::Yes` then `had_parse_error` must be `Ok(())`. This commit moves the `had_parse_error` field into the `Inline::No` variant. This makes it impossible to create the nonsensical combination of `inline == Inline::Yes` and `had_parse_error = Err(_)`.
2025-08-16Auto merge of #145304 - m-ou-se:simplify-panic, r=oli-obkbors-9/+1
Revert "Partially outline code inside the panic! macro". This reverts https://github.com/rust-lang/rust/pull/115670 Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect. (And if it did, whether that effect is still achieved today.)
2025-08-12Revert "Partially outline code inside the panic! macro".Mara Bos-9/+1
Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect at all. (And if it did, whether that effect is still achieved today.)
2025-08-11Propagate TraitImplHeader to hirCameron Steffen-5/+7
2025-08-11Extract ast TraitImplHeaderCameron Steffen-16/+10
2025-08-09remove `P`Deadbeef-5/+4
2025-08-07Merge commit '334fb906aef13d20050987b13448f37391bb97a2' into ↵Philipp Krones-94/+176
clippy-subtree-update
2025-07-31Rollup merge of #144726 - jdonszelmann:move-attr-data-structures, r=lcnrJana Dönszelmann-7/+9
merge rustc_attr_data_structures into rustc_hir this move was discussed on zulip: [#t-compiler > attribute parsing rework @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20parsing.20rework/near/528530091) Many PRs in the attribute rework depend on this move.
2025-07-31Rollup merge of #144712 - nnethercote:dedup-num-types, r=fmeaseJana Dönszelmann-5/+5
Deduplicate `IntTy`/`UintTy`/`FloatTy`. There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed. r? `@fmease`
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-7/+9
2025-07-31Deduplicate `IntTy`/`UintTy`/`FloatTy`.Nicholas Nethercote-5/+5
There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed. The one annoying wrinkle is that the old version had differences in their `Debug` impls, e.g. one printed `u32` while the other printed `U32`. Some compiler error messages rely on the former (yuk), and some clippy output depends on the latter. So the commit also changes clippy to not rely on `Debug` and just implement what it needs itself.
2025-07-31Remove `TyCtxt::get_attrs_unchecked`.Nicholas Nethercote-1/+1
It's identical to `TyCtxt::get_all_attrs` except it takes `DefId` instead of `impl Into<DefIf>`.
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-3/+3
2025-07-28Rename trait_of_item -> trait_of_assocCameron Steffen-3/+3
2025-07-25Merge commit '1db89a1b1ca87f24bf22d0bad21d14b2d81b3e99' into ↵Philipp Krones-43/+148
clippy-subtree-update
2025-07-17Include ErrorGuaranteed in StableSince::Err.Camille GILLOT-1/+1
2025-07-17parse `const trait Trait`Deadbeef-3/+6
2025-07-17Improve path segment joining.Nicholas Nethercote-8/+9
There are many places that join path segments with `::` to produce a string. A lot of these use `join("::")`. Many in rustdoc use `join_with_double_colon`, and a few use `.joined("..")`. One in Clippy uses `itertools::join`. A couple of them look for `kw::PathRoot` in the first segment, which can be important. This commit introduces `rustc_ast::join_path_{syms,ident}` to do the joining for everyone. `rustc_ast` is as good a location for these as any, being the earliest-running of the several crates with a `Path` type. Two functions are needed because `Ident` printing is more complex than simple `Symbol` printing. The commit also removes `join_with_double_colon`, and `estimate_item_path_byte_length` with it. There are still a handful of places that join strings with "::" that are unchanged. They are not that important: some of them are in tests, and some of them first split a path around "::" and then rejoin with "::". This fixes one test case where `{{root}}` shows up in an error message.
2025-07-14Auto merge of #143745 - flip1995:clippy-subtree-update, r=Manishearthbors-23/+149
Clippy subtree update r? `@Manishearth` Cargo.lock update due to `ui_test` bump and restructure.
2025-07-14Auto merge of #143779 - JonathanBrouwer:automatically_derived_parser, r=oli-obkbors-2/+2
Port `#[automatically_derived]` to the new attribute parsing infrastructure Ports `#[automatically_derived]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163 r? `@oli-obk` cc `@jdonszelmann`
2025-07-13Retire hir::*ItemRef.Camille GILLOT-17/+11
2025-07-13Auto merge of #143213 - dianne:lower-cond-tweaks, r=cjgillotbors-30/+19
de-duplicate condition scoping logic between AST→HIR lowering and `ScopeTree` construction There was some overlap between `rustc_ast_lowering::LoweringContext::lower_cond` and `rustc_hir_analysis::check::region::resolve_expr`, so I've removed the former and migrated its logic to the latter, with some simplifications. Consequences: - For `while` and `if` expressions' `let`-chains, this changes the `HirId`s for the `&&`s to properly correspond to their AST nodes. This is how guards were handled already. - This makes match guards share previously-duplicated logic with `if`/`while` expressions. This will also be used by guard pattern[^1] guards. - Aside from legacy syntax extensions (e.g. some builtin macros) that directly feed AST to the compiler, it's currently impossible to put attributes directly on `&&` operators in `let` chains[^2]. Nonetheless, attributes on `&&` operators in `let` chains in `if`/`while` expression conditions are no longer silently ignored and will be lowered. - This no longer wraps conditions in `DropTemps`, so the HIR and THIR will be slightly smaller. - `DesugaringKind::CondTemporary` is now gone. It's no longer applied to any spans, and all uses of it were dead since they were made to account for `if` and `while` being desugared to `match` on a boolean scrutinee. - Should be a marginal perf improvement beyond that due to leveraging [`ScopeTree` construction](https://github.com/rust-lang/rust/blob/5e749eb66f93ee998145399fbdde337e57cd72ef/compiler/rustc_hir_analysis/src/check/region.rs#L312-L355)'s clever handling of `&&` and `||`: - This removes some unnecessary terminating scopes that were placed around top-level `&&` and `||` operators in conditions. When lowered to MIR, logical operator chains don't create intermediate boolean temporaries, so there's no temporary to drop. The linked snippet handles wrapping the operands in terminating scopes as necessary, in case they create temporaries. - The linked snippet takes care of letting `let` temporaries live and terminating other operands, so we don't need separate traversals of `&&` chains for that. [^1]: rust-lang/rust#129967 [^2]: Case-by-case, here's my justification: `#[attr] e1 && e2` applies the attribute to `e1`. In `#[attr] (e1 && e2)` , the attribute is on the parentheses in the AST, plus it'd fail to parse if `e1` or `e2` contains a `let`. In `#[attr] expands_to_let_chain!()`, the attribute would already be ignored (rust-lang/rust#63221) and it'd fail to parse anyway; even if the expansion site is a condition, the expansion wouldn't be parsed with `Restrictions::ALLOW_LET`. If it *was* allowed, the notion of a "reparse context" from https://github.com/rust-lang/rust/issues/61733#issuecomment-509626449 would be necessary in order to make `let`-chains left-associative; multiple places in the compiler assume they are.
2025-07-12Fix clippy & rustdoc-jsonJonathan Brouwer-2/+2
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-11Rollup merge of #143708 - epage:pretty, r=compiler-errorsMatthias Krüger-16/+13
fix: Include frontmatter in -Zunpretty output In the implementation (rust-lang/rust#140035), this was left as an open question for the tracking issue (rust-lang/rust#136889). My assumption is that this should be carried over. The test was carried over from rust-lang/rust#137193 which was superseded by rust-lang/rust#140035. Thankfully, either way, `-Zunpretty` is unstable and we can always change it even if we stabilize frontmatter.
2025-07-10Merge commit 'cdbbf3afda0b1bf51568b368f629b1d828507f98' into ↵Philipp Krones-29/+151
clippy-subtree-update
2025-07-10Remove uncessary parens in closure body with unused lintyukang-2/+2
2025-07-09feat(lexer): Allow including frontmatter with 'tokenize'Ed Page-16/+13
2025-07-07Account for const stability in clippy when checking constnessEsteban Küber-2/+4
2025-07-07Auto merge of #143182 - xdoardo:more-addrspace, r=workingjubileebors-1/+1
Allow custom default address spaces and parse `p-` specifications in the datalayout string Some targets, such as CHERI, use as default an address space different from the "normal" default address space `0` (in the case of CHERI, [200 is used](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-877.pdf)). Currently, `rustc` does not allow to specify custom address spaces and does not take into consideration [`p-` specifications in the datalayout string](https://llvm.org/docs/LangRef.html#langref-datalayout). This patch tries to mitigate these problems by allowing targets to define a custom default address space (while keeping the default value to address space `0`) and adding the code to parse the `p-` specifications in `rustc_abi`. The main changes are that `TargetDataLayout` now uses functions to refer to pointer-related informations, instead of having specific fields for the size and alignment of pointers in the default address space; furthermore, the two `pointer_size` and `pointer_align` fields in `TargetDataLayout` are replaced with an `FxHashMap` that holds info for all the possible address spaces, as parsed by the `p-` specifications. The potential performance drawbacks of not having ad-hoc fields for the default address space will be tested in this PR's CI run. r? workingjubilee
2025-07-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-1/+1
default data address space
2025-07-07Rollup merge of #143544 - workingjubilee:rename-bare-fn, r=fmeaseJacob Pratt-13/+13
compiler: rename BareFn to FnPtr At some point "BareFn" was the chosen name for a "bare" function, without the niceties of `~fn`, `&fn`, or a few other ways of writing a function type. However, at some point the syntax for a "bare function" and any other function diverged even more. We started calling them what they are: function pointers, denoted by their own syntax. However, we never changed the *internal* name for these, as this divergence was very gradual. Personally, I have repeatedly searched for "FnPtr" and gotten confused until I find the name is BareFn, only to forget this until the next time, since I don't routinely interact with the higher-level AST and HIR. But even tools that interact with these internal types only touch on them in a few places, making a migration easy enough. Let's use a more intuitive and obvious name, as this 12+ year old name has little to do with current Rust.