Skip to content

Commit

Permalink
Auto merge of #17375 - Veykril:attr-input-no-intern, r=Veykril
Browse files Browse the repository at this point in the history
Don't intern attribute inputs as their spans make them unique
  • Loading branch information
bors committed Jun 9, 2024
2 parents 913371f + 2328085 commit b427d46
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/hir-expand/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl RawAttrs {
let span = span_map.span_for_range(comment.syntax().text_range());
Attr {
id,
input: Some(Interned::new(AttrInput::Literal(tt::Literal {
input: Some(Box::new(AttrInput::Literal(tt::Literal {
text: SmolStr::new(format_smolstr!("\"{}\"", Self::escape_chars(doc))),
span,
}))),
Expand Down Expand Up @@ -199,7 +199,7 @@ impl AttrId {
pub struct Attr {
pub id: AttrId,
pub path: Interned<ModPath>,
pub input: Option<Interned<AttrInput>>,
pub input: Option<Box<AttrInput>>,
pub ctxt: SyntaxContextId,
}

Expand Down Expand Up @@ -234,7 +234,7 @@ impl Attr {
})?);
let span = span_map.span_for_range(range);
let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() {
Some(Interned::new(AttrInput::Literal(tt::Literal {
Some(Box::new(AttrInput::Literal(tt::Literal {
text: lit.token().text().into(),
span,
})))
Expand All @@ -245,7 +245,7 @@ impl Attr {
span,
DocCommentDesugarMode::ProcMacro,
);
Some(Interned::new(AttrInput::TokenTree(Box::new(tree))))
Some(Box::new(AttrInput::TokenTree(Box::new(tree))))
} else {
None
};
Expand Down Expand Up @@ -281,12 +281,12 @@ impl Attr {

let input = match input.first() {
Some(tt::TokenTree::Subtree(tree)) => {
Some(Interned::new(AttrInput::TokenTree(Box::new(tree.clone()))))
Some(Box::new(AttrInput::TokenTree(Box::new(tree.clone()))))
}
Some(tt::TokenTree::Leaf(tt::Leaf::Punct(tt::Punct { char: '=', .. }))) => {
let input = match input.get(1) {
Some(tt::TokenTree::Leaf(tt::Leaf::Literal(lit))) => {
Some(Interned::new(AttrInput::Literal(lit.clone())))
Some(Box::new(AttrInput::Literal(lit.clone())))
}
_ => None,
};
Expand Down

0 comments on commit b427d46

Please sign in to comment.