From e24e22f288eba33928a9e579f13653d6f04fcdfa Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Sat, 3 Oct 2020 17:34:52 +0300 Subject: Add fix for incorrect case diagnostic --- crates/hir/src/code_model.rs | 40 +++++++++++++++------------------------- crates/hir/src/diagnostics.rs | 3 ++- 2 files changed, 17 insertions(+), 26 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 19ea26e36..c134356ef 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -257,34 +257,22 @@ impl ModuleDef { } pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { - match self { + let id = match self { ModuleDef::Adt(it) => match it { - Adt::Struct(it) => { - hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) - } - Adt::Enum(it) => hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink), - Adt::Union(it) => hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink), + Adt::Struct(it) => it.id.into(), + Adt::Enum(it) => it.id.into(), + Adt::Union(it) => it.id.into(), }, - ModuleDef::Trait(it) => { - hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) - } - ModuleDef::Function(it) => { - hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) - } - ModuleDef::TypeAlias(it) => { - hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) - } - ModuleDef::Module(it) => { - hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) - } - ModuleDef::Const(it) => { - hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) - } - ModuleDef::Static(it) => { - hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) - } + ModuleDef::Trait(it) => it.id.into(), + ModuleDef::Function(it) => it.id.into(), + ModuleDef::TypeAlias(it) => it.id.into(), + ModuleDef::Module(it) => it.id.into(), + ModuleDef::Const(it) => it.id.into(), + ModuleDef::Static(it) => it.id.into(), _ => return, - } + }; + + hir_ty::diagnostics::validate_module_item(db, id, sink) } } @@ -389,6 +377,8 @@ impl Module { let crate_def_map = db.crate_def_map(self.id.krate); crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); for decl in self.declarations(db) { + decl.diagnostics(db, sink); + match decl { crate::ModuleDef::Function(f) => f.diagnostics(db, sink), crate::ModuleDef::Module(m) => { 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 @@ pub use hir_def::diagnostics::UnresolvedModule; pub use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticSinkBuilder}; pub use hir_ty::diagnostics::{ - MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField, + IncorrectCase, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, + NoSuchField, }; -- cgit v1.2.3