mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Don't parse child modules when doing diagnostics
This commit is contained in:
parent
4a9e4ec7e1
commit
21ea62d292
2 changed files with 10 additions and 3 deletions
|
@ -7,7 +7,6 @@ use hir_def::{
|
||||||
builtin_type::BuiltinType,
|
builtin_type::BuiltinType,
|
||||||
docs::Documentation,
|
docs::Documentation,
|
||||||
expr::{BindingAnnotation, Pat, PatId},
|
expr::{BindingAnnotation, Pat, PatId},
|
||||||
nameres::ModuleSource,
|
|
||||||
per_ns::PerNs,
|
per_ns::PerNs,
|
||||||
resolver::HasResolver,
|
resolver::HasResolver,
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::{Mutability, TypeRef},
|
||||||
|
@ -193,13 +192,14 @@ impl Module {
|
||||||
|
|
||||||
pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
|
pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
|
||||||
let _p = profile("Module::diagnostics");
|
let _p = profile("Module::diagnostics");
|
||||||
db.crate_def_map(self.id.krate).add_diagnostics(db, self.id.local_id, sink);
|
let crate_def_map = db.crate_def_map(self.id.krate);
|
||||||
|
crate_def_map.add_diagnostics(db, self.id.local_id, sink);
|
||||||
for decl in self.declarations(db) {
|
for decl in self.declarations(db) {
|
||||||
match decl {
|
match decl {
|
||||||
crate::ModuleDef::Function(f) => f.diagnostics(db, sink),
|
crate::ModuleDef::Function(f) => f.diagnostics(db, sink),
|
||||||
crate::ModuleDef::Module(m) => {
|
crate::ModuleDef::Module(m) => {
|
||||||
// Only add diagnostics from inline modules
|
// Only add diagnostics from inline modules
|
||||||
if let ModuleSource::Module(_) = m.definition_source(db).value {
|
if crate_def_map[m.id.local_id].origin.is_inline() {
|
||||||
m.diagnostics(db, sink)
|
m.diagnostics(db, sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,13 @@ impl ModuleOrigin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_inline(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
ModuleOrigin::Inline { .. } => true,
|
||||||
|
ModuleOrigin::CrateRoot { .. } | ModuleOrigin::File { .. } => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a node which defines this module.
|
/// Returns a node which defines this module.
|
||||||
/// That is, a file or a `mod foo {}` with items.
|
/// That is, a file or a `mod foo {}` with items.
|
||||||
fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> {
|
fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> {
|
||||||
|
|
Loading…
Reference in a new issue