1
Fork 0

Make error message for missing fields with .. and without .. more consistent

This commit is contained in:
Michael Goulet 2025-03-27 17:24:06 +00:00
parent ecb170afc8
commit 250b848272
3 changed files with 25 additions and 14 deletions

View file

@ -2204,8 +2204,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let fields = listify(&missing_mandatory_fields, |f| format!("`{f}`")).unwrap();
self.dcx()
.struct_span_err(
span.shrink_to_hi(),
format!("missing mandatory field{s} {fields}"),
span.shrink_to_lo(),
format!("missing field{s} {fields} in initializer"),
)
.with_span_label(
span.shrink_to_lo(),
"fields that do not have a defaulted value must be provided explicitly",
)
.emit();
return;