aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/code_model.rs6
-rw-r--r--crates/ra_hir_def/src/nameres.rs7
2 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 3b479356f..500b34c17 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -7,7 +7,6 @@ use hir_def::{
7 builtin_type::BuiltinType, 7 builtin_type::BuiltinType,
8 docs::Documentation, 8 docs::Documentation,
9 expr::{BindingAnnotation, Pat, PatId}, 9 expr::{BindingAnnotation, Pat, PatId},
10 nameres::ModuleSource,
11 per_ns::PerNs, 10 per_ns::PerNs,
12 resolver::HasResolver, 11 resolver::HasResolver,
13 type_ref::{Mutability, TypeRef}, 12 type_ref::{Mutability, TypeRef},
@@ -193,13 +192,14 @@ impl Module {
193 192
194 pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) { 193 pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
195 let _p = profile("Module::diagnostics"); 194 let _p = profile("Module::diagnostics");
196 db.crate_def_map(self.id.krate).add_diagnostics(db, self.id.local_id, sink); 195 let crate_def_map = db.crate_def_map(self.id.krate);
196 crate_def_map.add_diagnostics(db, self.id.local_id, sink);
197 for decl in self.declarations(db) { 197 for decl in self.declarations(db) {
198 match decl { 198 match decl {
199 crate::ModuleDef::Function(f) => f.diagnostics(db, sink), 199 crate::ModuleDef::Function(f) => f.diagnostics(db, sink),
200 crate::ModuleDef::Module(m) => { 200 crate::ModuleDef::Module(m) => {
201 // Only add diagnostics from inline modules 201 // Only add diagnostics from inline modules
202 if let ModuleSource::Module(_) = m.definition_source(db).value { 202 if crate_def_map[m.id.local_id].origin.is_inline() {
203 m.diagnostics(db, sink) 203 m.diagnostics(db, sink)
204 } 204 }
205 } 205 }
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index 4d210eab1..e1a6a46df 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -145,6 +145,13 @@ impl ModuleOrigin {
145 } 145 }
146 } 146 }
147 147
148 pub fn is_inline(&self) -> bool {
149 match self {
150 ModuleOrigin::Inline { .. } => true,
151 ModuleOrigin::CrateRoot { .. } | ModuleOrigin::File { .. } => false,
152 }
153 }
154
148 /// Returns a node which defines this module. 155 /// Returns a node which defines this module.
149 /// That is, a file or a `mod foo {}` with items. 156 /// That is, a file or a `mod foo {}` with items.
150 fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> { 157 fn definition_source(&self, db: &impl DefDatabase) -> InFile<ModuleSource> {