about summary refs log tree commit diff
path: root/clippy_lints/src/default.rs
AgeCommit message (Collapse)AuthorLines
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-10-18Merge commit 'a109190d7060236e655fc75533373fa274ec5343' into ↵Philipp Krones-2/+2
clippy-subtree-update
2024-09-24Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into ↵Philipp Krones-1/+1
clippy-subtree-update
2024-08-08Merge commit 'cb806113e0f83a8f9b47d35b453b676543bcc40e' into ↵Philipp Krones-1/+1
clippy-subtree-update
2024-07-11Merge commit 'b794b8e08c16517a941dc598bb1483e8e12a8592' into ↵Philipp Krones-5/+5
clippy-subtree-update
2024-04-04Merge commit '9725c4a162502a02c1c67fdca6b797fe09b2b73c' into ↵Philipp Krones-2/+2
clippy-subtree-update
2024-03-14Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`Guillaume Gomez-1/+1
2024-02-07Use correct param env in clippyMichael Goulet-2/+2
2023-12-01Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-syncPhilipp Krones-1/+1
2023-11-16Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyupPhilipp Krones-94/+81
2023-11-02Merge commit '09ac14c901abc43bd0d617ae4a44e8a4fed98d9c' into clippyupPhilipp Krones-4/+4
2023-10-05Add more diagnostic items for clippyJason Newcomb-6/+4
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-4/+4
2023-03-24Merge commit 'd5e2a7aca55ed49fc943b7a07a8eba05ab5a0079' into clippyupPhilipp Krones-3/+6
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-1/+1
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-1/+1
2023-01-12Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyupPhilipp Krones-4/+3
2022-10-06Merge commit 'ac0e10aa68325235069a842f47499852b2dee79e' into clippyupPhilipp Krones-10/+7
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-1/+1
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-08-11Merge commit '2b2190cb5667cdd276a24ef8b9f3692209c54a89' into clippyupPhilipp Krones-1/+4
2022-06-16Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' into clippyupflip1995-5/+6
2022-05-21Merge 'rust-clippy/master' into clippyupxFrednet-1/+1
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-3/+3
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-02-26Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyupflip1995-1/+15
2022-01-13Merge commit '97a5daa65908e59744e2bc625b14849352231c75' into clippyupflip1995-2/+2
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-1/+1
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2021-12-06Merge commit 'a5d597637dcb78dc73f93561ce474f23d4177c35' into clippyupflip1995-3/+5
2021-10-21Merge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyupflip1995-0/+8
2021-07-29Merge commit '0cce3f643bfcbb92d5a1bb71858c9cbaff749d6b' into clippyupflip1995-9/+12
2021-07-01Merge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyupflip1995-2/+1
2021-05-06Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyupflip1995-1/+2
2021-04-08Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyupflip1995-27/+26
2021-03-25Merge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyupflip1995-4/+22
2021-01-18Remove qpath_res util functionCameron Steffen-2/+2
2021-01-15Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyupflip1995-2/+7
2021-01-02Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyupflip1995-117/+71
2020-12-06Merge commit 'c1664c50b27a51f7a78c93ba65558e7c33eabee6' into clippyupflip1995-2/+1
2020-11-05Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyupflip1995-0/+304