Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/data.rs')
-rw-r--r--crates/hir-def/src/data.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs
index 12bfbbe308..8e8b5c322f 100644
--- a/crates/hir-def/src/data.rs
+++ b/crates/hir-def/src/data.rs
@@ -2,7 +2,7 @@
use std::{mem, sync::Arc};
-use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId};
+use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroDefKind};
use syntax::ast;
use crate::{
@@ -498,6 +498,17 @@ impl<'a> AssocItemCollector<'a> {
if !self.db.enable_proc_attr_macros() {
continue 'attrs;
}
+ let loc = self.db.lookup_intern_macro_call(call_id);
+ if let MacroDefKind::ProcMacro(exp, ..) = loc.def.kind {
+ // If there's no expander for the proc macro (e.g. the
+ // proc macro is ignored, or building the proc macro
+ // crate failed), skip expansion like we would if it was
+ // disabled. This is analogous to the handling in
+ // `DefCollector::collect_macros`.
+ if exp.is_dummy() {
+ continue 'attrs;
+ }
+ }
match self.expander.enter_expand_id(self.db, call_id) {
ExpandResult { value: Some((mark, mac)), .. } => {
self.collect_macro_items(mark, mac);