aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/code_model.rs24
-rw-r--r--crates/hir/src/diagnostics.rs3
2 files changed, 25 insertions, 2 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index a101d724e..b65be4fe1 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -255,6 +255,25 @@ impl ModuleDef {
255 ModuleDef::BuiltinType(it) => Some(it.as_name()), 255 ModuleDef::BuiltinType(it) => Some(it.as_name()),
256 } 256 }
257 } 257 }
258
259 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
260 let id = match self {
261 ModuleDef::Adt(it) => match it {
262 Adt::Struct(it) => it.id.into(),
263 Adt::Enum(it) => it.id.into(),
264 Adt::Union(it) => it.id.into(),
265 },
266 ModuleDef::Trait(it) => it.id.into(),
267 ModuleDef::Function(it) => it.id.into(),
268 ModuleDef::TypeAlias(it) => it.id.into(),
269 ModuleDef::Module(it) => it.id.into(),
270 ModuleDef::Const(it) => it.id.into(),
271 ModuleDef::Static(it) => it.id.into(),
272 _ => return,
273 };
274
275 hir_ty::diagnostics::validate_module_item(db, id, sink)
276 }
258} 277}
259 278
260pub use hir_def::{ 279pub use hir_def::{
@@ -358,6 +377,8 @@ impl Module {
358 let crate_def_map = db.crate_def_map(self.id.krate); 377 let crate_def_map = db.crate_def_map(self.id.krate);
359 crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); 378 crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink);
360 for decl in self.declarations(db) { 379 for decl in self.declarations(db) {
380 decl.diagnostics(db, sink);
381
361 match decl { 382 match decl {
362 crate::ModuleDef::Function(f) => f.diagnostics(db, sink), 383 crate::ModuleDef::Function(f) => f.diagnostics(db, sink),
363 crate::ModuleDef::Module(m) => { 384 crate::ModuleDef::Module(m) => {
@@ -760,7 +781,8 @@ impl Function {
760 } 781 }
761 782
762 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { 783 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
763 hir_ty::diagnostics::validate_body(db, self.id.into(), sink) 784 hir_ty::diagnostics::validate_module_item(db, self.id.into(), sink);
785 hir_ty::diagnostics::validate_body(db, self.id.into(), sink);
764 } 786 }
765 787
766 /// Whether this function declaration has a definition. 788 /// Whether this function declaration has a definition.
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs
index 363164b9b..da2b40849 100644
--- a/crates/hir/src/diagnostics.rs
+++ b/crates/hir/src/diagnostics.rs
@@ -2,5 +2,6 @@
2pub use hir_def::diagnostics::UnresolvedModule; 2pub use hir_def::diagnostics::UnresolvedModule;
3pub use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticSinkBuilder}; 3pub use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticSinkBuilder};
4pub use hir_ty::diagnostics::{ 4pub use hir_ty::diagnostics::{
5 MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField, 5 IncorrectCase, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr,
6 NoSuchField,
6}; 7};