mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Fix case of ignored/broken proc macro
This commit is contained in:
parent
e71519572c
commit
9a12d0d6f2
1 changed files with 12 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::{mem, sync::Arc};
|
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 syntax::ast;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -498,6 +498,17 @@ impl<'a> AssocItemCollector<'a> {
|
||||||
if !self.db.enable_proc_attr_macros() {
|
if !self.db.enable_proc_attr_macros() {
|
||||||
continue 'attrs;
|
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) {
|
match self.expander.enter_expand_id(self.db, call_id) {
|
||||||
ExpandResult { value: Some((mark, mac)), .. } => {
|
ExpandResult { value: Some((mark, mac)), .. } => {
|
||||||
self.collect_macro_items(mark, mac);
|
self.collect_macro_items(mark, mac);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue