Commit 0ffcac3
committed
Introduce
Initial implementation of `#[feature(default_field_values]`, proposed in rust-lang/rfcs#3681.
Support default fields in enum struct variant
Allow default values in an enum struct variant definition:
```rust
pub enum Bar {
Foo {
bar: S = S,
baz: i32 = 42 + 3,
}
}
```
Allow using `..` without a base on an enum struct variant
```rust
Bar::Foo { .. }
```
`#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants.
Support `#[derive(Default)]` on enum struct variants with all defaulted fields
```rust
pub enum Bar {
#[default]
Foo {
bar: S = S,
baz: i32 = 42 + 3,
}
}
```
Check for missing fields in typeck instead of mir_build.
Expand test with `const` param case (needs `generic_const_exprs` enabled).
Properly instantiate MIR const
The following works:
```rust
struct S<A> {
a: Vec<A> = Vec::new(),
}
S::<i32> { .. }
```default_field_values feature1 parent 7db7489 commit 0ffcac3
File tree
65 files changed
+923
-319
lines changed- compiler
- rustc_ast_lowering
- src
- rustc_ast_passes/src
- rustc_ast/src
- rustc_borrowck/src/diagnostics
- rustc_builtin_macros/src/deriving
- generic
- rustc_expand/src
- rustc_feature/src
- rustc_hir_analysis/src
- collect
- rustc_hir_pretty/src
- rustc_hir_typeck
- src
- fn_ctxt
- rustc_hir/src
- rustc_metadata/src/rmeta
- rustc_middle/src
- thir
- ty
- rustc_mir_build/src
- build
- custom/parse
- expr
- thir
- cx
- rustc_parse
- src
- parser
- rustc_passes/src
- rustc_privacy/src
- rustc_resolve/src
- rustc_span/src
- src/tools/clippy
- clippy_lints/src
- loops
- utils
- clippy_utils/src
- tests/ui
- destructuring-assignment
- feature-gates
- parser
- stats
- structs
- thir-print
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
65 files changed
+923
-319
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3067 | 3067 | | |
3068 | 3068 | | |
3069 | 3069 | | |
| 3070 | + | |
3070 | 3071 | | |
3071 | 3072 | | |
3072 | 3073 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1115 | 1115 | | |
1116 | 1116 | | |
1117 | 1117 | | |
1118 | | - | |
| 1118 | + | |
1119 | 1119 | | |
1120 | 1120 | | |
1121 | 1121 | | |
1122 | 1122 | | |
1123 | 1123 | | |
1124 | 1124 | | |
| 1125 | + | |
1125 | 1126 | | |
1126 | 1127 | | |
1127 | 1128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
961 | 961 | | |
962 | 962 | | |
963 | 963 | | |
964 | | - | |
| 964 | + | |
| 965 | + | |
965 | 966 | | |
966 | 967 | | |
967 | 968 | | |
968 | 969 | | |
| 970 | + | |
969 | 971 | | |
970 | 972 | | |
971 | 973 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 117 | | |
126 | 118 | | |
127 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
368 | 365 | | |
369 | 366 | | |
370 | 367 | | |
| |||
1540 | 1537 | | |
1541 | 1538 | | |
1542 | 1539 | | |
1543 | | - | |
| 1540 | + | |
1544 | 1541 | | |
1545 | 1542 | | |
1546 | 1543 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
| 726 | + | |
726 | 727 | | |
727 | 728 | | |
728 | 729 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1151 | 1151 | | |
1152 | 1152 | | |
1153 | 1153 | | |
1154 | | - | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
1155 | 1157 | | |
1156 | 1158 | | |
1157 | 1159 | | |
| |||
1239 | 1241 | | |
1240 | 1242 | | |
1241 | 1243 | | |
1242 | | - | |
| 1244 | + | |
1243 | 1245 | | |
1244 | 1246 | | |
1245 | 1247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
0 commit comments