rust/compiler/rustc_lint/src
Stuart Cook 3e3db73c9b
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.
2024-12-28 16:50:36 +11:00
..
early Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
types rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00
async_closures.rs Stabilize async closures 2024-12-13 00:04:56 +00:00
async_fn_in_trait.rs nightly feature tracking: get rid of the per-feature bool fields 2024-10-23 09:14:41 +01:00
builtin.rs Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spastorino 2024-12-18 22:56:53 +08:00
context.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
dangling.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
default_could_be_derived.rs Implement default_overrides_default_fields lint 2024-12-25 23:25:45 +00:00
deref_into_dyn_supertrait.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
drop_forget_useless.rs remove Ty::is_copy_modulo_regions 2024-12-02 13:57:56 +01:00
early.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
enum_intrinsics_non_enums.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
errors.rs Add warn(unreachable_pub) to rustc_lint. 2024-08-27 15:24:11 +10:00
expect.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
for_loops_over_fallibles.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00
foreign_modules.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00
hidden_unicode_codepoints.rs Actually walk into lifetimes and attrs in EarlyContextAndPass 2024-12-07 02:08:40 +00:00
if_let_rescope.rs Use links to edition guide for edition migrations 2024-12-15 20:28:16 -08:00
impl_trait_overcaptures.rs Auto merge of #133961 - lcnr:borrowck-cleanup, r=jackh726 2024-12-19 08:33:20 +00:00
internal.rs Merge some patterns together 2024-12-18 10:21:20 +00:00
invalid_from_utf8.rs Remove extern crate rustc_session from rustc_lint. 2024-04-29 13:57:41 +10:00
late.rs Do not filter empty passes & Make CTFE Clippy into lintless pass 2024-11-05 15:27:09 +01:00
let_underscore.rs use TypingEnv when no infcx is available 2024-11-18 10:38:56 +01:00
levels.rs Rollup merge of #134481 - estebank:unstable-lint-span, r=compiler-errors 2024-12-18 21:38:11 -05:00
lib.rs Implement default_overrides_default_fields lint 2024-12-25 23:25:45 +00:00
lints.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
macro_expr_fragment_specifier_2024_migration.rs Rename RefTokenTreeCursor. 2024-12-18 10:39:07 +11:00
map_unit_fn.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
multiple_supertrait_upcastable.rs Compiler: Rename "object safe" to "dyn compatible" 2024-09-25 13:26:48 +02:00
non_ascii_idents.rs Auto merge of #134243 - nnethercote:re-export-more-rustc_span, r=jieyouxu 2024-12-18 02:56:38 +00:00
non_fmt_panic.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
non_local_def.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
nonstandard_style.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
noop_method_call.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
opaque_hidden_inferred_bound.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
pass_by_value.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
passes.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
precedence.rs Temporarily switch ambiguous_negative_literals lint to allow 2024-07-31 19:36:47 +02:00
ptr_nulls.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
redundant_semicolon.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
reference_casting.rs move fn is_item_raw to TypingEnv 2024-11-19 18:06:20 +01:00
shadowed_into_iter.rs Use links to edition guide for edition migrations 2024-12-15 20:28:16 -08:00
static_mut_refs.rs Fix #131977 parens mangled in shared mut static lint suggestion 2024-10-24 03:34:37 +00:00
tests.rs allow symbol_intern_string_literal lint in test modules 2024-12-11 20:38:55 +03:00
traits.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
types.rs Begin to implement type system layer of unsafe binders 2024-12-22 21:57:57 +00:00
unit_bindings.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
unqualified_local_imports.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
unused.rs Use #[derive(Default)] instead of manually implementing it 2024-12-23 03:01:29 +00:00