diff options
Diffstat (limited to 'crates/hir/src/diagnostics.rs')
-rw-r--r-- | crates/hir/src/diagnostics.rs | 46 |
1 files changed, 1 insertions, 45 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index c2d608eb5..b4c505898 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -3,18 +3,12 @@ | |||
3 | //! | 3 | //! |
4 | //! This probably isn't the best way to do this -- ideally, diagnistics should | 4 | //! This probably isn't the best way to do this -- ideally, diagnistics should |
5 | //! be expressed in terms of hir types themselves. | 5 | //! be expressed in terms of hir types themselves. |
6 | use std::any::Any; | ||
7 | |||
8 | use cfg::{CfgExpr, CfgOptions}; | 6 | use cfg::{CfgExpr, CfgOptions}; |
9 | use either::Either; | 7 | use either::Either; |
10 | use hir_def::path::ModPath; | 8 | use hir_def::path::ModPath; |
11 | use hir_expand::{name::Name, HirFileId, InFile}; | 9 | use hir_expand::{name::Name, HirFileId, InFile}; |
12 | use syntax::{ast, AstPtr, SyntaxNodePtr, TextRange}; | 10 | use syntax::{ast, AstPtr, SyntaxNodePtr, TextRange}; |
13 | 11 | ||
14 | pub use crate::diagnostics_sink::{ | ||
15 | Diagnostic, DiagnosticCode, DiagnosticSink, DiagnosticSinkBuilder, | ||
16 | }; | ||
17 | |||
18 | macro_rules! diagnostics { | 12 | macro_rules! diagnostics { |
19 | ($($diag:ident,)*) => { | 13 | ($($diag:ident,)*) => { |
20 | pub enum AnyDiagnostic {$( | 14 | pub enum AnyDiagnostic {$( |
@@ -38,6 +32,7 @@ diagnostics![ | |||
38 | MacroError, | 32 | MacroError, |
39 | MismatchedArgCount, | 33 | MismatchedArgCount, |
40 | MissingFields, | 34 | MissingFields, |
35 | MissingMatchArms, | ||
41 | MissingOkOrSomeInTailExpr, | 36 | MissingOkOrSomeInTailExpr, |
42 | MissingUnsafe, | 37 | MissingUnsafe, |
43 | NoSuchField, | 38 | NoSuchField, |
@@ -149,9 +144,6 @@ pub struct MissingOkOrSomeInTailExpr { | |||
149 | pub required: String, | 144 | pub required: String, |
150 | } | 145 | } |
151 | 146 | ||
152 | // Diagnostic: missing-match-arm | ||
153 | // | ||
154 | // This diagnostic is triggered if `match` block is missing one or more match arms. | ||
155 | #[derive(Debug)] | 147 | #[derive(Debug)] |
156 | pub struct MissingMatchArms { | 148 | pub struct MissingMatchArms { |
157 | pub file: HirFileId, | 149 | pub file: HirFileId, |
@@ -159,40 +151,4 @@ pub struct MissingMatchArms { | |||
159 | pub arms: AstPtr<ast::MatchArmList>, | 151 | pub arms: AstPtr<ast::MatchArmList>, |
160 | } | 152 | } |
161 | 153 | ||
162 | impl Diagnostic for MissingMatchArms { | ||
163 | fn code(&self) -> DiagnosticCode { | ||
164 | DiagnosticCode("missing-match-arm") | ||
165 | } | ||
166 | fn message(&self) -> String { | ||
167 | String::from("Missing match arm") | ||
168 | } | ||
169 | fn display_source(&self) -> InFile<SyntaxNodePtr> { | ||
170 | InFile { file_id: self.file, value: self.match_expr.clone().into() } | ||
171 | } | ||
172 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | ||
173 | self | ||
174 | } | ||
175 | } | ||
176 | |||
177 | #[derive(Debug)] | ||
178 | pub struct InternalBailedOut { | ||
179 | pub file: HirFileId, | ||
180 | pub pat_syntax_ptr: SyntaxNodePtr, | ||
181 | } | ||
182 | |||
183 | impl Diagnostic for InternalBailedOut { | ||
184 | fn code(&self) -> DiagnosticCode { | ||
185 | DiagnosticCode("internal:match-check-bailed-out") | ||
186 | } | ||
187 | fn message(&self) -> String { | ||
188 | format!("Internal: match check bailed out") | ||
189 | } | ||
190 | fn display_source(&self) -> InFile<SyntaxNodePtr> { | ||
191 | InFile { file_id: self.file, value: self.pat_syntax_ptr.clone() } | ||
192 | } | ||
193 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | ||
194 | self | ||
195 | } | ||
196 | } | ||
197 | |||
198 | pub use hir_ty::diagnostics::IncorrectCase; | 154 | pub use hir_ty::diagnostics::IncorrectCase; |