Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6fc3a3e

Browse files
committed
Auto merge of rust-lang#16832 - Veykril:macarons, r=Veykril
internal: Shrink MacroCallLoc Shaves off 4/8 bytes
2 parents e8182a5 + 9767156 commit 6fc3a3e

File tree

8 files changed

+247
-227
lines changed

8 files changed

+247
-227
lines changed

crates/hir-def/src/data.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ impl<'a> AssocItemCollector<'a> {
745745
self.collect_macro_items(res, &|| hir_expand::MacroCallKind::FnLike {
746746
ast_id: InFile::new(file_id, ast_id),
747747
expand_to: hir_expand::ExpandTo::Items,
748+
eager: None,
748749
});
749750
}
750751
Ok(None) => (),
@@ -754,6 +755,7 @@ impl<'a> AssocItemCollector<'a> {
754755
MacroCallKind::FnLike {
755756
ast_id: InFile::new(file_id, ast_id),
756757
expand_to,
758+
eager: None,
757759
},
758760
Clone::clone(path),
759761
));

crates/hir-def/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,17 +1403,20 @@ fn macro_call_as_call_id_with_eager(
14031403
resolver(call.path.clone()).ok_or_else(|| UnresolvedMacro { path: call.path.clone() })?;
14041404

14051405
let res = match def.kind {
1406-
MacroDefKind::BuiltInEager(..) => {
1407-
let macro_call = InFile::new(call.ast_id.file_id, call.ast_id.to_node(db));
1408-
expand_eager_macro_input(db, krate, macro_call, def, call_site, &|path| {
1409-
eager_resolver(path).filter(MacroDefId::is_fn_like)
1410-
})
1411-
}
1406+
MacroDefKind::BuiltInEager(..) => expand_eager_macro_input(
1407+
db,
1408+
krate,
1409+
&call.ast_id.to_node(db),
1410+
call.ast_id,
1411+
def,
1412+
call_site,
1413+
&|path| eager_resolver(path).filter(MacroDefId::is_fn_like),
1414+
),
14121415
_ if def.is_fn_like() => ExpandResult {
1413-
value: Some(def.as_lazy_macro(
1416+
value: Some(def.make_call(
14141417
db,
14151418
krate,
1416-
MacroCallKind::FnLike { ast_id: call.ast_id, expand_to },
1419+
MacroCallKind::FnLike { ast_id: call.ast_id, expand_to, eager: None },
14171420
call_site,
14181421
)),
14191422
err: None,

crates/hir-def/src/nameres/attr_resolution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub(super) fn attr_macro_as_call_id(
116116
_ => None,
117117
};
118118

119-
def.as_lazy_macro(
119+
def.make_call(
120120
db.upcast(),
121121
krate,
122122
MacroCallKind::Attr {
@@ -140,7 +140,7 @@ pub(super) fn derive_macro_as_call_id(
140140
let (macro_id, def_id) = resolver(item_attr.path.clone())
141141
.filter(|(_, def_id)| def_id.is_derive())
142142
.ok_or_else(|| UnresolvedMacro { path: item_attr.path.clone() })?;
143-
let call_id = def_id.as_lazy_macro(
143+
let call_id = def_id.make_call(
144144
db.upcast(),
145145
krate,
146146
MacroCallKind::Derive {

crates/hir-def/src/nameres/collector.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,11 @@ impl DefCollector<'_> {
14511451
if let Err(UnresolvedMacro { path }) = macro_call_as_call_id {
14521452
self.def_map.diagnostics.push(DefDiagnostic::unresolved_macro_call(
14531453
directive.module_id,
1454-
MacroCallKind::FnLike { ast_id: ast_id.ast_id, expand_to: *expand_to },
1454+
MacroCallKind::FnLike {
1455+
ast_id: ast_id.ast_id,
1456+
expand_to: *expand_to,
1457+
eager: None,
1458+
},
14551459
path,
14561460
));
14571461
}

crates/hir-expand/src/builtin_attr_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn derive_expand(
117117
}
118118

119119
pub fn pseudo_derive_attr_expansion(
120-
tt: &tt::Subtree,
120+
_: &tt::Subtree,
121121
args: &tt::Subtree,
122122
call_site: Span,
123123
) -> ExpandResult<tt::Subtree> {
@@ -141,7 +141,7 @@ pub fn pseudo_derive_attr_expansion(
141141
token_trees.push(mk_leaf(']'));
142142
}
143143
ExpandResult::ok(tt::Subtree {
144-
delimiter: tt.delimiter,
144+
delimiter: args.delimiter,
145145
token_trees: token_trees.into_boxed_slice(),
146146
})
147147
}

0 commit comments

Comments
 (0)