aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-13 13:49:37 +0100
committerGitHub <[email protected]>2021-06-13 13:49:37 +0100
commitcc6d761a99ab3b7e28ed13ca3839358f3341da4d (patch)
treed9d180d516ddbafc7eb950f401e9a8ab3f1e88fe /crates/hir_ty/src/diagnostics
parent3f53a5dd724cbc7aa20280cddba44c7d2c0c8a6d (diff)
parent6383252cc2770545505d40217732f14e93a396c4 (diff)
Merge #9246
9246: internal: unified missing fields diagnostic r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/diagnostics')
-rw-r--r--crates/hir_ty/src/diagnostics/expr.rs18
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};
10use hir_expand::name; 10use hir_expand::name;
11use itertools::Either;
11use rustc_hash::FxHashSet; 12use rustc_hash::FxHashSet;
12 13
13use crate::{ 14use crate::{
@@ -26,13 +27,8 @@ pub(crate) use hir_def::{
26}; 27};
27 28
28pub enum BodyValidationDiagnostic { 29pub 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 });