aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/search.rs25
1 files changed, 21 insertions, 4 deletions
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs
index 8e93de277..5fdcb13cf 100644
--- a/crates/ide_db/src/search.rs
+++ b/crates/ide_db/src/search.rs
@@ -7,7 +7,7 @@
7use std::{convert::TryInto, mem}; 7use std::{convert::TryInto, mem};
8 8
9use base_db::{FileId, FileRange, SourceDatabase, SourceDatabaseExt}; 9use base_db::{FileId, FileRange, SourceDatabase, SourceDatabaseExt};
10use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; 10use hir::{DefWithBody, HasAttrs, HasSource, Module, ModuleSource, Semantics, Visibility};
11use once_cell::unsync::Lazy; 11use once_cell::unsync::Lazy;
12use rustc_hash::FxHashMap; 12use rustc_hash::FxHashMap;
13use syntax::{ast, match_ast, AstNode, TextRange, TextSize}; 13use syntax::{ast, match_ast, AstNode, TextRange, TextSize};
@@ -244,9 +244,8 @@ impl Definition {
244 return SearchScope::new(res); 244 return SearchScope::new(res);
245 } 245 }
246 246
247 if let Some(Visibility::Public) = vis { 247 let rev_dep_scope = || {
248 let mut res = FxHashMap::default(); 248 let mut res = FxHashMap::default();
249
250 let krate = module.krate(); 249 let krate = module.krate();
251 for rev_dep in krate.transitive_reverse_dependencies(db) { 250 for rev_dep in krate.transitive_reverse_dependencies(db) {
252 let root_file = rev_dep.root_file(db); 251 let root_file = rev_dep.root_file(db);
@@ -254,7 +253,25 @@ impl Definition {
254 let source_root = db.source_root(source_root_id); 253 let source_root = db.source_root(source_root_id);
255 res.extend(source_root.iter().map(|id| (id, None))); 254 res.extend(source_root.iter().map(|id| (id, None)));
256 } 255 }
257 return SearchScope::new(res); 256 SearchScope::new(res)
257 };
258
259 if let Definition::Macro(macro_def) = self {
260 if macro_def.is_declarative() {
261 return if macro_def.attrs(db).by_key("macro_export").exists() {
262 rev_dep_scope()
263 } else {
264 let source_root_id = db.file_source_root(file_id);
265 let source_root = db.source_root(source_root_id);
266 SearchScope::new(
267 source_root.iter().map(|id| (id, None)).collect::<FxHashMap<_, _>>(),
268 )
269 };
270 }
271 }
272
273 if let Some(Visibility::Public) = vis {
274 return rev_dep_scope();
258 } 275 }
259 276
260 let mut res = FxHashMap::default(); 277 let mut res = FxHashMap::default();