summary refs log tree commit diff
path: root/src/tools/clippy/clippy_utils
AgeCommit message (Collapse)AuthorLines
2024-08-24Merge commit '0f8eabd6231366bfc1bb1464601297c2d48f8f68' into clippyupJason Newcomb-107/+140
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-1/+1
2024-08-14Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errorsbors-3/+3
Shrink `TyKind::FnPtr`. By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI. r? `@compiler-errors`
2024-08-10Fixes in various placesNadrieril-0/+1
2024-08-09Auto merge of #128703 - compiler-errors:normalizing-tails, r=lcnrbors-1/+1
Miscellaneous improvements to struct tail normalization 1. Make checks for foreign tails more accurate by normalizing the struct tail. I didn't write a test for this one. 2. Normalize when computing struct tail for `offset_of` for slice/str. This fixes the new solver only. 3. Normalizing when computing tails for disaligned reference check. This fixes both solvers. r? lcnr
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-3/+3
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-08-08Merge commit 'cb806113e0f83a8f9b47d35b453b676543bcc40e' into ↵Philipp Krones-333/+306
clippy-subtree-update
2024-08-08Rename struct_tail_erasing_lifetimes to struct_tail_for_codegenMichael Goulet-1/+1
2024-07-28step cfg(bootstrap)Mark Rousskov-1/+0
2024-07-25Merge commit '37f4fbb92913586b73a35772efd00eccd1cbbe13' into ↵Philipp Krones-27/+56
clippy-subtree-update
2024-07-16Add `ConstArgKind::Path` and make `ConstArg` its own HIR nodeNoah Lev-2/+6
This is a very large commit since a lot needs to be changed in order to make the tests pass. The salient changes are: - `ConstArgKind` gets a new `Path` variant, and all const params are now represented using it. Non-param paths still use `ConstArgKind::Anon` to prevent this change from getting too large, but they will soon use the `Path` variant too. - `ConstArg` gets a distinct `hir_id` field and its own variant in `hir::Node`. This affected many parts of the compiler that expected the parent of an `AnonConst` to be the containing context (e.g., an array repeat expression). They have been changed to check the "grandparent" where necessary. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at #127009.
2024-07-16Use `ConstArg` for array lengthsNoah Lev-9/+13
2024-07-16hir: Create `hir::ConstArgKind` enumNoah Lev-5/+17
This will allow lowering const params to a dedicated enum variant, rather than to an `AnonConst` that is later examined during `ty` lowering.
2024-07-11Merge commit 'b794b8e08c16517a941dc598bb1483e8e12a8592' into ↵Philipp Krones-35/+59
clippy-subtree-update
2024-07-08Auto merge of #127476 - jieyouxu:rollup-16wyb0b, r=jieyouxubors-1/+1
Rollup of 10 pull requests Successful merges: - #126841 ([`macro_metavar_expr_concat`] Add support for literals) - #126881 (Make `NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE` a deny-by-default lint in edition 2024) - #126921 (Give VaList its own home) - #127367 (Run alloc sync tests) - #127431 (Use field ident spans directly instead of the full field span in diagnostics on local fields) - #127437 (Uplift trait ref is knowable into `rustc_next_trait_solver`) - #127439 (Uplift elaboration into `rustc_type_ir`) - #127451 (Improve `run-make/output-type-permutations` code and improve `filename_not_in_denylist` API) - #127452 (Fix intrinsic const parameter counting with `effects`) - #127459 (rustdoc-json: add type/trait alias tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-07Add support for `mir::TerminatorKind::TailCall` in clippyMaybe Waffle-1/+2
2024-07-07iter_identity is a better nameMichael Goulet-1/+1
2024-06-28Rollup merge of #127058 - compiler-errors:tighten-async-spans, r=oli-obkMatthias Krüger-1/+1
Tighten `fn_decl_span` for async blocks Tightens the span of `async {}` blocks in diagnostics, and subsequently async closures and async fns, by actually setting the `fn_decl_span` correctly. This is kinda a follow-up on #125078, but it fixes the problem in a more general way. I think the diagnostics are significantly improved, since we no longer have a bunch of overlapping spans. I'll point out one caveat where I think the diagnostic may get a bit more confusing, but where I don't think it matters. r? ````@estebank```` or ````@oli-obk```` or someone else on wg-diag or compiler i dont really care lol
2024-06-27Tighten spans for async blocksMichael Goulet-1/+1
2024-06-27Merge commit '68a799aea9b65e2444fbecfe32217ce7d5a3604f' into ↵Philipp Krones-172/+388
clippy-subtree-update
2024-06-25RFC 2383: Stabilize `lint_reasons` in Clippy :paperclips:xFrednet-1/+1
2024-06-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-4/+4
AliasTy/AliasTerm/TraitRef/projection
2024-06-20StaticForeignItem and StaticItem are the sameMichael Goulet-2/+2
2024-06-19Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`sTrevor Gross-6/+41
This removes the ICE codepaths for `f16` and `f128` in Clippy. `rustc_apfloat` is used as a dependency for the parsing of these types, since their `FromStr` implementation will not be available in the standard library for a while.
2024-06-17Fix other toolsMichael Goulet-4/+1
2024-06-13Merge commit '3e5a02b13b1244545454752c6629b767522a44b1' into ↵Philipp Krones-42/+158
clippy-subtree-update
2024-06-10ScalarInt: size mismatches are a bug, do not delay the panicRalf Jung-19/+5
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-6/+6
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-06Auto merge of #126068 - lqd:revert-124976, r=petrochenkovbors-1/+1
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by #124976 than will be fixed by #125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes https://github.com/rust-lang/rust/issues/125474 fixes https://github.com/rust-lang/rust/issues/125484 fixes https://github.com/rust-lang/rust/issues/125646 fixes https://github.com/rust-lang/rust/issues/125707 fixes #126066 fixes #125934 fixes https://github.com/rust-lang/rust/issues/126021 r? `@petrochenkov` `@bors` p=1
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-1/+1
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-2/+6
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-05Misc fixes to cranelift/clippy/miriBoxy-2/+2
2024-06-04Add safe/unsafe to static inside extern blocksSantiago Pastorino-1/+3
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-1/+3
2024-06-03Align Term methods with GenericArg methodsMichael Goulet-3/+3
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-7/+7
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-7/+7
2024-05-30Merge commit 'c9139bd546d9cd69df817faeab62c5f9b1a51337' into ↵Philipp Krones-8/+28
clippy-subtree-update
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-5/+5
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-6/+12
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-24clippy: unnest check_constsJubilee Young-1/+1
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-6/+12
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-22rustc: Use `tcx.used_crates(())` moreVadim Petrochenkov-1/+1
And explain when it should be used.
2024-05-21Merge commit '2efebd2f0c03dabbe5c3ad7b4ebfbd99238d1fb2' into ↵Philipp Krones-100/+108
clippy-subtree-update
2024-05-20Rollup merge of #125173 - scottmcm:never-checked, r=davidtwcoMatthias Krüger-3/+3
Remove `Rvalue::CheckedBinaryOp` Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996> cc `@RalfJung` While it's a draft, r? ghost
2024-05-19Add and use generics.is_empty() and generics.is_own_empty, rather than using ↵Santiago Pastorino-1/+1
generics' attributes
2024-05-18Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726bors-22/+21
Rename Unsafe to Safety Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks. This leaves us today with: ```rust enum ast::Safety { Unsafe(Span), Default, // Safe (going to be added for unsafe extern blocks) } enum hir::Safety { Unsafe, Safe, } ``` We would convert from `ast::Safety::Default` into the right Safety level according the context.
2024-05-17Fix clippyScott McMurray-3/+3
2024-05-17Rename Unsafe to SafetySantiago Pastorino-22/+21
2024-05-16Remove trivial Binder::dummy callsMichael Goulet-1/+1