aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-12-17 00:19:56 +0000
committerJonas Schievink <[email protected]>2020-12-17 00:19:56 +0000
commit6615fda695dfe6cb2c6792eed5d472b43ac63423 (patch)
tree06403ae68423f829e545b86835a96b4173c49519 /crates/hir_ty/src/diagnostics.rs
parent554dd215c729c3598ceb014f61d9d295d554036a (diff)
decl_check: don't pass `db` around so often
Diffstat (limited to 'crates/hir_ty/src/diagnostics.rs')
-rw-r--r--crates/hir_ty/src/diagnostics.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs
index 1c72f766e..14e18f5a1 100644
--- a/crates/hir_ty/src/diagnostics.rs
+++ b/crates/hir_ty/src/diagnostics.rs
@@ -6,6 +6,7 @@ mod decl_check;
6 6
7use std::{any::Any, fmt}; 7use std::{any::Any, fmt};
8 8
9use base_db::CrateId;
9use hir_def::{DefWithBodyId, ModuleDefId}; 10use hir_def::{DefWithBodyId, ModuleDefId};
10use hir_expand::diagnostics::{Diagnostic, DiagnosticCode, DiagnosticSink}; 11use hir_expand::diagnostics::{Diagnostic, DiagnosticCode, DiagnosticSink};
11use hir_expand::{name::Name, HirFileId, InFile}; 12use hir_expand::{name::Name, HirFileId, InFile};
@@ -18,12 +19,13 @@ pub use crate::diagnostics::expr::{record_literal_missing_fields, record_pattern
18 19
19pub fn validate_module_item( 20pub fn validate_module_item(
20 db: &dyn HirDatabase, 21 db: &dyn HirDatabase,
22 krate: CrateId,
21 owner: ModuleDefId, 23 owner: ModuleDefId,
22 sink: &mut DiagnosticSink<'_>, 24 sink: &mut DiagnosticSink<'_>,
23) { 25) {
24 let _p = profile::span("validate_module_item"); 26 let _p = profile::span("validate_module_item");
25 let mut validator = decl_check::DeclValidator::new(owner, sink); 27 let mut validator = decl_check::DeclValidator::new(db, krate, sink);
26 validator.validate_item(db); 28 validator.validate_item(owner);
27} 29}
28 30
29pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut DiagnosticSink<'_>) { 31pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut DiagnosticSink<'_>) {
@@ -407,7 +409,7 @@ mod tests {
407 for (module_id, _) in crate_def_map.modules.iter() { 409 for (module_id, _) in crate_def_map.modules.iter() {
408 for decl in crate_def_map[module_id].scope.declarations() { 410 for decl in crate_def_map[module_id].scope.declarations() {
409 let mut sink = DiagnosticSinkBuilder::new().build(&mut cb); 411 let mut sink = DiagnosticSinkBuilder::new().build(&mut cb);
410 validate_module_item(self, decl, &mut sink); 412 validate_module_item(self, krate, decl, &mut sink);
411 413
412 if let ModuleDefId::FunctionId(f) = decl { 414 if let ModuleDefId::FunctionId(f) = decl {
413 fns.push(f) 415 fns.push(f)
@@ -419,7 +421,12 @@ mod tests {
419 for item in impl_data.items.iter() { 421 for item in impl_data.items.iter() {
420 if let AssocItemId::FunctionId(f) = item { 422 if let AssocItemId::FunctionId(f) = item {
421 let mut sink = DiagnosticSinkBuilder::new().build(&mut cb); 423 let mut sink = DiagnosticSinkBuilder::new().build(&mut cb);
422 validate_module_item(self, ModuleDefId::FunctionId(*f), &mut sink); 424 validate_module_item(
425 self,
426 krate,
427 ModuleDefId::FunctionId(*f),
428 &mut sink,
429 );
423 fns.push(*f) 430 fns.push(*f)
424 } 431 }
425 } 432 }