about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2024-12-28 16:50:36 +1100
committerGitHub <noreply@github.com>2024-12-28 16:50:36 +1100
commit3e3db73c9be04438c972d253251cb1765c573e1e (patch)
treec019bc1bb20789a6841e562ce215c1d076814a6e /compiler/rustc_codegen_llvm/src
parent2b0ceb8c8c7d50b12ef29c7e37fb4f915389e28b (diff)
parent01307cf03f5b95759a8e84bce659f6326e247049 (diff)
downloadrust-3e3db73c9be04438c972d253251cb1765c573e1e.tar.gz
rust-3e3db73c9be04438c972d253251cb1765c573e1e.zip
Rollup merge of #134737 - estebank:deive-lint-default-fields-base, r=compiler-errors
Implement `default_overrides_default_fields` lint

Detect when a manual `Default` implementation isn't using the existing default field values and suggest using `..` instead:

```
error: `Default` impl doesn't use the declared default field values
  --> $DIR/manual-default-impl-could-be-derived.rs:14:1
   |
LL | / impl Default for A {
LL | |     fn default() -> Self {
LL | |         A {
LL | |             y: 0,
   | |                - this field has a default value
...  |
LL | | }
   | |_^
   |
   = help: use the default values in the `impl` with `Struct { mandatory_field, .. }` to avoid them diverging over time
note: the lint level is defined here
  --> $DIR/manual-default-impl-could-be-derived.rs:5:9
   |
LL | #![deny(default_overrides_default_fields)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

r? `@compiler-errors`

This is a simpler version of #134441, detecting the simpler case when a field with a default should have not been specified in the manual `Default::default()`, instead using `..` for it. It doesn't provide any suggestions, nor the checks for "equivalences" nor whether the value used in the imp being used would be suitable as a default field value.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions