Remove MacroCallKind::DeriveAttr

This commit is contained in:
Wyatt Herkamp 2024-03-21 12:50:58 -04:00
parent c376addfcc
commit 262e06f1ef
6 changed files with 34 additions and 79 deletions

View file

@ -10,7 +10,7 @@ use syntax::{
use tracing::{debug, warn};
use tt::SmolStr;
use crate::{db::ExpandDatabase, MacroCallKind, MacroCallLoc};
use crate::{db::ExpandDatabase, proc_macro::ProcMacroKind, MacroCallLoc, MacroDefKind};
fn check_cfg_attr(attr: &Attr, loc: &MacroCallLoc, db: &dyn ExpandDatabase) -> Option<bool> {
if !attr.simple_name().as_deref().map(|v| v == "cfg")? {
@ -180,7 +180,13 @@ pub(crate) fn process_cfg_attrs(
db: &dyn ExpandDatabase,
) -> Option<FxHashSet<SyntaxElement>> {
// FIXME: #[cfg_eval] is not implemented. But it is not stable yet
if !matches!(loc.kind, MacroCallKind::Derive { .. } | MacroCallKind::DeriveAttr { .. }) {
let is_derive = match loc.def.kind {
MacroDefKind::BuiltInDerive(..)
| MacroDefKind::ProcMacro(_, ProcMacroKind::CustomDerive, _) => true,
MacroDefKind::BuiltInAttr(expander, _) => expander.is_derive(),
_ => false,
};
if !is_derive {
return None;
}
let mut remove = FxHashSet::default();