mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Merge #8871
8871: internal: Simplify `DefCollector::resolve_macros` r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
16b03d21dc
1 changed files with 13 additions and 23 deletions
|
@ -811,14 +811,7 @@ impl DefCollector<'_> {
|
|||
let mut resolved = Vec::new();
|
||||
let mut res = ReachedFixedPoint::Yes;
|
||||
macros.retain(|directive| {
|
||||
match &directive.kind {
|
||||
MacroDirectiveKind::FnLike { ast_id, fragment } => {
|
||||
match macro_call_as_call_id(
|
||||
ast_id,
|
||||
*fragment,
|
||||
self.db,
|
||||
self.def_map.krate,
|
||||
|path| {
|
||||
let resolver = |path| {
|
||||
let resolved_res = self.def_map.resolve_path_fp_with_macro(
|
||||
self.db,
|
||||
ResolveMode::Other,
|
||||
|
@ -827,7 +820,16 @@ impl DefCollector<'_> {
|
|||
BuiltinShadowMode::Module,
|
||||
);
|
||||
resolved_res.resolved_def.take_macros()
|
||||
},
|
||||
};
|
||||
|
||||
match &directive.kind {
|
||||
MacroDirectiveKind::FnLike { ast_id, fragment } => {
|
||||
match macro_call_as_call_id(
|
||||
ast_id,
|
||||
*fragment,
|
||||
self.db,
|
||||
self.def_map.krate,
|
||||
&resolver,
|
||||
&mut |_err| (),
|
||||
) {
|
||||
Ok(Ok(call_id)) => {
|
||||
|
@ -844,7 +846,7 @@ impl DefCollector<'_> {
|
|||
*derive_attr,
|
||||
self.db,
|
||||
self.def_map.krate,
|
||||
|path| self.resolve_derive_macro(directive.module_id, &path),
|
||||
&resolver,
|
||||
) {
|
||||
Ok(call_id) => {
|
||||
resolved.push((directive.module_id, call_id, directive.depth));
|
||||
|
@ -867,18 +869,6 @@ impl DefCollector<'_> {
|
|||
res
|
||||
}
|
||||
|
||||
fn resolve_derive_macro(&self, module: LocalModuleId, path: &ModPath) -> Option<MacroDefId> {
|
||||
let resolved_res = self.def_map.resolve_path_fp_with_macro(
|
||||
self.db,
|
||||
ResolveMode::Other,
|
||||
module,
|
||||
&path,
|
||||
BuiltinShadowMode::Module,
|
||||
);
|
||||
|
||||
resolved_res.resolved_def.take_macros()
|
||||
}
|
||||
|
||||
fn collect_macro_expansion(
|
||||
&mut self,
|
||||
module_id: LocalModuleId,
|
||||
|
|
Loading…
Reference in a new issue