Add name of initializer to missing field message, closes #30299

This commit is contained in:
Florian Hahn 2015-12-11 00:25:08 +01:00
parent 41a33852b8
commit 15743919dc
2 changed files with 4 additions and 3 deletions

View File

@ -3156,12 +3156,13 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
!remaining_fields.is_empty()
{
span_err!(tcx.sess, span, E0063,
"missing field{}: {}",
"missing field{} {} in initializer of `{}`",
if remaining_fields.len() == 1 {""} else {"s"},
remaining_fields.keys()
.map(|n| format!("`{}`", n))
.collect::<Vec<_>>()
.join(", "));
.join(", "),
adt_ty);
}
}

View File

@ -15,7 +15,7 @@ struct BuildData {
}
fn main() {
let foo = BuildData { //~ ERROR missing field: `bar`
let foo = BuildData { //~ ERROR missing field `bar` in initializer of `BuildData`
foo: 0
};
}