add record pat missing field diagnostic

This commit is contained in:
Josh Mcguigan 2020-04-08 20:23:51 -07:00
parent 176f7f6117
commit e63315b8f1
7 changed files with 159 additions and 57 deletions

View file

@ -62,6 +62,29 @@ impl AstDiagnostic for MissingFields {
}
}
#[derive(Debug)]
pub struct MissingPatFields {
pub file: HirFileId,
pub field_list: AstPtr<ast::RecordFieldPatList>,
pub missed_fields: Vec<Name>,
}
impl Diagnostic for MissingPatFields {
fn message(&self) -> String {
let mut buf = String::from("Missing structure fields:\n");
for field in &self.missed_fields {
format_to!(buf, "- {}", field);
}
buf
}
fn source(&self) -> InFile<SyntaxNodePtr> {
InFile { file_id: self.file, value: self.field_list.into() }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
self
}
}
#[derive(Debug)]
pub struct MissingMatchArms {
pub file: HirFileId,