From 6383252cc2770545505d40217732f14e93a396c4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 15:48:54 +0300 Subject: internal: unified missing fields diagnostic --- crates/hir_ty/src/diagnostics/expr.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index c480ed352..2a211fd8e 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -8,6 +8,7 @@ use hir_def::{ expr::Statement, path::path, resolver::HasResolver, AssocItemId, DefWithBodyId, HasModule, }; use hir_expand::name; +use itertools::Either; use rustc_hash::FxHashSet; use crate::{ @@ -26,13 +27,8 @@ pub(crate) use hir_def::{ }; pub enum BodyValidationDiagnostic { - RecordLiteralMissingFields { - record_expr: ExprId, - variant: VariantId, - missed_fields: Vec, - }, - RecordPatMissingFields { - record_pat: PatId, + RecordMissingFields { + record: Either, variant: VariantId, missed_fields: Vec, }, @@ -95,8 +91,8 @@ impl ExprValidator { if let Some((variant, missed_fields, true)) = record_literal_missing_fields(db, &self.infer, id, expr) { - self.diagnostics.push(BodyValidationDiagnostic::RecordLiteralMissingFields { - record_expr: id, + self.diagnostics.push(BodyValidationDiagnostic::RecordMissingFields { + record: Either::Left(id), variant, missed_fields, }); @@ -116,8 +112,8 @@ impl ExprValidator { if let Some((variant, missed_fields, true)) = record_pattern_missing_fields(db, &self.infer, id, pat) { - self.diagnostics.push(BodyValidationDiagnostic::RecordPatMissingFields { - record_pat: id, + self.diagnostics.push(BodyValidationDiagnostic::RecordMissingFields { + record: Either::Right(id), variant, missed_fields, }); -- cgit v1.2.3