mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Fix case of ignored/broken proc macro
This commit is contained in:
parent
e71519572c
commit
9a12d0d6f2
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user