summary refs log tree commit diff
path: root/src/tools/clippy/clippy_utils
AgeCommit message (Collapse)AuthorLines
2024-10-10Auto merge of #13464 - y21:issue13458, r=flip1995bors-54/+81
Don't warn on proc macro generated code in `needless_return` Fixes #13458 Fixes #13457 Fixes #13467 Fixes #13479 Fixes #13481 Fixes #13526 Fixes #13486 The fix is unfortunately a little more convoluted than just simply adding a `is_from_proc_macro`. That check *does* fix the issue, however it also introduces a bunch of false negatives in the tests, specifically when the returned expression is in a different syntax context, e.g. `return format!(..)`. The proc macro check builds up a start and end pattern based on the HIR nodes and compares it to a snippet of the span, however that would currently fail for `return format!(..)` because we would have the patterns `("return", <something inside of the format macro>)`, which doesn't compare equal. So we now return an empty string pattern for when it's in a different syntax context. "Hide whitespace" helps a bit for reviewing the proc macro detection change changelog: none
2024-10-07Avoid another `&Lrc<..>` in a return value.Nicholas Nethercote-0/+1
2024-10-05Auto merge of #129244 - cjgillot:opaque-hir, r=compiler-errorsbors-1/+1
Make opaque types regular HIR nodes Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead. I haven't gone through all the test changes yet, so there may be a few surprises. Many thanks to `@camelid` for the first draft. Fixes https://github.com/rust-lang/rust/issues/129023 Fixes #129099 Fixes #125843 Fixes #119716 Fixes #121422
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-1/+1
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-10-04Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnayJubilee-1/+0
Stabilize the `map`/`value` methods on `ControlFlow` And fix the stability attribute on the `pub use` in `core::ops`. libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP. Summary: ```rust impl<B, C> ControlFlow<B, C> { pub fn break_value(self) -> Option<B>; pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>; pub fn continue_value(self) -> Option<C>; pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>; } ``` Resolves #75744 ``@rustbot`` label +needs-fcp +t-libs-api -t-libs --- Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.
2024-10-03Rollup merge of #131183 - compiler-errors:opaque-ty-origin, r=estebankMatthias Krüger-2/+1
Refactoring to `OpaqueTyOrigin` Pulled out of a larger PR that uses these changes to do cross-crate encoding of opaque origin, so we can use them for edition 2024 migrations. These changes should be self-explanatory on their own, tho 😄
2024-10-03Merge commit 'aa0d551351a9c15d8a95fdb3e2946b505893dda8' into ↵Philipp Krones-82/+119
clippy-subtree-update
2024-10-02Remove redundant in_trait from hir::TyKind::OpaqueDefMichael Goulet-2/+1
2024-10-01make InterpResult a dedicated type to avoid accidentally discarding the errorRalf Jung-5/+5
2024-09-25Remove the `control_flow_enum` feature from clippyScott McMurray-1/+0
2024-09-25Auto merge of #130778 - flip1995:clippy-subtree-update, r=Manishearthbors-188/+144
Clippy subtree update r? `@Manishearth` Really delayed sync (2 1/2 weeks), because of a `debug_assertion` we hit, and I didn't have the time to investigate earlier. It would be nice to merge this PR with some priority, as it includes a lot of formatting changes due to the rustfmt bump. Include Cargo.lock update due to Clippy version bump and ui_test bump in Clippy.
2024-09-24Rollup merge of #130764 - compiler-errors:inherent, r=estebankTrevor Gross-7/+3
Separate collection of crate-local inherent impls from error tracking #119895 changed the return type of the `crate_inherent_impls` query from `CrateInherentImpls` to `Result<CrateInherentImpls, ErrorGuaranteed>` to avoid needing to use the non-parallel-friendly `track_errors()` to track if an error was reporting from within the query... This was mostly fine until #121113, which stopped halting compilation when we hit an `Err(ErrorGuaranteed)` in the `crate_inherent_impls` query. Thus we proceed onwards to typeck, and since a return type of `Result<CrateInherentImpls, ErrorGuaranteed>` means that the query can *either* return one of "the list inherent impls" or "error has been reported", later on when we want to assemble method or associated item candidates for inherent impls, we were just treating any `Err(ErrorGuaranteed)` return value as if Rust had no inherent impls defined anywhere at all! This leads to basically every inherent method call failing with an error, lol, which was reported in #127798. This PR changes the `crate_inherent_impls` query to return `(CrateInherentImpls, Result<(), ErrorGuaranteed>)`, i.e. returning the inherent impls collected *and* whether an error was reported in the query itself. It firewalls the latter part of that query into a new `crate_inherent_impls_validity_check` just for the `ensure()` call. This fixes #127798.
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-4/+4
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-1/+1
2024-09-24Fix toolsMichael Goulet-7/+3
2024-09-24Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into ↵Philipp Krones-188/+144
clippy-subtree-update
2024-09-21Fix clippyBen Kimock-1/+1
2024-09-20[Clippy] Remove final std paths for diagnostic itemGnomedDev-19/+12
2024-09-19Categorise paths in `clippy_utils::paths`GnomedDev-13/+20
2024-09-19[Clippy] Swap `open_options` to use diagnostic items instead of pathsGnomedDev-2/+0
2024-09-19[Clippy] Swap `iter_over_hash_type` to use diagnostic items instead of pathsGnomedDev-8/+0
2024-09-19[Clippy] Swap `non_octal_unix_permissions` to use diagnostic item instead of ↵GnomedDev-2/+0
path
2024-09-19[Clippy] Swap `unnecessary_owned_empty_strings` to use diagnostic item ↵GnomedDev-1/+0
instead of path
2024-09-19[Clippy] Swap `manual_strip` to use diagnostic items instead of pathsGnomedDev-3/+0
2024-09-19[Clippy] Swap `unnecessary_to_owned` to use diagnostic item instead of pathGnomedDev-1/+0
2024-09-19[Clippy] Swap `instant_subtraction` to use diagnostic item instead of pathGnomedDev-1/+0
2024-09-19[Clippy] Swap `waker_clone_wake` to use diagnostic item instead of pathGnomedDev-1/+0
2024-09-19[Clippy] Swap `filter_map_bool_then` to use diagnostic item instead of pathGnomedDev-1/+0
2024-09-19[Clippy] Swap `manual_while_let_some` to use diagnostic items instead of pathsGnomedDev-4/+0
2024-09-19[Clippy] Swap `repeat_vec_with_capacity` to use diagnostic item instead of pathGnomedDev-1/+0
2024-09-19[Clippy] Swap `VecArgs::hir` to use diagnostic items instead of pathsGnomedDev-7/+4
2024-09-19[Clippy] Swap `single_char_add_str`/`format_push_string` to use diagnostic ↵GnomedDev-2/+0
items instead of paths
2024-09-19[Clippy] Swap `manual_main_separator_str` to use diagnostic item instead of pathGnomedDev-1/+0
2024-09-19[Clippy] Swap `redundant_clone` to use diagnostic items instead of pathsGnomedDev-2/+0
2024-09-19[Clippy] Swap `float_equality_without_abs` to use diagnostic items instead ↵GnomedDev-2/+0
of paths
2024-09-19[Clippy] Swap `option_as_ref_deref` to use diagnostic items instead of pathsGnomedDev-7/+0
2024-09-19[Clippy] Swap `lines_filter_map_ok` to use a diagnostic item instead of pathGnomedDev-1/+0
2024-09-19[Clippy] Swap `map_entry` to use diagnostic items instead of pathsGnomedDev-4/+0
2024-09-18[Clippy] Swap `manual_retain` to use diagnostic items instead of pathsGnomedDev-9/+0
2024-09-11Remove unused functions from ast CoroutineKindMichael Goulet-1/+11
2024-09-06Make `Ty::boxed_ty` return an `Option`Pavel Grigorenko-2/+2
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