aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/nameres/collector.rs36
1 files changed, 13 insertions, 23 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 19db6cc59..d4840be2f 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -811,6 +811,17 @@ impl DefCollector<'_> {
811 let mut resolved = Vec::new(); 811 let mut resolved = Vec::new();
812 let mut res = ReachedFixedPoint::Yes; 812 let mut res = ReachedFixedPoint::Yes;
813 macros.retain(|directive| { 813 macros.retain(|directive| {
814 let resolver = |path| {
815 let resolved_res = self.def_map.resolve_path_fp_with_macro(
816 self.db,
817 ResolveMode::Other,
818 directive.module_id,
819 &path,
820 BuiltinShadowMode::Module,
821 );
822 resolved_res.resolved_def.take_macros()
823 };
824
814 match &directive.kind { 825 match &directive.kind {
815 MacroDirectiveKind::FnLike { ast_id, fragment } => { 826 MacroDirectiveKind::FnLike { ast_id, fragment } => {
816 match macro_call_as_call_id( 827 match macro_call_as_call_id(
@@ -818,16 +829,7 @@ impl DefCollector<'_> {
818 *fragment, 829 *fragment,
819 self.db, 830 self.db,
820 self.def_map.krate, 831 self.def_map.krate,
821 |path| { 832 &resolver,
822 let resolved_res = self.def_map.resolve_path_fp_with_macro(
823 self.db,
824 ResolveMode::Other,
825 directive.module_id,
826 &path,
827 BuiltinShadowMode::Module,
828 );
829 resolved_res.resolved_def.take_macros()
830 },
831 &mut |_err| (), 833 &mut |_err| (),
832 ) { 834 ) {
833 Ok(Ok(call_id)) => { 835 Ok(Ok(call_id)) => {
@@ -844,7 +846,7 @@ impl DefCollector<'_> {
844 *derive_attr, 846 *derive_attr,
845 self.db, 847 self.db,
846 self.def_map.krate, 848 self.def_map.krate,
847 |path| self.resolve_derive_macro(directive.module_id, &path), 849 &resolver,
848 ) { 850 ) {
849 Ok(call_id) => { 851 Ok(call_id) => {
850 resolved.push((directive.module_id, call_id, directive.depth)); 852 resolved.push((directive.module_id, call_id, directive.depth));
@@ -867,18 +869,6 @@ impl DefCollector<'_> {
867 res 869 res
868 } 870 }
869 871
870 fn resolve_derive_macro(&self, module: LocalModuleId, path: &ModPath) -> Option<MacroDefId> {
871 let resolved_res = self.def_map.resolve_path_fp_with_macro(
872 self.db,
873 ResolveMode::Other,
874 module,
875 &path,
876 BuiltinShadowMode::Module,
877 );
878
879 resolved_res.resolved_def.take_macros()
880 }
881
882 fn collect_macro_expansion( 872 fn collect_macro_expansion(
883 &mut self, 873 &mut self,
884 module_id: LocalModuleId, 874 module_id: LocalModuleId,