about summary refs log tree commit diff
path: root/clippy_utils/src/higher.rs
AgeCommit message (Collapse)AuthorLines
2025-01-19Apply `unnecessary_semicolon` to Clippy sourcesSamuel Tardieu-1/+1
2024-12-26Make "all fields are shorthand" requirement configurableSamuel Moelius-1/+1
Handle field attributes in suggestions Fix adjacent code Address review comments https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1861352124 Address all review comments but one This comment is not yet addressed: https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1874544907 `initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
2024-12-15Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-1/+1
2024-12-09Introduce `default_field_values` featureEsteban Küber-2/+2
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-11-07Merge commit 'f712eb5cdccd121d0569af12f20e6a0fabe4364d' into ↵Philipp Krones-4/+4
clippy-subtree-update
2024-10-30Use match ergonomics compatible with editions 2021 and 2024Samuel Tardieu-4/+4
2024-09-24Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into ↵Philipp Krones-2/+2
clippy-subtree-update
2024-09-22FormattingPhilipp Krones-2/+2
2024-09-19[Clippy] Swap `VecArgs::hir` to use diagnostic items instead of pathsGnomedDev-4/+4
2024-08-08Merge commit 'cb806113e0f83a8f9b47d35b453b676543bcc40e' into ↵Philipp Krones-4/+9
clippy-subtree-update
2024-06-27Merge commit '68a799aea9b65e2444fbecfe32217ce7d5a3604f' into ↵Philipp Krones-29/+34
clippy-subtree-update
2024-04-04Merge commit '9725c4a162502a02c1c67fdca6b797fe09b2b73c' into ↵Philipp Krones-27/+27
clippy-subtree-update
2024-03-20Rename `hir::Let` into `hir::LetExpr`Guillaume Gomez-2/+2
2023-12-28Merge commit 'ac4c2094a6030530661bee3876e0228ddfeb6b8b' into clippy-subtree-syncPhilipp Krones-3/+17
2023-11-16Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyupPhilipp Krones-40/+37
2023-10-21Merge commit '2b030eb03d9e5837440b1ee0b98c50b97c0c5889' into clippyupPhilipp Krones-1/+1
2023-10-05Add more diagnostic items for clippyJason Newcomb-1/+1
2023-07-31Merge commit '5436dba826191964ac1d0dab534b7eb6d4c878f6' into clippyupPhilipp Krones-0/+1
2023-07-17Merge commit 'd9c24d1b1ee61f276e550b967409c9f155eac4e3' into clippyupPhilipp Krones-4/+4
2023-05-05Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyupPhilipp Krones-2/+4
2023-03-02Restrict `#[rustc_box]` to `Box::new` callsclubby789-8/+5
2022-06-04Merge commit 'd9ddce8a223cb9916389c039777b6966ea448dc8' into clippyupPhilipp Krones-1/+1
2022-05-21Merge 'rust-clippy/master' into clippyupxFrednet-11/+8
2022-02-10Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyupflip1995-7/+4
2022-01-13Merge commit '97a5daa65908e59744e2bc625b14849352231c75' into clippyupflip1995-292/+3
2021-12-17Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisabors-2/+12
Implement let-else type annotations natively Tracking issue: #87335 Fixes #89688, fixes #89807, edit: fixes #89960 as well As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved. This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically: * `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~ * It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that. * ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~ * ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~ * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~ Some other misc notes: * ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~ * in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.
2021-12-13Fix clippy uses of QPath::LangItemEsteban Kuber-6/+6
2021-12-13let-else: use hir::Let in clippyCormac Relf-2/+12
fix clippy format using `cargo fmt -p clippy_{lints,utils}` manually revert rustfmt line truncations rename to hir::Let in clippy Undo the shadowing of various `expr` variables after renaming `scrutinee` reduce destructuring of hir::Let to avoid `expr` collisions cargo fmt -p clippy_{lints,utils} bless new clippy::author output
2021-11-21Fix Clippy with changed for loop desugarCameron Steffen-47/+15
2021-11-06Fix Clippy with changed format_args!Cameron Steffen-10/+4
2021-11-04Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyupflip1995-10/+18
2021-10-21Merge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyupflip1995-3/+154
2021-10-19Remove begin_panic_fmt from clippyGary Guo-1/+0
2021-09-28Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyupflip1995-0/+30
2021-09-23Auto merge of #89139 - camsteffen:write-perf, r=Mark-Simulacrumbors-20/+15
Use ZST for fmt unsafety as suggested here - https://github.com/rust-lang/rust/pull/83302#issuecomment-923529151.
2021-09-21Use ZST for fmt unsafetyCameron Steffen-20/+15
This allows the format_args! macro to keep the pre-expansion code out of the unsafe block without doing gymnastics with nested `match` expressions. This reduces codegen.
2021-09-18Remove needless hir Map refCameron Steffen-2/+1
2021-09-08Merge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyupflip1995-55/+110
2021-08-23Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnaybors-15/+20
Get piece unchecked in `write` We already use specialized `zip`, but it seems like we can do a little better by not checking `pieces` length at all. `Arguments` constructors are now unsafe. So the `format_args!` expansion now includes an `unsafe` block. <details> <summary>Local Bench Diff</summary> ```text name before ns/iter after ns/iter diff ns/iter diff % speedup fmt::write_str_macro1 22,967 19,718 -3,249 -14.15% x 1.16 fmt::write_str_macro2 35,527 32,654 -2,873 -8.09% x 1.09 fmt::write_str_macro_debug 571,953 575,973 4,020 0.70% x 0.99 fmt::write_str_ref 9,579 9,459 -120 -1.25% x 1.01 fmt::write_str_value 9,573 9,572 -1 -0.01% x 1.00 fmt::write_u128_max 176 173 -3 -1.70% x 1.02 fmt::write_u128_min 138 134 -4 -2.90% x 1.03 fmt::write_u64_max 139 136 -3 -2.16% x 1.02 fmt::write_u64_min 129 135 6 4.65% x 0.96 fmt::write_vec_macro1 24,401 22,273 -2,128 -8.72% x 1.10 fmt::write_vec_macro2 37,096 35,602 -1,494 -4.03% x 1.04 fmt::write_vec_macro_debug 588,291 589,575 1,284 0.22% x 1.00 fmt::write_vec_ref 9,568 9,732 164 1.71% x 0.98 fmt::write_vec_value 9,516 9,625 109 1.15% x 0.99 ``` </details>
2021-08-19Fix clippy let expressions falloutCameron Steffen-25/+9
2021-08-16clippy: Fix format_args expansion parsingCameron Steffen-15/+20
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-144/+363
2021-08-12Merge commit '7bfc26ec8e7a454786668e7e52ffe527fc649735' into clippyupflip1995-3/+3
2021-07-19Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyupflip1995-25/+0
2021-07-15Merge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyupflip1995-2/+106
2021-06-03Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyupflip1995-18/+18
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-1/+1
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-02-25Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyupflip1995-0/+268