Show missing struct fields in the error message

This commit is contained in:
Frizi 2019-11-24 17:36:30 +01:00
parent ac9ba5eb32
commit 66f04e6be5
2 changed files with 8 additions and 2 deletions

View File

@ -39,7 +39,12 @@ pub struct MissingFields {
impl Diagnostic for MissingFields {
fn message(&self) -> String {
"fill structure fields".to_string()
use std::fmt::Write;
let mut message = String::from("Missing structure fields:\n");
for field in &self.missed_fields {
write!(message, "- {}\n", field).unwrap();
}
message
}
fn source(&self) -> Source<SyntaxNodePtr> {
Source { file_id: self.file, value: self.field_list.into() }

View File

@ -4832,7 +4832,8 @@ fn no_such_field_diagnostics() {
assert_snapshot!(diagnostics, @r###"
"baz: 62": no such field
"{\n foo: 92,\n baz: 62,\n }": fill structure fields
"{\n foo: 92,\n baz: 62,\n }": Missing structure fields:
- bar
"###
);
}