diff options
author | Aleksey Kladov <[email protected]> | 2021-06-13 13:48:54 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-13 13:48:54 +0100 |
commit | 6383252cc2770545505d40217732f14e93a396c4 (patch) | |
tree | c68f9e02b8ef19b6d4bb70451c202bccbf5858f0 /crates/hir_ty | |
parent | c6509a4592b67acc4a99a7ffd6dd688bc6cd29be (diff) |
internal: unified missing fields diagnostic
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/diagnostics/expr.rs | 18 |
1 files changed, 7 insertions, 11 deletions
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::{ | |||
8 | expr::Statement, path::path, resolver::HasResolver, AssocItemId, DefWithBodyId, HasModule, | 8 | expr::Statement, path::path, resolver::HasResolver, AssocItemId, DefWithBodyId, HasModule, |
9 | }; | 9 | }; |
10 | use hir_expand::name; | 10 | use hir_expand::name; |
11 | use itertools::Either; | ||
11 | use rustc_hash::FxHashSet; | 12 | use rustc_hash::FxHashSet; |
12 | 13 | ||
13 | use crate::{ | 14 | use crate::{ |
@@ -26,13 +27,8 @@ pub(crate) use hir_def::{ | |||
26 | }; | 27 | }; |
27 | 28 | ||
28 | pub enum BodyValidationDiagnostic { | 29 | pub enum BodyValidationDiagnostic { |
29 | RecordLiteralMissingFields { | 30 | RecordMissingFields { |
30 | record_expr: ExprId, | 31 | record: Either<ExprId, PatId>, |
31 | variant: VariantId, | ||
32 | missed_fields: Vec<LocalFieldId>, | ||
33 | }, | ||
34 | RecordPatMissingFields { | ||
35 | record_pat: PatId, | ||
36 | variant: VariantId, | 32 | variant: VariantId, |
37 | missed_fields: Vec<LocalFieldId>, | 33 | missed_fields: Vec<LocalFieldId>, |
38 | }, | 34 | }, |
@@ -95,8 +91,8 @@ impl ExprValidator { | |||
95 | if let Some((variant, missed_fields, true)) = | 91 | if let Some((variant, missed_fields, true)) = |
96 | record_literal_missing_fields(db, &self.infer, id, expr) | 92 | record_literal_missing_fields(db, &self.infer, id, expr) |
97 | { | 93 | { |
98 | self.diagnostics.push(BodyValidationDiagnostic::RecordLiteralMissingFields { | 94 | self.diagnostics.push(BodyValidationDiagnostic::RecordMissingFields { |
99 | record_expr: id, | 95 | record: Either::Left(id), |
100 | variant, | 96 | variant, |
101 | missed_fields, | 97 | missed_fields, |
102 | }); | 98 | }); |
@@ -116,8 +112,8 @@ impl ExprValidator { | |||
116 | if let Some((variant, missed_fields, true)) = | 112 | if let Some((variant, missed_fields, true)) = |
117 | record_pattern_missing_fields(db, &self.infer, id, pat) | 113 | record_pattern_missing_fields(db, &self.infer, id, pat) |
118 | { | 114 | { |
119 | self.diagnostics.push(BodyValidationDiagnostic::RecordPatMissingFields { | 115 | self.diagnostics.push(BodyValidationDiagnostic::RecordMissingFields { |
120 | record_pat: id, | 116 | record: Either::Right(id), |
121 | variant, | 117 | variant, |
122 | missed_fields, | 118 | missed_fields, |
123 | }); | 119 | }); |