aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/attr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/attr.rs')
-rw-r--r--crates/hir_def/src/attr.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index 74bb6de35..ab77d924a 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -22,6 +22,7 @@ use tt::Subtree;
22 22
23use crate::{ 23use crate::{
24 db::DefDatabase, 24 db::DefDatabase,
25 intern::Interned,
25 item_tree::{ItemTreeId, ItemTreeNode}, 26 item_tree::{ItemTreeId, ItemTreeNode},
26 nameres::ModuleSource, 27 nameres::ModuleSource,
27 path::{ModPath, PathKind}, 28 path::{ModPath, PathKind},
@@ -102,7 +103,7 @@ impl RawAttrs {
102 Either::Right(comment) => comment.doc_comment().map(|doc| Attr { 103 Either::Right(comment) => comment.doc_comment().map(|doc| Attr {
103 index: i as u32, 104 index: i as u32,
104 input: Some(AttrInput::Literal(SmolStr::new(doc))), 105 input: Some(AttrInput::Literal(SmolStr::new(doc))),
105 path: ModPath::from(hir_expand::name!(doc)), 106 path: Interned::new(ModPath::from(hir_expand::name!(doc))),
106 }), 107 }),
107 }) 108 })
108 .collect::<Arc<_>>(); 109 .collect::<Arc<_>>();
@@ -601,7 +602,7 @@ impl DocsRangeMap {
601#[derive(Debug, Clone, PartialEq, Eq)] 602#[derive(Debug, Clone, PartialEq, Eq)]
602pub struct Attr { 603pub struct Attr {
603 index: u32, 604 index: u32,
604 pub(crate) path: ModPath, 605 pub(crate) path: Interned<ModPath>,
605 pub(crate) input: Option<AttrInput>, 606 pub(crate) input: Option<AttrInput>,
606} 607}
607 608
@@ -615,7 +616,7 @@ pub enum AttrInput {
615 616
616impl Attr { 617impl Attr {
617 fn from_src(ast: ast::Attr, hygiene: &Hygiene, index: u32) -> Option<Attr> { 618 fn from_src(ast: ast::Attr, hygiene: &Hygiene, index: u32) -> Option<Attr> {
618 let path = ModPath::from_src(ast.path()?, hygiene)?; 619 let path = Interned::new(ModPath::from_src(ast.path()?, hygiene)?);
619 let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() { 620 let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() {
620 let value = match lit.kind() { 621 let value = match lit.kind() {
621 ast::LiteralKind::String(string) => string.value()?.into(), 622 ast::LiteralKind::String(string) => string.value()?.into(),
@@ -623,7 +624,7 @@ impl Attr {
623 }; 624 };
624 Some(AttrInput::Literal(value)) 625 Some(AttrInput::Literal(value))
625 } else if let Some(tt) = ast.token_tree() { 626 } else if let Some(tt) = ast.token_tree() {
626 Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0)) 627 Some(AttrInput::TokenTree(ast_to_token_tree(&tt).0))
627 } else { 628 } else {
628 None 629 None
629 }; 630 };