Skip to content

Commit 1574391

Browse files
committed
Add name of initializer to missing field message, closes #30299
1 parent 41a3385 commit 1574391

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,12 +3156,13 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
31563156
!remaining_fields.is_empty()
31573157
{
31583158
span_err!(tcx.sess, span, E0063,
3159-
"missing field{}: {}",
3159+
"missing field{} {} in initializer of `{}`",
31603160
if remaining_fields.len() == 1 {""} else {"s"},
31613161
remaining_fields.keys()
31623162
.map(|n| format!("`{}`", n))
31633163
.collect::<Vec<_>>()
3164-
.join(", "));
3164+
.join(", "),
3165+
adt_ty);
31653166
}
31663167

31673168
}

src/test/compile-fail/struct-fields-missing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct BuildData {
1515
}
1616

1717
fn main() {
18-
let foo = BuildData { //~ ERROR missing field: `bar`
18+
let foo = BuildData { //~ ERROR missing field `bar` in initializer of `BuildData`
1919
foo: 0
2020
};
2121
}

0 commit comments

Comments
 (0)