Files
rust/compiler
bors 974ccc12e6 Auto merge of #129514 - estebank:default-field-values, r=compiler-errors
Introduce `default_field_values` feature

Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681.

We now parse const expressions after a `=` in a field definition, to specify a `struct` field default value.

We now allow `Struct { field, .. }` where there's no base after `..`.

`#[derive(Default)]` now uses the default value if present, continuing to use `Default::default()` if not.

```rust
#[derive(Debug)]
pub struct S;

#[derive(Debug, Default)]
pub struct Foo {
    pub bar: S = S,
    pub baz: i32 = 42 + 3,
}

fn main () {
    let x = Foo { .. };
    let y = Foo::default();
    let z = Foo { baz: 1, .. };

    assert_eq!(45, x.baz);
    assert_eq!(45, y.baz);
    assert_eq!(1, z.baz);
}
```
2024-12-10 00:07:00 +00:00
..
2024-12-06 16:42:09 -05:00
2024-12-09 21:55:13 +00:00
2024-12-09 21:55:12 +00:00
2024-11-23 13:52:54 +01:00
2024-12-09 21:55:13 +00:00
2024-12-06 18:42:31 +00:00
2024-12-06 16:42:09 -05:00