aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-08 11:24:44 +0000
committerGitHub <[email protected]>2019-12-08 11:24:44 +0000
commit7a6b6ed0a5311cabee9d68a89100aed46523243b (patch)
treee0a20bb1f63f0aaa9e0c335a28ccb1172e9e2c77 /crates
parentb236f6aa499f98985acd07a34eb0c0d147bf8d5f (diff)
parent7aacf9a19739f53a45840df2d08b5f3cca761192 (diff)
Merge #2498
2498: Drop some unused methods r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/code_model.rs127
-rw-r--r--crates/ra_hir/src/debug.rs4
-rw-r--r--crates/ra_hir/src/from_id.rs4
-rw-r--r--crates/ra_hir/src/from_source.rs8
-rw-r--r--crates/ra_hir_def/src/resolver.rs42
-rw-r--r--crates/ra_ide/src/references/search_scope.rs16
6 files changed, 94 insertions, 107 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 4578a0ba8..9cbea024a 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -25,7 +25,7 @@ use hir_expand::{
25 MacroDefId, 25 MacroDefId,
26}; 26};
27use hir_ty::expr::ExprValidator; 27use hir_ty::expr::ExprValidator;
28use ra_db::{CrateId, Edition}; 28use ra_db::{CrateId, Edition, FileId};
29use ra_syntax::ast; 29use ra_syntax::ast;
30 30
31use crate::{ 31use crate::{
@@ -40,7 +40,7 @@ use crate::{
40/// root module. 40/// root module.
41#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 41#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
42pub struct Crate { 42pub struct Crate {
43 pub(crate) crate_id: CrateId, 43 pub(crate) id: CrateId,
44} 44}
45 45
46#[derive(Debug)] 46#[derive(Debug)]
@@ -50,33 +50,47 @@ pub struct CrateDependency {
50} 50}
51 51
52impl Crate { 52impl Crate {
53 pub fn crate_id(self) -> CrateId {
54 self.crate_id
55 }
56
57 pub fn dependencies(self, db: &impl DefDatabase) -> Vec<CrateDependency> { 53 pub fn dependencies(self, db: &impl DefDatabase) -> Vec<CrateDependency> {
58 db.crate_graph() 54 db.crate_graph()
59 .dependencies(self.crate_id) 55 .dependencies(self.id)
60 .map(|dep| { 56 .map(|dep| {
61 let krate = Crate { crate_id: dep.crate_id() }; 57 let krate = Crate { id: dep.crate_id() };
62 let name = dep.as_name(); 58 let name = dep.as_name();
63 CrateDependency { krate, name } 59 CrateDependency { krate, name }
64 }) 60 })
65 .collect() 61 .collect()
66 } 62 }
67 63
64 // FIXME: add `transitive_reverse_dependencies`.
65 pub fn reverse_dependencies(self, db: &impl DefDatabase) -> Vec<Crate> {
66 let crate_graph = db.crate_graph();
67 crate_graph
68 .iter()
69 .filter(|&krate| crate_graph.dependencies(krate).any(|it| it.crate_id == self.id))
70 .map(|id| Crate { id })
71 .collect()
72 }
73
68 pub fn root_module(self, db: &impl DefDatabase) -> Option<Module> { 74 pub fn root_module(self, db: &impl DefDatabase) -> Option<Module> {
69 let module_id = db.crate_def_map(self.crate_id).root; 75 let module_id = db.crate_def_map(self.id).root;
70 Some(Module::new(self, module_id)) 76 Some(Module::new(self, module_id))
71 } 77 }
72 78
79 pub fn root_file(self, db: &impl DefDatabase) -> FileId {
80 db.crate_graph().crate_root(self.id)
81 }
82
73 pub fn edition(self, db: &impl DefDatabase) -> Edition { 83 pub fn edition(self, db: &impl DefDatabase) -> Edition {
74 let crate_graph = db.crate_graph(); 84 let crate_graph = db.crate_graph();
75 crate_graph.edition(self.crate_id) 85 crate_graph.edition(self.id)
76 } 86 }
77 87
78 pub fn all(db: &impl DefDatabase) -> Vec<Crate> { 88 pub fn all(db: &impl DefDatabase) -> Vec<Crate> {
79 db.crate_graph().iter().map(|crate_id| Crate { crate_id }).collect() 89 db.crate_graph().iter().map(|id| Crate { id }).collect()
90 }
91
92 pub fn crate_id(self) -> CrateId {
93 self.id
80 } 94 }
81} 95}
82 96
@@ -115,7 +129,7 @@ pub use hir_def::attr::Attrs;
115 129
116impl Module { 130impl Module {
117 pub(crate) fn new(krate: Crate, crate_module_id: LocalModuleId) -> Module { 131 pub(crate) fn new(krate: Crate, crate_module_id: LocalModuleId) -> Module {
118 Module { id: ModuleId { krate: krate.crate_id, local_id: crate_module_id } } 132 Module { id: ModuleId { krate: krate.id, local_id: crate_module_id } }
119 } 133 }
120 134
121 /// Name of this module. 135 /// Name of this module.
@@ -133,7 +147,7 @@ impl Module {
133 147
134 /// Returns the crate this module is part of. 148 /// Returns the crate this module is part of.
135 pub fn krate(self) -> Crate { 149 pub fn krate(self) -> Crate {
136 Crate { crate_id: self.id.krate } 150 Crate { id: self.id.krate }
137 } 151 }
138 152
139 /// Topmost parent of this module. Every module has a `crate_root`, but some 153 /// Topmost parent of this module. Every module has a `crate_root`, but some
@@ -144,13 +158,6 @@ impl Module {
144 self.with_module_id(def_map.root) 158 self.with_module_id(def_map.root)
145 } 159 }
146 160
147 /// Finds a child module with the specified name.
148 pub fn child(self, db: &impl DefDatabase, name: &Name) -> Option<Module> {
149 let def_map = db.crate_def_map(self.id.krate);
150 let child_id = def_map[self.id.local_id].children.get(name)?;
151 Some(self.with_module_id(*child_id))
152 }
153
154 /// Iterates over all child modules. 161 /// Iterates over all child modules.
155 pub fn children(self, db: &impl DefDatabase) -> impl Iterator<Item = Module> { 162 pub fn children(self, db: &impl DefDatabase) -> impl Iterator<Item = Module> {
156 let def_map = db.crate_def_map(self.id.krate); 163 let def_map = db.crate_def_map(self.id.krate);
@@ -224,7 +231,7 @@ impl Module {
224 def_map[self.id.local_id].impls.iter().copied().map(ImplBlock::from).collect() 231 def_map[self.id.local_id].impls.iter().copied().map(ImplBlock::from).collect()
225 } 232 }
226 233
227 fn with_module_id(self, module_id: LocalModuleId) -> Module { 234 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module {
228 Module::new(self.krate(), module_id) 235 Module::new(self.krate(), module_id)
229 } 236 }
230} 237}
@@ -251,8 +258,10 @@ impl StructField {
251 self.parent.variant_data(db).fields()[self.id].name.clone() 258 self.parent.variant_data(db).fields()[self.id].name.clone()
252 } 259 }
253 260
254 pub fn ty(&self, db: &impl HirDatabase) -> Ty { 261 pub fn ty(&self, db: &impl HirDatabase) -> Type {
255 db.field_types(self.parent.into())[self.id].clone() 262 let var_id = self.parent.into();
263 let ty = db.field_types(var_id)[self.id].clone();
264 Type::new(db, self.parent.module(db).id.krate.into(), var_id, ty)
256 } 265 }
257 266
258 pub fn parent_def(&self, _db: &impl HirDatabase) -> VariantDef { 267 pub fn parent_def(&self, _db: &impl HirDatabase) -> VariantDef {
@@ -287,23 +296,10 @@ impl Struct {
287 .collect() 296 .collect()
288 } 297 }
289 298
290 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
291 db.struct_data(self.id.into())
292 .variant_data
293 .fields()
294 .iter()
295 .find(|(_id, data)| data.name == *name)
296 .map(|(id, _)| StructField { parent: self.into(), id })
297 }
298
299 pub fn ty(self, db: &impl HirDatabase) -> Type { 299 pub fn ty(self, db: &impl HirDatabase) -> Type {
300 Type::from_def(db, self.id.module(db).krate, self.id) 300 Type::from_def(db, self.id.module(db).krate, self.id)
301 } 301 }
302 302
303 pub fn constructor_ty(self, db: &impl HirDatabase) -> Ty {
304 db.value_ty(self.id.into())
305 }
306
307 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 303 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
308 db.struct_data(self.id.into()).variant_data.clone() 304 db.struct_data(self.id.into()).variant_data.clone()
309 } 305 }
@@ -336,15 +332,6 @@ impl Union {
336 .collect() 332 .collect()
337 } 333 }
338 334
339 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
340 db.union_data(self.id)
341 .variant_data
342 .fields()
343 .iter()
344 .find(|(_id, data)| data.name == *name)
345 .map(|(id, _)| StructField { parent: self.into(), id })
346 }
347
348 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 335 fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
349 db.union_data(self.id).variant_data.clone() 336 db.union_data(self.id).variant_data.clone()
350 } 337 }
@@ -376,11 +363,6 @@ impl Enum {
376 .collect() 363 .collect()
377 } 364 }
378 365
379 pub fn variant(self, db: &impl DefDatabase, name: &Name) -> Option<EnumVariant> {
380 let id = db.enum_data(self.id).variant(name)?;
381 Some(EnumVariant { parent: self, id })
382 }
383
384 pub fn ty(self, db: &impl HirDatabase) -> Type { 366 pub fn ty(self, db: &impl HirDatabase) -> Type {
385 Type::from_def(db, self.id.module(db).krate, self.id) 367 Type::from_def(db, self.id.module(db).krate, self.id)
386 } 368 }
@@ -412,14 +394,6 @@ impl EnumVariant {
412 .collect() 394 .collect()
413 } 395 }
414 396
415 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
416 self.variant_data(db)
417 .fields()
418 .iter()
419 .find(|(_id, data)| data.name == *name)
420 .map(|(id, _)| StructField { parent: self.into(), id })
421 }
422
423 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 397 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
424 db.enum_data(self.parent.id).variants[self.id].variant_data.clone() 398 db.enum_data(self.parent.id).variants[self.id].variant_data.clone()
425 } 399 }
@@ -545,10 +519,6 @@ impl Function {
545 db.body(self.id.into()) 519 db.body(self.id.into())
546 } 520 }
547 521
548 pub fn ty(self, db: &impl HirDatabase) -> Ty {
549 db.value_ty(self.id.into())
550 }
551
552 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { 522 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
553 db.infer(self.id.into()) 523 db.infer(self.id.into())
554 } 524 }
@@ -878,11 +848,11 @@ pub struct ImplBlock {
878 848
879impl ImplBlock { 849impl ImplBlock {
880 pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplBlock> { 850 pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplBlock> {
881 let impls = db.impls_in_crate(krate.crate_id); 851 let impls = db.impls_in_crate(krate.id);
882 impls.all_impls().map(Self::from).collect() 852 impls.all_impls().map(Self::from).collect()
883 } 853 }
884 pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplBlock> { 854 pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplBlock> {
885 let impls = db.impls_in_crate(krate.crate_id); 855 let impls = db.impls_in_crate(krate.id);
886 impls.lookup_impl_blocks_for_trait(trait_.id).map(Self::from).collect() 856 impls.lookup_impl_blocks_for_trait(trait_.id).map(Self::from).collect()
887 } 857 }
888 858
@@ -915,7 +885,7 @@ impl ImplBlock {
915 } 885 }
916 886
917 pub fn krate(&self, db: &impl DefDatabase) -> Crate { 887 pub fn krate(&self, db: &impl DefDatabase) -> Crate {
918 Crate { crate_id: self.module(db).id.krate } 888 Crate { id: self.module(db).id.krate }
919 } 889 }
920} 890}
921 891
@@ -926,15 +896,19 @@ pub struct Type {
926} 896}
927 897
928impl Type { 898impl Type {
899 fn new(db: &impl HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type {
900 let resolver = lexical_env.resolver(db);
901 let environment = TraitEnvironment::lower(db, &resolver);
902 Type { krate, ty: InEnvironment { value: ty, environment } }
903 }
904
929 fn from_def( 905 fn from_def(
930 db: &impl HirDatabase, 906 db: &impl HirDatabase,
931 krate: CrateId, 907 krate: CrateId,
932 def: impl HasResolver + Into<TyDefId>, 908 def: impl HasResolver + Into<TyDefId>,
933 ) -> Type { 909 ) -> Type {
934 let resolver = def.resolver(db);
935 let environment = TraitEnvironment::lower(db, &resolver);
936 let ty = db.ty(def.into()); 910 let ty = db.ty(def.into());
937 Type { krate, ty: InEnvironment { value: ty, environment } } 911 Type::new(db, krate, def, ty)
938 } 912 }
939 913
940 pub fn is_bool(&self) -> bool { 914 pub fn is_bool(&self) -> bool {
@@ -1025,11 +999,16 @@ impl Type {
1025 ) -> Vec<(StructField, Type)> { 999 ) -> Vec<(StructField, Type)> {
1026 // FIXME: check that ty and def match 1000 // FIXME: check that ty and def match
1027 match &self.ty.value { 1001 match &self.ty.value {
1028 Ty::Apply(a_ty) => def 1002 Ty::Apply(a_ty) => {
1029 .fields(db) 1003 let field_types = db.field_types(def.into());
1030 .into_iter() 1004 def.fields(db)
1031 .map(|it| (it, self.derived(it.ty(db).subst(&a_ty.parameters)))) 1005 .into_iter()
1032 .collect(), 1006 .map(|it| {
1007 let ty = field_types[it.id].clone().subst(&a_ty.parameters);
1008 (it, self.derived(ty))
1009 })
1010 .collect()
1011 }
1033 _ => Vec::new(), 1012 _ => Vec::new(),
1034 } 1013 }
1035 } 1014 }
@@ -1053,7 +1032,7 @@ impl Type {
1053 krate: Crate, 1032 krate: Crate,
1054 mut callback: impl FnMut(AssocItem) -> Option<T>, 1033 mut callback: impl FnMut(AssocItem) -> Option<T>,
1055 ) -> Option<T> { 1034 ) -> Option<T> {
1056 for krate in self.ty.value.def_crates(db, krate.crate_id)? { 1035 for krate in self.ty.value.def_crates(db, krate.id)? {
1057 let impls = db.impls_in_crate(krate); 1036 let impls = db.impls_in_crate(krate);
1058 1037
1059 for impl_block in impls.lookup_impl_blocks(&self.ty.value) { 1038 for impl_block in impls.lookup_impl_blocks(&self.ty.value) {
diff --git a/crates/ra_hir/src/debug.rs b/crates/ra_hir/src/debug.rs
index 7a2810f71..6cd5c8cb9 100644
--- a/crates/ra_hir/src/debug.rs
+++ b/crates/ra_hir/src/debug.rs
@@ -57,9 +57,9 @@ pub trait HirDebugDatabase {
57impl<DB: HirDebugHelper> HirDebugDatabase for DB { 57impl<DB: HirDebugHelper> HirDebugDatabase for DB {
58 fn debug_crate(&self, krate: Crate, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { 58 fn debug_crate(&self, krate: Crate, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
59 let mut builder = fmt.debug_tuple("Crate"); 59 let mut builder = fmt.debug_tuple("Crate");
60 match self.crate_name(krate.crate_id) { 60 match self.crate_name(krate.id) {
61 Some(name) => builder.field(&name), 61 Some(name) => builder.field(&name),
62 None => builder.field(&krate.crate_id), 62 None => builder.field(&krate.id),
63 } 63 }
64 .finish() 64 .finish()
65 } 65 }
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs
index e96a18d12..0398d0ee6 100644
--- a/crates/ra_hir/src/from_id.rs
+++ b/crates/ra_hir/src/from_id.rs
@@ -14,8 +14,8 @@ use crate::{
14}; 14};
15 15
16impl From<ra_db::CrateId> for Crate { 16impl From<ra_db::CrateId> for Crate {
17 fn from(crate_id: ra_db::CrateId) -> Self { 17 fn from(id: ra_db::CrateId) -> Self {
18 Crate { crate_id } 18 Crate { id }
19 } 19 }
20} 20}
21 21
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index 4acc038e4..307f3d5bf 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -95,7 +95,7 @@ impl FromSource for MacroDef {
95 95
96 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax())); 96 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax()));
97 let module = Module::from_definition(db, InFile::new(src.file_id, module_src))?; 97 let module = Module::from_definition(db, InFile::new(src.file_id, module_src))?;
98 let krate = Some(module.krate().crate_id()); 98 let krate = Some(module.krate().id);
99 99
100 let ast_id = Some(AstId::new(src.file_id, db.ast_id_map(src.file_id).ast_id(&src.value))); 100 let ast_id = Some(AstId::new(src.file_id, db.ast_id_map(src.file_id).ast_id(&src.value)));
101 101
@@ -216,8 +216,10 @@ impl Module {
216 } 216 }
217 }?; 217 }?;
218 218
219 let child_name = src.value.name()?; 219 let child_name = src.value.name()?.as_name();
220 parent_module.child(db, &child_name.as_name()) 220 let def_map = db.crate_def_map(parent_module.id.krate);
221 let child_id = def_map[parent_module.id.local_id].children.get(&child_name)?;
222 Some(parent_module.with_module_id(*child_id))
221 } 223 }
222 224
223 pub fn from_definition(db: &impl DefDatabase, src: InFile<ModuleSource>) -> Option<Self> { 225 pub fn from_definition(db: &impl DefDatabase, src: InFile<ModuleSource>) -> Option<Self> {
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 4c859e497..9484a61d5 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -19,7 +19,7 @@ use crate::{
19 per_ns::PerNs, 19 per_ns::PerNs,
20 AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, 20 AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
21 GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, 21 GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId,
22 StructId, TraitId, TypeAliasId, TypeParamId, 22 StructId, TraitId, TypeAliasId, TypeParamId, VariantId,
23}; 23};
24 24
25#[derive(Debug, Clone, Default)] 25#[derive(Debug, Clone, Default)]
@@ -544,16 +544,6 @@ impl HasResolver for FunctionId {
544 } 544 }
545} 545}
546 546
547impl HasResolver for DefWithBodyId {
548 fn resolver(self, db: &impl DefDatabase) -> Resolver {
549 match self {
550 DefWithBodyId::ConstId(c) => c.resolver(db),
551 DefWithBodyId::FunctionId(f) => f.resolver(db),
552 DefWithBodyId::StaticId(s) => s.resolver(db),
553 }
554 }
555}
556
557impl HasResolver for ConstId { 547impl HasResolver for ConstId {
558 fn resolver(self, db: &impl DefDatabase) -> Resolver { 548 fn resolver(self, db: &impl DefDatabase) -> Resolver {
559 self.lookup(db).container.resolver(db) 549 self.lookup(db).container.resolver(db)
@@ -572,6 +562,25 @@ impl HasResolver for TypeAliasId {
572 } 562 }
573} 563}
574 564
565impl HasResolver for ImplId {
566 fn resolver(self, db: &impl DefDatabase) -> Resolver {
567 self.module(db)
568 .resolver(db)
569 .push_generic_params_scope(db, self.into())
570 .push_impl_block_scope(self)
571 }
572}
573
574impl HasResolver for DefWithBodyId {
575 fn resolver(self, db: &impl DefDatabase) -> Resolver {
576 match self {
577 DefWithBodyId::ConstId(c) => c.resolver(db),
578 DefWithBodyId::FunctionId(f) => f.resolver(db),
579 DefWithBodyId::StaticId(s) => s.resolver(db),
580 }
581 }
582}
583
575impl HasResolver for ContainerId { 584impl HasResolver for ContainerId {
576 fn resolver(self, db: &impl DefDatabase) -> Resolver { 585 fn resolver(self, db: &impl DefDatabase) -> Resolver {
577 match self { 586 match self {
@@ -596,11 +605,12 @@ impl HasResolver for GenericDefId {
596 } 605 }
597} 606}
598 607
599impl HasResolver for ImplId { 608impl HasResolver for VariantId {
600 fn resolver(self, db: &impl DefDatabase) -> Resolver { 609 fn resolver(self, db: &impl DefDatabase) -> Resolver {
601 self.module(db) 610 match self {
602 .resolver(db) 611 VariantId::EnumVariantId(it) => it.parent.resolver(db),
603 .push_generic_params_scope(db, self.into()) 612 VariantId::StructId(it) => it.resolver(db),
604 .push_impl_block_scope(self) 613 VariantId::UnionId(it) => it.resolver(db),
614 }
605 } 615 }
606} 616}
diff --git a/crates/ra_ide/src/references/search_scope.rs b/crates/ra_ide/src/references/search_scope.rs
index f5c9589f4..241dd358f 100644
--- a/crates/ra_ide/src/references/search_scope.rs
+++ b/crates/ra_ide/src/references/search_scope.rs
@@ -5,7 +5,7 @@
5use std::mem; 5use std::mem;
6 6
7use hir::{DefWithBody, HasSource, ModuleSource}; 7use hir::{DefWithBody, HasSource, ModuleSource};
8use ra_db::{FileId, SourceDatabase, SourceDatabaseExt}; 8use ra_db::{FileId, SourceDatabaseExt};
9use ra_prof::profile; 9use ra_prof::profile;
10use ra_syntax::{AstNode, TextRange}; 10use ra_syntax::{AstNode, TextRange};
11use rustc_hash::FxHashMap; 11use rustc_hash::FxHashMap;
@@ -120,15 +120,11 @@ impl NameDefinition {
120 } 120 }
121 if vis.as_str() == "pub" { 121 if vis.as_str() == "pub" {
122 let krate = self.container.krate(); 122 let krate = self.container.krate();
123 let crate_graph = db.crate_graph(); 123 for rev_dep in krate.reverse_dependencies(db) {
124 for crate_id in crate_graph.iter() { 124 let root_file = rev_dep.root_file(db);
125 let mut crate_deps = crate_graph.dependencies(crate_id); 125 let source_root_id = db.file_source_root(root_file);
126 if crate_deps.any(|dep| dep.crate_id() == krate.crate_id()) { 126 let source_root = db.source_root(source_root_id);
127 let root_file = crate_graph.crate_root(crate_id); 127 res.extend(source_root.walk().map(|id| (id, None)));
128 let source_root_id = db.file_source_root(root_file);
129 let source_root = db.source_root(source_root_id);
130 res.extend(source_root.walk().map(|id| (id, None)));
131 }
132 } 128 }
133 return SearchScope::new(res); 129 return SearchScope::new(res);
134 } 130 }