diff options
author | Aleksey Kladov <[email protected]> | 2020-04-17 12:55:05 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-17 12:56:42 +0100 |
commit | 146f6f5a45a4bfd98ab0eb54bb30610d784433c9 (patch) | |
tree | e56f182d50f8863c2535fcd9d736ffb4e3425ae6 /crates/ra_hir_ty/src/diagnostics.rs | |
parent | a8196ffe8466aa60dec56e77c2da717793c0debe (diff) |
Simplify Diagnostic structure
It's not entirely clear what subnode ranges should mean in the
presence of macros, so let's leave them out for now. We are not using
them heavily anyway.
Diffstat (limited to 'crates/ra_hir_ty/src/diagnostics.rs')
-rw-r--r-- | crates/ra_hir_ty/src/diagnostics.rs | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 018c2ad3f..c8fd54861 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use std::any::Any; | 3 | use std::any::Any; |
4 | 4 | ||
5 | use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; | 5 | use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; |
6 | use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr, TextRange}; | 6 | use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; |
7 | use stdx::format_to; | 7 | use stdx::format_to; |
8 | 8 | ||
9 | pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm}; | 9 | pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm}; |
@@ -13,7 +13,6 @@ pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; | |||
13 | pub struct NoSuchField { | 13 | pub struct NoSuchField { |
14 | pub file: HirFileId, | 14 | pub file: HirFileId, |
15 | pub field: AstPtr<ast::RecordField>, | 15 | pub field: AstPtr<ast::RecordField>, |
16 | pub highlight_range: TextRange, | ||
17 | } | 16 | } |
18 | 17 | ||
19 | impl Diagnostic for NoSuchField { | 18 | impl Diagnostic for NoSuchField { |
@@ -21,10 +20,6 @@ impl Diagnostic for NoSuchField { | |||
21 | "no such field".to_string() | 20 | "no such field".to_string() |
22 | } | 21 | } |
23 | 22 | ||
24 | fn highlight_range(&self) -> InFile<TextRange> { | ||
25 | InFile::new(self.file, self.highlight_range) | ||
26 | } | ||
27 | |||
28 | fn source(&self) -> InFile<SyntaxNodePtr> { | 23 | fn source(&self) -> InFile<SyntaxNodePtr> { |
29 | InFile::new(self.file, self.field.clone().into()) | 24 | InFile::new(self.file, self.field.clone().into()) |
30 | } | 25 | } |
@@ -38,7 +33,6 @@ impl Diagnostic for NoSuchField { | |||
38 | pub struct MissingFields { | 33 | pub struct MissingFields { |
39 | pub file: HirFileId, | 34 | pub file: HirFileId, |
40 | pub field_list: AstPtr<ast::RecordFieldList>, | 35 | pub field_list: AstPtr<ast::RecordFieldList>, |
41 | pub highlight_range: TextRange, | ||
42 | pub missed_fields: Vec<Name>, | 36 | pub missed_fields: Vec<Name>, |
43 | } | 37 | } |
44 | 38 | ||
@@ -50,10 +44,6 @@ impl Diagnostic for MissingFields { | |||
50 | } | 44 | } |
51 | buf | 45 | buf |
52 | } | 46 | } |
53 | fn highlight_range(&self) -> InFile<TextRange> { | ||
54 | InFile::new(self.file, self.highlight_range) | ||
55 | } | ||
56 | |||
57 | fn source(&self) -> InFile<SyntaxNodePtr> { | 47 | fn source(&self) -> InFile<SyntaxNodePtr> { |
58 | InFile { file_id: self.file, value: self.field_list.clone().into() } | 48 | InFile { file_id: self.file, value: self.field_list.clone().into() } |
59 | } | 49 | } |
@@ -76,7 +66,6 @@ impl AstDiagnostic for MissingFields { | |||
76 | pub struct MissingPatFields { | 66 | pub struct MissingPatFields { |
77 | pub file: HirFileId, | 67 | pub file: HirFileId, |
78 | pub field_list: AstPtr<ast::RecordFieldPatList>, | 68 | pub field_list: AstPtr<ast::RecordFieldPatList>, |
79 | pub highlight_range: TextRange, | ||
80 | pub missed_fields: Vec<Name>, | 69 | pub missed_fields: Vec<Name>, |
81 | } | 70 | } |
82 | 71 | ||
@@ -88,9 +77,6 @@ impl Diagnostic for MissingPatFields { | |||
88 | } | 77 | } |
89 | buf | 78 | buf |
90 | } | 79 | } |
91 | fn highlight_range(&self) -> InFile<TextRange> { | ||
92 | InFile::new(self.file, self.highlight_range) | ||
93 | } | ||
94 | fn source(&self) -> InFile<SyntaxNodePtr> { | 80 | fn source(&self) -> InFile<SyntaxNodePtr> { |
95 | InFile { file_id: self.file, value: self.field_list.clone().into() } | 81 | InFile { file_id: self.file, value: self.field_list.clone().into() } |
96 | } | 82 | } |
@@ -104,16 +90,12 @@ pub struct MissingMatchArms { | |||
104 | pub file: HirFileId, | 90 | pub file: HirFileId, |
105 | pub match_expr: AstPtr<ast::Expr>, | 91 | pub match_expr: AstPtr<ast::Expr>, |
106 | pub arms: AstPtr<ast::MatchArmList>, | 92 | pub arms: AstPtr<ast::MatchArmList>, |
107 | pub highlight_range: TextRange, | ||
108 | } | 93 | } |
109 | 94 | ||
110 | impl Diagnostic for MissingMatchArms { | 95 | impl Diagnostic for MissingMatchArms { |
111 | fn message(&self) -> String { | 96 | fn message(&self) -> String { |
112 | String::from("Missing match arm") | 97 | String::from("Missing match arm") |
113 | } | 98 | } |
114 | fn highlight_range(&self) -> InFile<TextRange> { | ||
115 | InFile::new(self.file, self.highlight_range) | ||
116 | } | ||
117 | fn source(&self) -> InFile<SyntaxNodePtr> { | 99 | fn source(&self) -> InFile<SyntaxNodePtr> { |
118 | InFile { file_id: self.file, value: self.match_expr.clone().into() } | 100 | InFile { file_id: self.file, value: self.match_expr.clone().into() } |
119 | } | 101 | } |
@@ -126,16 +108,12 @@ impl Diagnostic for MissingMatchArms { | |||
126 | pub struct MissingOkInTailExpr { | 108 | pub struct MissingOkInTailExpr { |
127 | pub file: HirFileId, | 109 | pub file: HirFileId, |
128 | pub expr: AstPtr<ast::Expr>, | 110 | pub expr: AstPtr<ast::Expr>, |
129 | pub highlight_range: TextRange, | ||
130 | } | 111 | } |
131 | 112 | ||
132 | impl Diagnostic for MissingOkInTailExpr { | 113 | impl Diagnostic for MissingOkInTailExpr { |
133 | fn message(&self) -> String { | 114 | fn message(&self) -> String { |
134 | "wrap return expression in Ok".to_string() | 115 | "wrap return expression in Ok".to_string() |
135 | } | 116 | } |
136 | fn highlight_range(&self) -> InFile<TextRange> { | ||
137 | InFile::new(self.file, self.highlight_range) | ||
138 | } | ||
139 | fn source(&self) -> InFile<SyntaxNodePtr> { | 117 | fn source(&self) -> InFile<SyntaxNodePtr> { |
140 | InFile { file_id: self.file, value: self.expr.clone().into() } | 118 | InFile { file_id: self.file, value: self.expr.clone().into() } |
141 | } | 119 | } |