diff options
author | Igor Aleksanov <[email protected]> | 2020-10-03 15:34:52 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-10-12 09:04:59 +0100 |
commit | e24e22f288eba33928a9e579f13653d6f04fcdfa (patch) | |
tree | 4fd9d128cf510dd7478f6a1fd955461cca70d2f4 /crates/hir/src | |
parent | 17f1026c46e6e3797caf3c69737f66bd612c58e1 (diff) |
Add fix for incorrect case diagnostic
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/code_model.rs | 40 | ||||
-rw-r--r-- | crates/hir/src/diagnostics.rs | 3 |
2 files changed, 17 insertions, 26 deletions
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 { | |||
257 | } | 257 | } |
258 | 258 | ||
259 | pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { | 259 | pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { |
260 | match self { | 260 | let id = match self { |
261 | ModuleDef::Adt(it) => match it { | 261 | ModuleDef::Adt(it) => match it { |
262 | Adt::Struct(it) => { | 262 | Adt::Struct(it) => it.id.into(), |
263 | hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) | 263 | Adt::Enum(it) => it.id.into(), |
264 | } | 264 | Adt::Union(it) => it.id.into(), |
265 | Adt::Enum(it) => hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink), | ||
266 | Adt::Union(it) => hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink), | ||
267 | }, | 265 | }, |
268 | ModuleDef::Trait(it) => { | 266 | ModuleDef::Trait(it) => it.id.into(), |
269 | hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) | 267 | ModuleDef::Function(it) => it.id.into(), |
270 | } | 268 | ModuleDef::TypeAlias(it) => it.id.into(), |
271 | ModuleDef::Function(it) => { | 269 | ModuleDef::Module(it) => it.id.into(), |
272 | hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) | 270 | ModuleDef::Const(it) => it.id.into(), |
273 | } | 271 | ModuleDef::Static(it) => it.id.into(), |
274 | ModuleDef::TypeAlias(it) => { | ||
275 | hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) | ||
276 | } | ||
277 | ModuleDef::Module(it) => { | ||
278 | hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) | ||
279 | } | ||
280 | ModuleDef::Const(it) => { | ||
281 | hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) | ||
282 | } | ||
283 | ModuleDef::Static(it) => { | ||
284 | hir_ty::diagnostics::validate_module_item(db, it.id.into(), sink) | ||
285 | } | ||
286 | _ => return, | 272 | _ => return, |
287 | } | 273 | }; |
274 | |||
275 | hir_ty::diagnostics::validate_module_item(db, id, sink) | ||
288 | } | 276 | } |
289 | } | 277 | } |
290 | 278 | ||
@@ -389,6 +377,8 @@ impl Module { | |||
389 | let crate_def_map = db.crate_def_map(self.id.krate); | 377 | let crate_def_map = db.crate_def_map(self.id.krate); |
390 | 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); |
391 | for decl in self.declarations(db) { | 379 | for decl in self.declarations(db) { |
380 | decl.diagnostics(db, sink); | ||
381 | |||
392 | match decl { | 382 | match decl { |
393 | crate::ModuleDef::Function(f) => f.diagnostics(db, sink), | 383 | crate::ModuleDef::Function(f) => f.diagnostics(db, sink), |
394 | crate::ModuleDef::Module(m) => { | 384 | 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 @@ | |||
2 | pub use hir_def::diagnostics::UnresolvedModule; | 2 | pub use hir_def::diagnostics::UnresolvedModule; |
3 | pub use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticSinkBuilder}; | 3 | pub use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticSinkBuilder}; |
4 | pub use hir_ty::diagnostics::{ | 4 | pub use hir_ty::diagnostics::{ |
5 | MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField, | 5 | IncorrectCase, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, |
6 | NoSuchField, | ||
6 | }; | 7 | }; |