aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-13 20:05:47 +0100
committerAleksey Kladov <[email protected]>2021-06-13 20:05:47 +0100
commitff52167c9a8dd6f99a56a35eae8d634d0ddf1286 (patch)
treecb85647c41d797b885ac579312043df4b3112648 /crates/hir/src/lib.rs
parent935c53b92eea7c288b781ecd68436c9733ec8a83 (diff)
internal: kill diagnostic sink
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs28
1 files changed, 6 insertions, 22 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 7f689cd41..ce38396d0 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -27,7 +27,6 @@ mod attrs;
27mod has_source; 27mod has_source;
28 28
29pub mod diagnostics; 29pub mod diagnostics;
30pub mod diagnostics_sink;
31pub mod db; 30pub mod db;
32 31
33mod display; 32mod display;
@@ -78,10 +77,7 @@ use syntax::{
78}; 77};
79use tt::{Ident, Leaf, Literal, TokenTree}; 78use tt::{Ident, Leaf, Literal, TokenTree};
80 79
81use crate::{ 80use crate::db::{DefDatabase, HirDatabase};
82 db::{DefDatabase, HirDatabase},
83 diagnostics_sink::DiagnosticSink,
84};
85 81
86pub use crate::{ 82pub use crate::{
87 attrs::{HasAttrs, Namespace}, 83 attrs::{HasAttrs, Namespace},
@@ -457,15 +453,10 @@ impl Module {
457 self.id.def_map(db.upcast())[self.id.local_id].scope.visibility_of((*def).into()) 453 self.id.def_map(db.upcast())[self.id.local_id].scope.visibility_of((*def).into())
458 } 454 }
459 455
460 pub fn diagnostics( 456 pub fn diagnostics(self, db: &dyn HirDatabase, acc: &mut Vec<AnyDiagnostic>) {
461 self,
462 db: &dyn HirDatabase,
463 sink: &mut DiagnosticSink,
464 ) -> Vec<AnyDiagnostic> {
465 let _p = profile::span("Module::diagnostics").detail(|| { 457 let _p = profile::span("Module::diagnostics").detail(|| {
466 format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string())) 458 format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string()))
467 }); 459 });
468 let mut acc: Vec<AnyDiagnostic> = Vec::new();
469 let def_map = self.id.def_map(db.upcast()); 460 let def_map = self.id.def_map(db.upcast());
470 for diag in def_map.diagnostics() { 461 for diag in def_map.diagnostics() {
471 if diag.in_module != self.id.local_id { 462 if diag.in_module != self.id.local_id {
@@ -618,11 +609,11 @@ impl Module {
618 } 609 }
619 for decl in self.declarations(db) { 610 for decl in self.declarations(db) {
620 match decl { 611 match decl {
621 ModuleDef::Function(f) => acc.extend(f.diagnostics(db, sink)), 612 ModuleDef::Function(f) => f.diagnostics(db, acc),
622 ModuleDef::Module(m) => { 613 ModuleDef::Module(m) => {
623 // Only add diagnostics from inline modules 614 // Only add diagnostics from inline modules
624 if def_map[m.id.local_id].origin.is_inline() { 615 if def_map[m.id.local_id].origin.is_inline() {
625 acc.extend(m.diagnostics(db, sink)) 616 m.diagnostics(db, acc)
626 } 617 }
627 } 618 }
628 _ => acc.extend(decl.diagnostics(db)), 619 _ => acc.extend(decl.diagnostics(db)),
@@ -632,11 +623,10 @@ impl Module {
632 for impl_def in self.impl_defs(db) { 623 for impl_def in self.impl_defs(db) {
633 for item in impl_def.items(db) { 624 for item in impl_def.items(db) {
634 if let AssocItem::Function(f) = item { 625 if let AssocItem::Function(f) = item {
635 acc.extend(f.diagnostics(db, sink)); 626 f.diagnostics(db, acc);
636 } 627 }
637 } 628 }
638 } 629 }
639 acc
640 } 630 }
641 631
642 pub fn declarations(self, db: &dyn HirDatabase) -> Vec<ModuleDef> { 632 pub fn declarations(self, db: &dyn HirDatabase) -> Vec<ModuleDef> {
@@ -1035,12 +1025,7 @@ impl Function {
1035 db.function_data(self.id).is_async() 1025 db.function_data(self.id).is_async()
1036 } 1026 }
1037 1027
1038 pub fn diagnostics( 1028 pub fn diagnostics(self, db: &dyn HirDatabase, acc: &mut Vec<AnyDiagnostic>) {
1039 self,
1040 db: &dyn HirDatabase,
1041 sink: &mut DiagnosticSink,
1042 ) -> Vec<AnyDiagnostic> {
1043 let mut acc: Vec<AnyDiagnostic> = Vec::new();
1044 let krate = self.module(db).id.krate(); 1029 let krate = self.module(db).id.krate();
1045 1030
1046 let source_map = db.body_with_source_map(self.id.into()).1; 1031 let source_map = db.body_with_source_map(self.id.into()).1;
@@ -1225,7 +1210,6 @@ impl Function {
1225 for diag in hir_ty::diagnostics::validate_module_item(db, krate, self.id.into()) { 1210 for diag in hir_ty::diagnostics::validate_module_item(db, krate, self.id.into()) {
1226 acc.push(diag.into()) 1211 acc.push(diag.into())
1227 } 1212 }
1228 acc
1229 } 1213 }
1230 1214
1231 /// Whether this function declaration has a definition. 1215 /// Whether this function declaration has a definition.