diff options
author | Aleksey Kladov <[email protected]> | 2021-06-13 19:55:51 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-13 19:55:51 +0100 |
commit | 935c53b92eea7c288b781ecd68436c9733ec8a83 (patch) | |
tree | 379899e0c1b3027df86a028b24203b58dd2fc49b /crates/hir_ty/src/diagnostics | |
parent | b292e1b9da39813e2739cb450c263e7502c97c8d (diff) |
internal: use cov-mark rather than bailing out diagnostic
Diffstat (limited to 'crates/hir_ty/src/diagnostics')
-rw-r--r-- | crates/hir_ty/src/diagnostics/expr.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 2a211fd8e..b809b96a0 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs | |||
@@ -50,21 +50,13 @@ pub enum BodyValidationDiagnostic { | |||
50 | MissingMatchArms { | 50 | MissingMatchArms { |
51 | match_expr: ExprId, | 51 | match_expr: ExprId, |
52 | }, | 52 | }, |
53 | InternalBailedOut { | ||
54 | pat: PatId, | ||
55 | }, | ||
56 | } | 53 | } |
57 | 54 | ||
58 | impl BodyValidationDiagnostic { | 55 | impl BodyValidationDiagnostic { |
59 | pub fn collect( | 56 | pub fn collect(db: &dyn HirDatabase, owner: DefWithBodyId) -> Vec<BodyValidationDiagnostic> { |
60 | db: &dyn HirDatabase, | ||
61 | owner: DefWithBodyId, | ||
62 | internal_diagnostics: bool, | ||
63 | ) -> Vec<BodyValidationDiagnostic> { | ||
64 | let _p = profile::span("BodyValidationDiagnostic::collect"); | 57 | let _p = profile::span("BodyValidationDiagnostic::collect"); |
65 | let infer = db.infer(owner); | 58 | let infer = db.infer(owner); |
66 | let mut validator = ExprValidator::new(owner, infer.clone()); | 59 | let mut validator = ExprValidator::new(owner, infer.clone()); |
67 | validator.internal_diagnostics = internal_diagnostics; | ||
68 | validator.validate_body(db); | 60 | validator.validate_body(db); |
69 | validator.diagnostics | 61 | validator.diagnostics |
70 | } | 62 | } |
@@ -74,12 +66,11 @@ struct ExprValidator { | |||
74 | owner: DefWithBodyId, | 66 | owner: DefWithBodyId, |
75 | infer: Arc<InferenceResult>, | 67 | infer: Arc<InferenceResult>, |
76 | pub(super) diagnostics: Vec<BodyValidationDiagnostic>, | 68 | pub(super) diagnostics: Vec<BodyValidationDiagnostic>, |
77 | internal_diagnostics: bool, | ||
78 | } | 69 | } |
79 | 70 | ||
80 | impl ExprValidator { | 71 | impl ExprValidator { |
81 | fn new(owner: DefWithBodyId, infer: Arc<InferenceResult>) -> ExprValidator { | 72 | fn new(owner: DefWithBodyId, infer: Arc<InferenceResult>) -> ExprValidator { |
82 | ExprValidator { owner, infer, diagnostics: Vec::new(), internal_diagnostics: false } | 73 | ExprValidator { owner, infer, diagnostics: Vec::new() } |
83 | } | 74 | } |
84 | 75 | ||
85 | fn validate_body(&mut self, db: &dyn HirDatabase) { | 76 | fn validate_body(&mut self, db: &dyn HirDatabase) { |
@@ -308,9 +299,7 @@ impl ExprValidator { | |||
308 | // fit the match expression, we skip this diagnostic. Skipping the entire | 299 | // fit the match expression, we skip this diagnostic. Skipping the entire |
309 | // diagnostic rather than just not including this match arm is preferred | 300 | // diagnostic rather than just not including this match arm is preferred |
310 | // to avoid the chance of false positives. | 301 | // to avoid the chance of false positives. |
311 | if self.internal_diagnostics { | 302 | cov_mark::hit!(validate_match_bailed_out); |
312 | self.diagnostics.push(BodyValidationDiagnostic::InternalBailedOut { pat: arm.pat }) | ||
313 | } | ||
314 | return; | 303 | return; |
315 | } | 304 | } |
316 | 305 | ||