aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/attr.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-01 19:35:21 +0100
committerJonas Schievink <[email protected]>2021-04-01 19:35:21 +0100
commit39d992ef559c9cd67551819a9d63ef52ef7b725f (patch)
tree49e1e59d00e46a8bb110d2b28d911c07d4a058f9 /crates/hir_def/src/attr.rs
parentb00266b79f0e2c2a5e332b30f7e6aba83b5e6e5a (diff)
Intern Attr, MacroCall and Path components
Diffstat (limited to 'crates/hir_def/src/attr.rs')
-rw-r--r--crates/hir_def/src/attr.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index 52a2bce9b..2bab121d9 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -18,6 +18,7 @@ use tt::Subtree;
18 18
19use crate::{ 19use crate::{
20 db::DefDatabase, 20 db::DefDatabase,
21 intern::Interned,
21 item_tree::{ItemTreeId, ItemTreeNode}, 22 item_tree::{ItemTreeId, ItemTreeNode},
22 nameres::ModuleSource, 23 nameres::ModuleSource,
23 path::{ModPath, PathKind}, 24 path::{ModPath, PathKind},
@@ -98,7 +99,7 @@ impl RawAttrs {
98 Either::Right(comment) => comment.doc_comment().map(|doc| Attr { 99 Either::Right(comment) => comment.doc_comment().map(|doc| Attr {
99 index: i as u32, 100 index: i as u32,
100 input: Some(AttrInput::Literal(SmolStr::new(doc))), 101 input: Some(AttrInput::Literal(SmolStr::new(doc))),
101 path: ModPath::from(hir_expand::name!(doc)), 102 path: Interned::new(ModPath::from(hir_expand::name!(doc))),
102 }), 103 }),
103 }) 104 })
104 .collect::<Arc<_>>(); 105 .collect::<Arc<_>>();
@@ -510,7 +511,7 @@ impl AttrSourceMap {
510#[derive(Debug, Clone, PartialEq, Eq)] 511#[derive(Debug, Clone, PartialEq, Eq)]
511pub struct Attr { 512pub struct Attr {
512 index: u32, 513 index: u32,
513 pub(crate) path: ModPath, 514 pub(crate) path: Interned<ModPath>,
514 pub(crate) input: Option<AttrInput>, 515 pub(crate) input: Option<AttrInput>,
515} 516}
516 517
@@ -524,7 +525,7 @@ pub enum AttrInput {
524 525
525impl Attr { 526impl Attr {
526 fn from_src(ast: ast::Attr, hygiene: &Hygiene, index: u32) -> Option<Attr> { 527 fn from_src(ast: ast::Attr, hygiene: &Hygiene, index: u32) -> Option<Attr> {
527 let path = ModPath::from_src(ast.path()?, hygiene)?; 528 let path = Interned::new(ModPath::from_src(ast.path()?, hygiene)?);
528 let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() { 529 let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() {
529 let value = match lit.kind() { 530 let value = match lit.kind() {
530 ast::LiteralKind::String(string) => string.value()?.into(), 531 ast::LiteralKind::String(string) => string.value()?.into(),