Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer/pat.rs')
-rw-r--r--crates/hir-ty/src/infer/pat.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/hir-ty/src/infer/pat.rs b/crates/hir-ty/src/infer/pat.rs
index f1af8a0b73..e876375cbc 100644
--- a/crates/hir-ty/src/infer/pat.rs
+++ b/crates/hir-ty/src/infer/pat.rs
@@ -1241,13 +1241,19 @@ https://doc.rust-lang.org/reference/types.html#trait-objects";
// Report an error if an incorrect number of fields was specified.
if matches!(variant, VariantId::UnionId(_)) {
if fields.len() != 1 {
- // FIXME: Emit an error, unions can't have more than one field.
+ self.push_diagnostic(InferenceDiagnostic::UnionPatMustHaveExactlyOneField { pat });
}
if has_rest_pat {
- // FIXME: Emit an error, unions can't have a rest pat.
+ self.push_diagnostic(InferenceDiagnostic::UnionPatHasRest { pat });
}
} else if !unmentioned_fields.is_empty() && !has_rest_pat {
- // FIXME: Emit an error.
+ let missing_fields =
+ unmentioned_fields.iter().map(|(field_id, _)| *field_id).collect();
+ self.push_diagnostic(InferenceDiagnostic::RecordPatMissingFields {
+ pat,
+ variant,
+ missing_fields,
+ });
}
}