Skip to content

Commit 9a12d0d

Browse files
committed
Fix case of ignored/broken proc macro
1 parent e715195 commit 9a12d0d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/hir-def/src/data.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::{mem, sync::Arc};
44

5-
use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId};
5+
use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroDefKind};
66
use syntax::ast;
77

88
use crate::{
@@ -498,6 +498,17 @@ impl<'a> AssocItemCollector<'a> {
498498
if !self.db.enable_proc_attr_macros() {
499499
continue 'attrs;
500500
}
501+
let loc = self.db.lookup_intern_macro_call(call_id);
502+
if let MacroDefKind::ProcMacro(exp, ..) = loc.def.kind {
503+
// If there's no expander for the proc macro (e.g. the
504+
// proc macro is ignored, or building the proc macro
505+
// crate failed), skip expansion like we would if it was
506+
// disabled. This is analogous to the handling in
507+
// `DefCollector::collect_macros`.
508+
if exp.is_dummy() {
509+
continue 'attrs;
510+
}
511+
}
501512
match self.expander.enter_expand_id(self.db, call_id) {
502513
ExpandResult { value: Some((mark, mac)), .. } => {
503514
self.collect_macro_items(mark, mac);

0 commit comments

Comments
 (0)