Skip to content

Commit b6fb35f

Browse files
committed
Shrink hir_expand::attr::AttrInput by boxing a variant
1 parent 993299e commit b6fb35f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

crates/hir-def/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,13 +1028,13 @@ fn attr_macro_as_call_id(
10281028
def: MacroDefId,
10291029
) -> MacroCallId {
10301030
let arg = match macro_attr.input.as_deref() {
1031-
Some(AttrInput::TokenTree(tt, map)) => (
1031+
Some(AttrInput::TokenTree(tt)) => (
10321032
{
1033-
let mut tt = tt.clone();
1033+
let mut tt = tt.0.clone();
10341034
tt.delimiter = tt::Delimiter::UNSPECIFIED;
10351035
tt
10361036
},
1037-
map.clone(),
1037+
tt.1.clone(),
10381038
),
10391039
_ => (tt::Subtree::empty(), Default::default()),
10401040
};

crates/hir-expand/src/attrs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ pub enum AttrInput {
192192
/// `#[attr = "string"]`
193193
Literal(SmolStr),
194194
/// `#[attr(subtree)]`
195-
TokenTree(tt::Subtree, mbe::TokenMap),
195+
TokenTree(Box<(tt::Subtree, mbe::TokenMap)>),
196196
}
197197

198198
impl fmt::Display for AttrInput {
199199
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
200200
match self {
201201
AttrInput::Literal(lit) => write!(f, " = \"{}\"", lit.escape_debug()),
202-
AttrInput::TokenTree(subtree, _) => subtree.fmt(f),
202+
AttrInput::TokenTree(tt) => tt.0.fmt(f),
203203
}
204204
}
205205
}
@@ -220,7 +220,7 @@ impl Attr {
220220
Some(Interned::new(AttrInput::Literal(value)))
221221
} else if let Some(tt) = ast.token_tree() {
222222
let (tree, map) = syntax_node_to_token_tree(tt.syntax());
223-
Some(Interned::new(AttrInput::TokenTree(tree, map)))
223+
Some(Interned::new(AttrInput::TokenTree(Box::new((tree, map)))))
224224
} else {
225225
None
226226
};
@@ -256,7 +256,7 @@ impl Attr {
256256
/// #[path(ident)]
257257
pub fn single_ident_value(&self) -> Option<&tt::Ident> {
258258
match self.input.as_deref()? {
259-
AttrInput::TokenTree(subtree, _) => match &*subtree.token_trees {
259+
AttrInput::TokenTree(tt) => match &*tt.0.token_trees {
260260
[tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] => Some(ident),
261261
_ => None,
262262
},
@@ -267,7 +267,7 @@ impl Attr {
267267
/// #[path TokenTree]
268268
pub fn token_tree_value(&self) -> Option<&Subtree> {
269269
match self.input.as_deref()? {
270-
AttrInput::TokenTree(subtree, _) => Some(subtree),
270+
AttrInput::TokenTree(tt) => Some(&tt.0),
271271
_ => None,
272272
}
273273
}

0 commit comments

Comments
 (0)