diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/completion/src/completions/attribute.rs | 9 | ||||
-rw-r--r-- | crates/hir_def/src/body.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/db.rs | 10 | ||||
-rw-r--r-- | crates/hir_def/src/find_path.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/nameres.rs | 12 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 14 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/path_resolution.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/tests.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/resolver.rs | 12 | ||||
-rw-r--r-- | crates/hir_def/src/visibility.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/tests.rs | 6 |
11 files changed, 41 insertions, 42 deletions
diff --git a/crates/completion/src/completions/attribute.rs b/crates/completion/src/completions/attribute.rs index e5522980d..ab25a8c58 100644 --- a/crates/completion/src/completions/attribute.rs +++ b/crates/completion/src/completions/attribute.rs | |||
@@ -99,13 +99,14 @@ const ATTRIBUTES: &[AttrCompletion] = &[ | |||
99 | Some("export_name"), | 99 | Some("export_name"), |
100 | Some(r#"export_name = "${0:exported_symbol_name}""#), | 100 | Some(r#"export_name = "${0:exported_symbol_name}""#), |
101 | ), | 101 | ), |
102 | attr(r#"doc(alias = "…")"#, Some("docalias"), Some(r#"doc(alias = "${0:docs}")"#)), | ||
102 | attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)), | 103 | attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)), |
103 | attr("feature(…)", Some("feature"), Some("feature(${0:flag})")).prefer_inner(), | 104 | attr("feature(…)", Some("feature"), Some("feature(${0:flag})")).prefer_inner(), |
104 | attr("forbid(…)", Some("forbid"), Some("forbid(${0:lint})")), | 105 | attr("forbid(…)", Some("forbid"), Some("forbid(${0:lint})")), |
105 | // FIXME: resolve through macro resolution? | 106 | // FIXME: resolve through macro resolution? |
106 | attr("global_allocator", None, None).prefer_inner(), | 107 | attr("global_allocator", None, None).prefer_inner(), |
107 | attr(r#"ignore = "…""#, Some("ignore"), Some(r#"ignore = "${0:reason}""#)), | 108 | attr(r#"ignore = "…""#, Some("ignore"), Some(r#"ignore = "${0:reason}""#)), |
108 | attr("inline(…)", Some("inline"), Some("inline(${0:lint})")), | 109 | attr("inline", Some("inline"), Some("inline")), |
109 | attr("link", None, None), | 110 | attr("link", None, None), |
110 | attr(r#"link_name = "…""#, Some("link_name"), Some(r#"link_name = "${0:symbol_name}""#)), | 111 | attr(r#"link_name = "…""#, Some("link_name"), Some(r#"link_name = "${0:symbol_name}""#)), |
111 | attr( | 112 | attr( |
@@ -468,10 +469,11 @@ struct Test {} | |||
468 | at deprecated | 469 | at deprecated |
469 | at derive(…) | 470 | at derive(…) |
470 | at export_name = "…" | 471 | at export_name = "…" |
472 | at doc(alias = "…") | ||
471 | at doc = "…" | 473 | at doc = "…" |
472 | at forbid(…) | 474 | at forbid(…) |
473 | at ignore = "…" | 475 | at ignore = "…" |
474 | at inline(…) | 476 | at inline |
475 | at link | 477 | at link |
476 | at link_name = "…" | 478 | at link_name = "…" |
477 | at link_section = "…" | 479 | at link_section = "…" |
@@ -515,12 +517,13 @@ struct Test {} | |||
515 | at deprecated | 517 | at deprecated |
516 | at derive(…) | 518 | at derive(…) |
517 | at export_name = "…" | 519 | at export_name = "…" |
520 | at doc(alias = "…") | ||
518 | at doc = "…" | 521 | at doc = "…" |
519 | at feature(…) | 522 | at feature(…) |
520 | at forbid(…) | 523 | at forbid(…) |
521 | at global_allocator | 524 | at global_allocator |
522 | at ignore = "…" | 525 | at ignore = "…" |
523 | at inline(…) | 526 | at inline |
524 | at link | 527 | at link |
525 | at link_name = "…" | 528 | at link_name = "…" |
526 | at link_section = "…" | 529 | at link_section = "…" |
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 344f0b6c0..3b2dd0f6e 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -29,7 +29,7 @@ use crate::{ | |||
29 | expr::{Expr, ExprId, Label, LabelId, Pat, PatId}, | 29 | expr::{Expr, ExprId, Label, LabelId, Pat, PatId}, |
30 | item_scope::BuiltinShadowMode, | 30 | item_scope::BuiltinShadowMode, |
31 | item_scope::ItemScope, | 31 | item_scope::ItemScope, |
32 | nameres::CrateDefMap, | 32 | nameres::DefMap, |
33 | path::{ModPath, Path}, | 33 | path::{ModPath, Path}, |
34 | src::HasSource, | 34 | src::HasSource, |
35 | AsMacroCall, DefWithBodyId, HasModule, Lookup, ModuleId, | 35 | AsMacroCall, DefWithBodyId, HasModule, Lookup, ModuleId, |
@@ -45,7 +45,7 @@ pub(crate) struct CfgExpander { | |||
45 | 45 | ||
46 | pub(crate) struct Expander { | 46 | pub(crate) struct Expander { |
47 | cfg_expander: CfgExpander, | 47 | cfg_expander: CfgExpander, |
48 | crate_def_map: Arc<CrateDefMap>, | 48 | crate_def_map: Arc<DefMap>, |
49 | current_file_id: HirFileId, | 49 | current_file_id: HirFileId, |
50 | ast_id_map: Arc<AstIdMap>, | 50 | ast_id_map: Arc<AstIdMap>, |
51 | module: ModuleId, | 51 | module: ModuleId, |
diff --git a/crates/hir_def/src/db.rs b/crates/hir_def/src/db.rs index 6ef9fe790..91c8d45cd 100644 --- a/crates/hir_def/src/db.rs +++ b/crates/hir_def/src/db.rs | |||
@@ -15,7 +15,7 @@ use crate::{ | |||
15 | import_map::ImportMap, | 15 | import_map::ImportMap, |
16 | item_tree::ItemTree, | 16 | item_tree::ItemTree, |
17 | lang_item::{LangItemTarget, LangItems}, | 17 | lang_item::{LangItemTarget, LangItems}, |
18 | nameres::CrateDefMap, | 18 | nameres::DefMap, |
19 | AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, FunctionId, FunctionLoc, | 19 | AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, FunctionId, FunctionLoc, |
20 | GenericDefId, ImplId, ImplLoc, LocalEnumVariantId, LocalFieldId, StaticId, StaticLoc, StructId, | 20 | GenericDefId, ImplId, ImplLoc, LocalEnumVariantId, LocalFieldId, StaticId, StaticLoc, StructId, |
21 | StructLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc, VariantId, | 21 | StructLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc, VariantId, |
@@ -50,10 +50,10 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> { | |||
50 | 50 | ||
51 | #[salsa::invoke(crate_def_map_wait)] | 51 | #[salsa::invoke(crate_def_map_wait)] |
52 | #[salsa::transparent] | 52 | #[salsa::transparent] |
53 | fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>; | 53 | fn crate_def_map(&self, krate: CrateId) -> Arc<DefMap>; |
54 | 54 | ||
55 | #[salsa::invoke(CrateDefMap::crate_def_map_query)] | 55 | #[salsa::invoke(DefMap::crate_def_map_query)] |
56 | fn crate_def_map_query(&self, krate: CrateId) -> Arc<CrateDefMap>; | 56 | fn crate_def_map_query(&self, krate: CrateId) -> Arc<DefMap>; |
57 | 57 | ||
58 | #[salsa::invoke(StructData::struct_data_query)] | 58 | #[salsa::invoke(StructData::struct_data_query)] |
59 | fn struct_data(&self, id: StructId) -> Arc<StructData>; | 59 | fn struct_data(&self, id: StructId) -> Arc<StructData>; |
@@ -112,7 +112,7 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> { | |||
112 | fn import_map(&self, krate: CrateId) -> Arc<ImportMap>; | 112 | fn import_map(&self, krate: CrateId) -> Arc<ImportMap>; |
113 | } | 113 | } |
114 | 114 | ||
115 | fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { | 115 | fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<DefMap> { |
116 | let _p = profile::span("crate_def_map:wait"); | 116 | let _p = profile::span("crate_def_map:wait"); |
117 | db.crate_def_map_query(krate) | 117 | db.crate_def_map_query(krate) |
118 | } | 118 | } |
diff --git a/crates/hir_def/src/find_path.rs b/crates/hir_def/src/find_path.rs index 4a212d291..422a6eeb4 100644 --- a/crates/hir_def/src/find_path.rs +++ b/crates/hir_def/src/find_path.rs | |||
@@ -4,7 +4,7 @@ use hir_expand::name::{known, AsName, Name}; | |||
4 | use rustc_hash::FxHashSet; | 4 | use rustc_hash::FxHashSet; |
5 | use test_utils::mark; | 5 | use test_utils::mark; |
6 | 6 | ||
7 | use crate::nameres::CrateDefMap; | 7 | use crate::nameres::DefMap; |
8 | use crate::{ | 8 | use crate::{ |
9 | db::DefDatabase, | 9 | db::DefDatabase, |
10 | item_scope::ItemInNs, | 10 | item_scope::ItemInNs, |
@@ -47,7 +47,7 @@ impl ModPath { | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | fn check_self_super(def_map: &CrateDefMap, item: ItemInNs, from: ModuleId) -> Option<ModPath> { | 50 | fn check_self_super(def_map: &DefMap, item: ItemInNs, from: ModuleId) -> Option<ModPath> { |
51 | if item == ItemInNs::Types(from.into()) { | 51 | if item == ItemInNs::Types(from.into()) { |
52 | // - if the item is the module we're in, use `self` | 52 | // - if the item is the module we're in, use `self` |
53 | Some(ModPath::from_segments(PathKind::Super(0), Vec::new())) | 53 | Some(ModPath::from_segments(PathKind::Super(0), Vec::new())) |
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 50acc3f54..769a557ad 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs | |||
@@ -74,7 +74,7 @@ use crate::{ | |||
74 | 74 | ||
75 | /// Contains all top-level defs from a macro-expanded crate | 75 | /// Contains all top-level defs from a macro-expanded crate |
76 | #[derive(Debug, PartialEq, Eq)] | 76 | #[derive(Debug, PartialEq, Eq)] |
77 | pub struct CrateDefMap { | 77 | pub struct DefMap { |
78 | pub root: LocalModuleId, | 78 | pub root: LocalModuleId, |
79 | pub modules: Arena<ModuleData>, | 79 | pub modules: Arena<ModuleData>, |
80 | pub(crate) krate: CrateId, | 80 | pub(crate) krate: CrateId, |
@@ -88,7 +88,7 @@ pub struct CrateDefMap { | |||
88 | diagnostics: Vec<DefDiagnostic>, | 88 | diagnostics: Vec<DefDiagnostic>, |
89 | } | 89 | } |
90 | 90 | ||
91 | impl std::ops::Index<LocalModuleId> for CrateDefMap { | 91 | impl std::ops::Index<LocalModuleId> for DefMap { |
92 | type Output = ModuleData; | 92 | type Output = ModuleData; |
93 | fn index(&self, id: LocalModuleId) -> &ModuleData { | 93 | fn index(&self, id: LocalModuleId) -> &ModuleData { |
94 | &self.modules[id] | 94 | &self.modules[id] |
@@ -169,8 +169,8 @@ pub struct ModuleData { | |||
169 | pub origin: ModuleOrigin, | 169 | pub origin: ModuleOrigin, |
170 | } | 170 | } |
171 | 171 | ||
172 | impl CrateDefMap { | 172 | impl DefMap { |
173 | pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { | 173 | pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<DefMap> { |
174 | let _p = profile::span("crate_def_map_query").detail(|| { | 174 | let _p = profile::span("crate_def_map_query").detail(|| { |
175 | db.crate_graph()[krate].display_name.as_deref().unwrap_or_default().to_string() | 175 | db.crate_graph()[krate].display_name.as_deref().unwrap_or_default().to_string() |
176 | }); | 176 | }); |
@@ -178,7 +178,7 @@ impl CrateDefMap { | |||
178 | let edition = db.crate_graph()[krate].edition; | 178 | let edition = db.crate_graph()[krate].edition; |
179 | let mut modules: Arena<ModuleData> = Arena::default(); | 179 | let mut modules: Arena<ModuleData> = Arena::default(); |
180 | let root = modules.alloc(ModuleData::default()); | 180 | let root = modules.alloc(ModuleData::default()); |
181 | CrateDefMap { | 181 | DefMap { |
182 | krate, | 182 | krate, |
183 | edition, | 183 | edition, |
184 | extern_prelude: FxHashMap::default(), | 184 | extern_prelude: FxHashMap::default(), |
@@ -227,7 +227,7 @@ impl CrateDefMap { | |||
227 | go(&mut buf, self, "crate", self.root); | 227 | go(&mut buf, self, "crate", self.root); |
228 | return buf; | 228 | return buf; |
229 | 229 | ||
230 | fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { | 230 | fn go(buf: &mut String, map: &DefMap, path: &str, module: LocalModuleId) { |
231 | format_to!(buf, "{}\n", path); | 231 | format_to!(buf, "{}\n", path); |
232 | 232 | ||
233 | let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect(); | 233 | let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect(); |
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 0cd61698c..61da56340 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -31,7 +31,7 @@ use crate::{ | |||
31 | }, | 31 | }, |
32 | nameres::{ | 32 | nameres::{ |
33 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, | 33 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, |
34 | BuiltinShadowMode, CrateDefMap, ModuleData, ModuleOrigin, ResolveMode, | 34 | BuiltinShadowMode, DefMap, ModuleData, ModuleOrigin, ResolveMode, |
35 | }, | 35 | }, |
36 | path::{ImportAlias, ModPath, PathKind}, | 36 | path::{ImportAlias, ModPath, PathKind}, |
37 | per_ns::PerNs, | 37 | per_ns::PerNs, |
@@ -45,7 +45,7 @@ const GLOB_RECURSION_LIMIT: usize = 100; | |||
45 | const EXPANSION_DEPTH_LIMIT: usize = 128; | 45 | const EXPANSION_DEPTH_LIMIT: usize = 128; |
46 | const FIXED_POINT_LIMIT: usize = 8192; | 46 | const FIXED_POINT_LIMIT: usize = 8192; |
47 | 47 | ||
48 | pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 48 | pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: DefMap) -> DefMap { |
49 | let crate_graph = db.crate_graph(); | 49 | let crate_graph = db.crate_graph(); |
50 | 50 | ||
51 | // populate external prelude | 51 | // populate external prelude |
@@ -210,7 +210,7 @@ struct DefData<'a> { | |||
210 | /// Walks the tree of module recursively | 210 | /// Walks the tree of module recursively |
211 | struct DefCollector<'a> { | 211 | struct DefCollector<'a> { |
212 | db: &'a dyn DefDatabase, | 212 | db: &'a dyn DefDatabase, |
213 | def_map: CrateDefMap, | 213 | def_map: DefMap, |
214 | glob_imports: FxHashMap<LocalModuleId, Vec<(LocalModuleId, Visibility)>>, | 214 | glob_imports: FxHashMap<LocalModuleId, Vec<(LocalModuleId, Visibility)>>, |
215 | unresolved_imports: Vec<ImportDirective>, | 215 | unresolved_imports: Vec<ImportDirective>, |
216 | resolved_imports: Vec<ImportDirective>, | 216 | resolved_imports: Vec<ImportDirective>, |
@@ -859,7 +859,7 @@ impl DefCollector<'_> { | |||
859 | .collect(item_tree.top_level_items()); | 859 | .collect(item_tree.top_level_items()); |
860 | } | 860 | } |
861 | 861 | ||
862 | fn finish(mut self) -> CrateDefMap { | 862 | fn finish(mut self) -> DefMap { |
863 | // Emit diagnostics for all remaining unexpanded macros. | 863 | // Emit diagnostics for all remaining unexpanded macros. |
864 | 864 | ||
865 | for directive in &self.unexpanded_macros { | 865 | for directive in &self.unexpanded_macros { |
@@ -1474,7 +1474,7 @@ mod tests { | |||
1474 | 1474 | ||
1475 | use super::*; | 1475 | use super::*; |
1476 | 1476 | ||
1477 | fn do_collect_defs(db: &dyn DefDatabase, def_map: CrateDefMap) -> CrateDefMap { | 1477 | fn do_collect_defs(db: &dyn DefDatabase, def_map: DefMap) -> DefMap { |
1478 | let mut collector = DefCollector { | 1478 | let mut collector = DefCollector { |
1479 | db, | 1479 | db, |
1480 | def_map, | 1480 | def_map, |
@@ -1493,7 +1493,7 @@ mod tests { | |||
1493 | collector.def_map | 1493 | collector.def_map |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | fn do_resolve(code: &str) -> CrateDefMap { | 1496 | fn do_resolve(code: &str) -> DefMap { |
1497 | let (db, _file_id) = TestDB::with_single_file(&code); | 1497 | let (db, _file_id) = TestDB::with_single_file(&code); |
1498 | let krate = db.test_crate(); | 1498 | let krate = db.test_crate(); |
1499 | 1499 | ||
@@ -1501,7 +1501,7 @@ mod tests { | |||
1501 | let edition = db.crate_graph()[krate].edition; | 1501 | let edition = db.crate_graph()[krate].edition; |
1502 | let mut modules: Arena<ModuleData> = Arena::default(); | 1502 | let mut modules: Arena<ModuleData> = Arena::default(); |
1503 | let root = modules.alloc(ModuleData::default()); | 1503 | let root = modules.alloc(ModuleData::default()); |
1504 | CrateDefMap { | 1504 | DefMap { |
1505 | krate, | 1505 | krate, |
1506 | edition, | 1506 | edition, |
1507 | extern_prelude: FxHashMap::default(), | 1507 | extern_prelude: FxHashMap::default(), |
diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index 88e10574e..096a7d0ac 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs | |||
@@ -19,7 +19,7 @@ use test_utils::mark; | |||
19 | use crate::{ | 19 | use crate::{ |
20 | db::DefDatabase, | 20 | db::DefDatabase, |
21 | item_scope::BUILTIN_SCOPE, | 21 | item_scope::BUILTIN_SCOPE, |
22 | nameres::{BuiltinShadowMode, CrateDefMap}, | 22 | nameres::{BuiltinShadowMode, DefMap}, |
23 | path::{ModPath, PathKind}, | 23 | path::{ModPath, PathKind}, |
24 | per_ns::PerNs, | 24 | per_ns::PerNs, |
25 | visibility::{RawVisibility, Visibility}, | 25 | visibility::{RawVisibility, Visibility}, |
@@ -61,7 +61,7 @@ impl ResolvePathResult { | |||
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | impl CrateDefMap { | 64 | impl DefMap { |
65 | pub(super) fn resolve_name_in_extern_prelude(&self, name: &Name) -> PerNs { | 65 | pub(super) fn resolve_name_in_extern_prelude(&self, name: &Name) -> PerNs { |
66 | self.extern_prelude | 66 | self.extern_prelude |
67 | .get(name) | 67 | .get(name) |
diff --git a/crates/hir_def/src/nameres/tests.rs b/crates/hir_def/src/nameres/tests.rs index c459fa66d..723481c36 100644 --- a/crates/hir_def/src/nameres/tests.rs +++ b/crates/hir_def/src/nameres/tests.rs | |||
@@ -13,7 +13,7 @@ use test_utils::mark; | |||
13 | 13 | ||
14 | use crate::{db::DefDatabase, nameres::*, test_db::TestDB}; | 14 | use crate::{db::DefDatabase, nameres::*, test_db::TestDB}; |
15 | 15 | ||
16 | fn compute_crate_def_map(ra_fixture: &str) -> Arc<CrateDefMap> { | 16 | fn compute_crate_def_map(ra_fixture: &str) -> Arc<DefMap> { |
17 | let db = TestDB::with_files(ra_fixture); | 17 | let db = TestDB::with_files(ra_fixture); |
18 | let krate = db.crate_graph().iter().next().unwrap(); | 18 | let krate = db.crate_graph().iter().next().unwrap(); |
19 | db.crate_def_map(krate) | 19 | db.crate_def_map(krate) |
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index 85ddc2c47..e7e92c72d 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs | |||
@@ -16,7 +16,7 @@ use crate::{ | |||
16 | expr::{ExprId, PatId}, | 16 | expr::{ExprId, PatId}, |
17 | generics::GenericParams, | 17 | generics::GenericParams, |
18 | item_scope::{BuiltinShadowMode, BUILTIN_SCOPE}, | 18 | item_scope::{BuiltinShadowMode, BUILTIN_SCOPE}, |
19 | nameres::CrateDefMap, | 19 | nameres::DefMap, |
20 | path::{ModPath, PathKind}, | 20 | path::{ModPath, PathKind}, |
21 | per_ns::PerNs, | 21 | per_ns::PerNs, |
22 | visibility::{RawVisibility, Visibility}, | 22 | visibility::{RawVisibility, Visibility}, |
@@ -34,7 +34,7 @@ pub struct Resolver { | |||
34 | // FIXME how to store these best | 34 | // FIXME how to store these best |
35 | #[derive(Debug, Clone)] | 35 | #[derive(Debug, Clone)] |
36 | struct ModuleItemMap { | 36 | struct ModuleItemMap { |
37 | crate_def_map: Arc<CrateDefMap>, | 37 | crate_def_map: Arc<DefMap>, |
38 | module_id: LocalModuleId, | 38 | module_id: LocalModuleId, |
39 | } | 39 | } |
40 | 40 | ||
@@ -425,7 +425,7 @@ impl Resolver { | |||
425 | traits | 425 | traits |
426 | } | 426 | } |
427 | 427 | ||
428 | fn module_scope(&self) -> Option<(&CrateDefMap, LocalModuleId)> { | 428 | fn module_scope(&self) -> Option<(&DefMap, LocalModuleId)> { |
429 | self.scopes.iter().rev().find_map(|scope| match scope { | 429 | self.scopes.iter().rev().find_map(|scope| match scope { |
430 | Scope::ModuleScope(m) => Some((&*m.crate_def_map, m.module_id)), | 430 | Scope::ModuleScope(m) => Some((&*m.crate_def_map, m.module_id)), |
431 | 431 | ||
@@ -588,11 +588,7 @@ impl Resolver { | |||
588 | self.push_scope(Scope::ImplDefScope(impl_def)) | 588 | self.push_scope(Scope::ImplDefScope(impl_def)) |
589 | } | 589 | } |
590 | 590 | ||
591 | fn push_module_scope( | 591 | fn push_module_scope(self, crate_def_map: Arc<DefMap>, module_id: LocalModuleId) -> Resolver { |
592 | self, | ||
593 | crate_def_map: Arc<CrateDefMap>, | ||
594 | module_id: LocalModuleId, | ||
595 | ) -> Resolver { | ||
596 | self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) | 592 | self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) |
597 | } | 593 | } |
598 | 594 | ||
diff --git a/crates/hir_def/src/visibility.rs b/crates/hir_def/src/visibility.rs index f3bc9d680..3134fa43d 100644 --- a/crates/hir_def/src/visibility.rs +++ b/crates/hir_def/src/visibility.rs | |||
@@ -5,7 +5,7 @@ use syntax::ast; | |||
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | db::DefDatabase, | 7 | db::DefDatabase, |
8 | nameres::CrateDefMap, | 8 | nameres::DefMap, |
9 | path::{ModPath, PathKind}, | 9 | path::{ModPath, PathKind}, |
10 | ModuleId, | 10 | ModuleId, |
11 | }; | 11 | }; |
@@ -116,7 +116,7 @@ impl Visibility { | |||
116 | 116 | ||
117 | pub(crate) fn is_visible_from_def_map( | 117 | pub(crate) fn is_visible_from_def_map( |
118 | self, | 118 | self, |
119 | def_map: &CrateDefMap, | 119 | def_map: &DefMap, |
120 | from_module: crate::LocalModuleId, | 120 | from_module: crate::LocalModuleId, |
121 | ) -> bool { | 121 | ) -> bool { |
122 | let to_module = match self { | 122 | let to_module = match self { |
@@ -135,7 +135,7 @@ impl Visibility { | |||
135 | /// | 135 | /// |
136 | /// If there is no subset relation between `self` and `other`, returns `None` (ie. they're only | 136 | /// If there is no subset relation between `self` and `other`, returns `None` (ie. they're only |
137 | /// visible in unrelated modules). | 137 | /// visible in unrelated modules). |
138 | pub(crate) fn max(self, other: Visibility, def_map: &CrateDefMap) -> Option<Visibility> { | 138 | pub(crate) fn max(self, other: Visibility, def_map: &DefMap) -> Option<Visibility> { |
139 | match (self, other) { | 139 | match (self, other) { |
140 | (Visibility::Module(_), Visibility::Public) | 140 | (Visibility::Module(_), Visibility::Public) |
141 | | (Visibility::Public, Visibility::Module(_)) | 141 | | (Visibility::Public, Visibility::Module(_)) |
diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs index 5ff755321..4a3fcea8d 100644 --- a/crates/hir_ty/src/tests.rs +++ b/crates/hir_ty/src/tests.rs | |||
@@ -18,7 +18,7 @@ use hir_def::{ | |||
18 | db::DefDatabase, | 18 | db::DefDatabase, |
19 | item_scope::ItemScope, | 19 | item_scope::ItemScope, |
20 | keys, | 20 | keys, |
21 | nameres::CrateDefMap, | 21 | nameres::DefMap, |
22 | AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, | 22 | AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, |
23 | }; | 23 | }; |
24 | use hir_expand::{db::AstDatabase, InFile}; | 24 | use hir_expand::{db::AstDatabase, InFile}; |
@@ -221,7 +221,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { | |||
221 | 221 | ||
222 | fn visit_module( | 222 | fn visit_module( |
223 | db: &TestDB, | 223 | db: &TestDB, |
224 | crate_def_map: &CrateDefMap, | 224 | crate_def_map: &DefMap, |
225 | module_id: LocalModuleId, | 225 | module_id: LocalModuleId, |
226 | cb: &mut dyn FnMut(DefWithBodyId), | 226 | cb: &mut dyn FnMut(DefWithBodyId), |
227 | ) { | 227 | ) { |
@@ -249,7 +249,7 @@ fn visit_module( | |||
249 | 249 | ||
250 | fn visit_scope( | 250 | fn visit_scope( |
251 | db: &TestDB, | 251 | db: &TestDB, |
252 | crate_def_map: &CrateDefMap, | 252 | crate_def_map: &DefMap, |
253 | scope: &ItemScope, | 253 | scope: &ItemScope, |
254 | cb: &mut dyn FnMut(DefWithBodyId), | 254 | cb: &mut dyn FnMut(DefWithBodyId), |
255 | ) { | 255 | ) { |