aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-03 19:56:53 +0100
committerJonas Schievink <[email protected]>2021-04-03 19:57:25 +0100
commitf7e6b186e1d2f3a31b8e21d0885e13f12f12d71b (patch)
tree9d7a2c08e173ee9bf20cd09ca068ff3de83489f4
parente2213a503ec4c602eb976dccb9d34b56d9c6aba3 (diff)
Intern `ModPath` in `Import`
Minor savings only
-rw-r--r--crates/hir_def/src/item_tree.rs2
-rw-r--r--crates/hir_def/src/item_tree/lower.rs2
-rw-r--r--crates/hir_def/src/nameres/collector.rs8
3 files changed, 8 insertions, 4 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs
index 69a313c7e..dd80cef23 100644
--- a/crates/hir_def/src/item_tree.rs
+++ b/crates/hir_def/src/item_tree.rs
@@ -529,7 +529,7 @@ impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree {
529/// A desugared `use` import. 529/// A desugared `use` import.
530#[derive(Debug, Clone, Eq, PartialEq)] 530#[derive(Debug, Clone, Eq, PartialEq)]
531pub struct Import { 531pub struct Import {
532 pub path: ModPath, 532 pub path: Interned<ModPath>,
533 pub alias: Option<ImportAlias>, 533 pub alias: Option<ImportAlias>,
534 pub visibility: RawVisibilityId, 534 pub visibility: RawVisibilityId,
535 pub is_glob: bool, 535 pub is_glob: bool,
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index 5247379c5..ead7cd7a4 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -577,7 +577,7 @@ impl Ctx {
577 &self.hygiene, 577 &self.hygiene,
578 |path, _use_tree, is_glob, alias| { 578 |path, _use_tree, is_glob, alias| {
579 imports.push(id(tree.imports.alloc(Import { 579 imports.push(id(tree.imports.alloc(Import {
580 path, 580 path: Interned::new(path),
581 alias, 581 alias,
582 visibility, 582 visibility,
583 is_glob, 583 is_glob,
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index c8f494707..c2e445b68 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,
@@ -139,7 +140,7 @@ enum ImportSource {
139 140
140#[derive(Clone, Debug, Eq, PartialEq)] 141#[derive(Clone, Debug, Eq, PartialEq)]
141struct Import { 142struct Import {
142 path: ModPath, 143 path: Interned<ModPath>,
143 alias: Option<ImportAlias>, 144 alias: Option<ImportAlias>,
144 visibility: RawVisibility, 145 visibility: RawVisibility,
145 is_glob: bool, 146 is_glob: bool,
@@ -181,7 +182,10 @@ impl Import {
181 let attrs = &tree.attrs(db, krate, ModItem::from(id.value).into()); 182 let attrs = &tree.attrs(db, krate, ModItem::from(id.value).into());
182 let visibility = &tree[it.visibility]; 183 let visibility = &tree[it.visibility];
183 Self { 184 Self {
184 path: ModPath::from_segments(PathKind::Plain, iter::once(it.name.clone())), 185 path: Interned::new(ModPath::from_segments(
186 PathKind::Plain,
187 iter::once(it.name.clone()),
188 )),
185 alias: it.alias.clone(), 189 alias: it.alias.clone(),
186 visibility: visibility.clone(), 190 visibility: visibility.clone(),
187 is_glob: false, 191 is_glob: false,