diff options
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/diagnostics.rs | 23 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 28 |
2 files changed, 6 insertions, 45 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 5cffef47f..1f6a70006 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -3,8 +3,6 @@ | |||
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; |
@@ -157,25 +155,4 @@ pub struct MissingMatchArms { | |||
157 | pub arms: AstPtr<ast::MatchArmList>, | 155 | pub arms: AstPtr<ast::MatchArmList>, |
158 | } | 156 | } |
159 | 157 | ||
160 | #[derive(Debug)] | ||
161 | pub struct InternalBailedOut { | ||
162 | pub file: HirFileId, | ||
163 | pub pat_syntax_ptr: SyntaxNodePtr, | ||
164 | } | ||
165 | |||
166 | impl Diagnostic for InternalBailedOut { | ||
167 | fn code(&self) -> DiagnosticCode { | ||
168 | DiagnosticCode("internal:match-check-bailed-out") | ||
169 | } | ||
170 | fn message(&self) -> String { | ||
171 | format!("Internal: match check bailed out") | ||
172 | } | ||
173 | fn display_source(&self) -> InFile<SyntaxNodePtr> { | ||
174 | InFile { file_id: self.file, value: self.pat_syntax_ptr.clone() } | ||
175 | } | ||
176 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | ||
177 | self | ||
178 | } | ||
179 | } | ||
180 | |||
181 | pub use hir_ty::diagnostics::IncorrectCase; | 158 | pub use hir_ty::diagnostics::IncorrectCase; |
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 2e794ff4a..7f689cd41 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -86,8 +86,8 @@ use crate::{ | |||
86 | pub use crate::{ | 86 | pub use crate::{ |
87 | attrs::{HasAttrs, Namespace}, | 87 | attrs::{HasAttrs, Namespace}, |
88 | diagnostics::{ | 88 | diagnostics::{ |
89 | AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase, InternalBailedOut, | 89 | AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase, MacroError, |
90 | MacroError, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, | 90 | MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, |
91 | MissingUnsafe, NoSuchField, RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap, | 91 | MissingUnsafe, NoSuchField, RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap, |
92 | UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, | 92 | UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, |
93 | UnresolvedModule, UnresolvedProcMacro, | 93 | UnresolvedModule, UnresolvedProcMacro, |
@@ -461,7 +461,6 @@ impl Module { | |||
461 | self, | 461 | self, |
462 | db: &dyn HirDatabase, | 462 | db: &dyn HirDatabase, |
463 | sink: &mut DiagnosticSink, | 463 | sink: &mut DiagnosticSink, |
464 | internal_diagnostics: bool, | ||
465 | ) -> Vec<AnyDiagnostic> { | 464 | ) -> Vec<AnyDiagnostic> { |
466 | let _p = profile::span("Module::diagnostics").detail(|| { | 465 | let _p = profile::span("Module::diagnostics").detail(|| { |
467 | format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string())) | 466 | format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string())) |
@@ -619,11 +618,11 @@ impl Module { | |||
619 | } | 618 | } |
620 | for decl in self.declarations(db) { | 619 | for decl in self.declarations(db) { |
621 | match decl { | 620 | match decl { |
622 | ModuleDef::Function(f) => acc.extend(f.diagnostics(db, sink, internal_diagnostics)), | 621 | ModuleDef::Function(f) => acc.extend(f.diagnostics(db, sink)), |
623 | ModuleDef::Module(m) => { | 622 | ModuleDef::Module(m) => { |
624 | // Only add diagnostics from inline modules | 623 | // Only add diagnostics from inline modules |
625 | if def_map[m.id.local_id].origin.is_inline() { | 624 | if def_map[m.id.local_id].origin.is_inline() { |
626 | acc.extend(m.diagnostics(db, sink, internal_diagnostics)) | 625 | acc.extend(m.diagnostics(db, sink)) |
627 | } | 626 | } |
628 | } | 627 | } |
629 | _ => acc.extend(decl.diagnostics(db)), | 628 | _ => acc.extend(decl.diagnostics(db)), |
@@ -633,7 +632,7 @@ impl Module { | |||
633 | for impl_def in self.impl_defs(db) { | 632 | for impl_def in self.impl_defs(db) { |
634 | for item in impl_def.items(db) { | 633 | for item in impl_def.items(db) { |
635 | if let AssocItem::Function(f) = item { | 634 | if let AssocItem::Function(f) = item { |
636 | acc.extend(f.diagnostics(db, sink, internal_diagnostics)); | 635 | acc.extend(f.diagnostics(db, sink)); |
637 | } | 636 | } |
638 | } | 637 | } |
639 | } | 638 | } |
@@ -1040,7 +1039,6 @@ impl Function { | |||
1040 | self, | 1039 | self, |
1041 | db: &dyn HirDatabase, | 1040 | db: &dyn HirDatabase, |
1042 | sink: &mut DiagnosticSink, | 1041 | sink: &mut DiagnosticSink, |
1043 | internal_diagnostics: bool, | ||
1044 | ) -> Vec<AnyDiagnostic> { | 1042 | ) -> Vec<AnyDiagnostic> { |
1045 | let mut acc: Vec<AnyDiagnostic> = Vec::new(); | 1043 | let mut acc: Vec<AnyDiagnostic> = Vec::new(); |
1046 | let krate = self.module(db).id.krate(); | 1044 | let krate = self.module(db).id.krate(); |
@@ -1100,9 +1098,7 @@ impl Function { | |||
1100 | } | 1098 | } |
1101 | } | 1099 | } |
1102 | 1100 | ||
1103 | for diagnostic in | 1101 | for diagnostic in BodyValidationDiagnostic::collect(db, self.id.into()) { |
1104 | BodyValidationDiagnostic::collect(db, self.id.into(), internal_diagnostics) | ||
1105 | { | ||
1106 | match diagnostic { | 1102 | match diagnostic { |
1107 | BodyValidationDiagnostic::RecordMissingFields { | 1103 | BodyValidationDiagnostic::RecordMissingFields { |
1108 | record, | 1104 | record, |
@@ -1223,18 +1219,6 @@ impl Function { | |||
1223 | Err(SyntheticSyntax) => (), | 1219 | Err(SyntheticSyntax) => (), |
1224 | } | 1220 | } |
1225 | } | 1221 | } |
1226 | BodyValidationDiagnostic::InternalBailedOut { pat } => { | ||
1227 | match source_map.pat_syntax(pat) { | ||
1228 | Ok(source_ptr) => { | ||
1229 | let pat_syntax_ptr = source_ptr.value.either(Into::into, Into::into); | ||
1230 | sink.push(InternalBailedOut { | ||
1231 | file: source_ptr.file_id, | ||
1232 | pat_syntax_ptr, | ||
1233 | }); | ||
1234 | } | ||
1235 | Err(SyntheticSyntax) => (), | ||
1236 | } | ||
1237 | } | ||
1238 | } | 1222 | } |
1239 | } | 1223 | } |
1240 | 1224 | ||