diff options
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index c8f494707..4ddc791ce 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -23,6 +23,7 @@ use crate::{ | |||
23 | attr::Attrs, | 23 | attr::Attrs, |
24 | db::DefDatabase, | 24 | db::DefDatabase, |
25 | derive_macro_as_call_id, | 25 | derive_macro_as_call_id, |
26 | intern::Interned, | ||
26 | item_scope::{ImportType, PerNsGlobImports}, | 27 | item_scope::{ImportType, PerNsGlobImports}, |
27 | item_tree::{ | 28 | item_tree::{ |
28 | self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, ModItem, | 29 | self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, ModItem, |
@@ -108,7 +109,9 @@ pub(super) fn collect_defs( | |||
108 | } | 109 | } |
109 | } | 110 | } |
110 | collector.collect(); | 111 | collector.collect(); |
111 | collector.finish() | 112 | let mut def_map = collector.finish(); |
113 | def_map.shrink_to_fit(); | ||
114 | def_map | ||
112 | } | 115 | } |
113 | 116 | ||
114 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] | 117 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] |
@@ -139,7 +142,7 @@ enum ImportSource { | |||
139 | 142 | ||
140 | #[derive(Clone, Debug, Eq, PartialEq)] | 143 | #[derive(Clone, Debug, Eq, PartialEq)] |
141 | struct Import { | 144 | struct Import { |
142 | path: ModPath, | 145 | path: Interned<ModPath>, |
143 | alias: Option<ImportAlias>, | 146 | alias: Option<ImportAlias>, |
144 | visibility: RawVisibility, | 147 | visibility: RawVisibility, |
145 | is_glob: bool, | 148 | is_glob: bool, |
@@ -181,7 +184,10 @@ impl Import { | |||
181 | let attrs = &tree.attrs(db, krate, ModItem::from(id.value).into()); | 184 | let attrs = &tree.attrs(db, krate, ModItem::from(id.value).into()); |
182 | let visibility = &tree[it.visibility]; | 185 | let visibility = &tree[it.visibility]; |
183 | Self { | 186 | Self { |
184 | path: ModPath::from_segments(PathKind::Plain, iter::once(it.name.clone())), | 187 | path: Interned::new(ModPath::from_segments( |
188 | PathKind::Plain, | ||
189 | iter::once(it.name.clone()), | ||
190 | )), | ||
185 | alias: it.alias.clone(), | 191 | alias: it.alias.clone(), |
186 | visibility: visibility.clone(), | 192 | visibility: visibility.clone(), |
187 | is_glob: false, | 193 | is_glob: false, |