diff options
| author | bors <bors@rust-lang.org> | 2024-12-10 00:07:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-12-10 00:07:00 +0000 |
| commit | 974ccc12e6b4fdf38407258071e3d794d383ce3a (patch) | |
| tree | 13ea18466fe3e5912cff4fbdebe6433619ac37de /compiler/rustc_mir_transform/src/coverage/query.rs | |
| parent | a224f3807e58afc9353510f1d556c607d367545d (diff) | |
| parent | fa331f4d0d2d7657c76972574868c5c00afae459 (diff) | |
| download | rust-974ccc12e6b4fdf38407258071e3d794d383ce3a.tar.gz rust-974ccc12e6b4fdf38407258071e3d794d383ce3a.zip | |
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);
}
```
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/query.rs')
0 files changed, 0 insertions, 0 deletions
