Shrink MacroCallLoc

This commit is contained in:
Lukas Wirth 2024-03-13 18:05:27 +01:00
parent 87e0bbc534
commit abe3177445
7 changed files with 69 additions and 45 deletions

View file

@ -745,6 +745,7 @@ impl<'a> AssocItemCollector<'a> {
self.collect_macro_items(res, &|| hir_expand::MacroCallKind::FnLike {
ast_id: InFile::new(file_id, ast_id),
expand_to: hir_expand::ExpandTo::Items,
eager: None,
});
}
Ok(None) => (),
@ -754,6 +755,7 @@ impl<'a> AssocItemCollector<'a> {
MacroCallKind::FnLike {
ast_id: InFile::new(file_id, ast_id),
expand_to,
eager: None,
},
Clone::clone(path),
));

View file

@ -1410,10 +1410,10 @@ fn macro_call_as_call_id_with_eager(
})
}
_ if def.is_fn_like() => ExpandResult {
value: Some(def.as_lazy_macro(
value: Some(def.make_call(
db,
krate,
MacroCallKind::FnLike { ast_id: call.ast_id, expand_to },
MacroCallKind::FnLike { ast_id: call.ast_id, expand_to, eager: None },
call_site,
)),
err: None,

View file

@ -116,7 +116,7 @@ pub(super) fn attr_macro_as_call_id(
_ => None,
};
def.as_lazy_macro(
def.make_call(
db.upcast(),
krate,
MacroCallKind::Attr {
@ -140,7 +140,7 @@ pub(super) fn derive_macro_as_call_id(
let (macro_id, def_id) = resolver(item_attr.path.clone())
.filter(|(_, def_id)| def_id.is_derive())
.ok_or_else(|| UnresolvedMacro { path: item_attr.path.clone() })?;
let call_id = def_id.as_lazy_macro(
let call_id = def_id.make_call(
db.upcast(),
krate,
MacroCallKind::Derive {

View file

@ -1451,7 +1451,11 @@ impl DefCollector<'_> {
if let Err(UnresolvedMacro { path }) = macro_call_as_call_id {
self.def_map.diagnostics.push(DefDiagnostic::unresolved_macro_call(
directive.module_id,
MacroCallKind::FnLike { ast_id: ast_id.ast_id, expand_to: *expand_to },
MacroCallKind::FnLike {
ast_id: ast_id.ast_id,
expand_to: *expand_to,
eager: None,
},
path,
));
}