rust/tests/ui/structs/default-field-values
Jubilee b3d7c1483d
Rollup merge of #137913 - compiler-errors:struct-field-default-generic, r=BoxyUwU
Allow struct field default values to reference struct's generics

Right now, the default field value feature (https://github.com/rust-lang/rust/issues/132162) lowers anon consts whose types may reference ADT params that the const doesn't inherit.

This PR fixes this, so that these defaults can reference ADTs' generics, and sets the `generics_of` parenting up correctly.

There doesn't seem to be a good reason not to support this, since the anon const has a well-defined type from the field, and the anon const doesn't interact with the type system like generic parameter defaults do.

r? `````@boxyuwu````` or reassign

I could also make this into an error if this seems problematic (https://github.com/rust-lang/rust/compare/master...compiler-errors:rust:default-field-value-implicit-param?expand=1)...... but I'd rather make this work and register an open question on the tracking issue about validating that this is well-vetted.

Fixes #137896
2025-03-04 19:37:01 -08:00
..
auxiliary
do-not-ice-on-invalid-lifetime.rs Do not recover missing lifetime with random in-scope lifetime 2025-03-03 05:57:55 +00:00
do-not-ice-on-invalid-lifetime.stderr Do not recover missing lifetime with random in-scope lifetime 2025-03-03 05:57:55 +00:00
empty-struct.rs Disallow A { .. } if A has no fields 2025-01-18 21:05:09 +00:00
empty-struct.stderr Disallow A { .. } if A has no fields 2025-01-18 21:05:09 +00:00
failures.rs Allow struct field default values to reference struct's generics 2025-03-04 01:00:55 +00:00
failures.stderr Allow struct field default values to reference struct's generics 2025-03-04 01:00:55 +00:00
field-references-param.rs Allow struct field default values to reference struct's generics 2025-03-04 01:00:55 +00:00
invalid-const.rs
invalid-const.stderr Shorten span of panic failures in const context 2025-02-28 16:28:41 +00:00
non-exhaustive-ctor.disabled.stderr More sophisticated span trimming 2025-02-21 00:41:17 +00:00
non-exhaustive-ctor.enabled.fixed Detect missing fields with default values and suggest .. 2025-01-21 21:26:37 +00:00
non-exhaustive-ctor.enabled.stderr More sophisticated span trimming 2025-02-21 00:41:17 +00:00
non-exhaustive-ctor.rs Detect missing fields with default values and suggest .. 2025-01-21 21:26:37 +00:00
post-mono.direct.stderr Allow struct field default values to reference struct's generics 2025-03-04 01:00:55 +00:00
post-mono.indirect.stderr Allow struct field default values to reference struct's generics 2025-03-04 01:00:55 +00:00
post-mono.rs Allow struct field default values to reference struct's generics 2025-03-04 01:00:55 +00:00
support.rs
use-normalized-ty-for-default-struct-value.rs Make sure to use normalized ty for unevaluated const for default struct value 2024-12-14 18:05:19 +00:00
visibility.rs Emit a single privacy error for multiple fields on the same struct expression 2025-01-18 20:33:15 +00:00
visibility.stderr Emit a single privacy error for multiple fields on the same struct expression 2025-01-18 20:33:15 +00:00