Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/lib.rs')
-rw-r--r--crates/hir-expand/src/lib.rs47
1 files changed, 24 insertions, 23 deletions
diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs
index 83e92565f4..b34649d972 100644
--- a/crates/hir-expand/src/lib.rs
+++ b/crates/hir-expand/src/lib.rs
@@ -16,6 +16,7 @@ pub mod declarative;
pub mod eager;
pub mod files;
pub mod hygiene;
+pub mod inert_attr_macro;
pub mod mod_path;
pub mod name;
pub mod proc_macro;
@@ -186,11 +187,11 @@ pub struct MacroDefId {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MacroDefKind {
Declarative(AstId<ast::Macro>),
- BuiltIn(BuiltinFnLikeExpander, AstId<ast::Macro>),
- BuiltInAttr(BuiltinAttrExpander, AstId<ast::Macro>),
- BuiltInDerive(BuiltinDeriveExpander, AstId<ast::Macro>),
- BuiltInEager(EagerExpander, AstId<ast::Macro>),
- ProcMacro(CustomProcMacroExpander, ProcMacroKind, AstId<ast::Fn>),
+ BuiltIn(AstId<ast::Macro>, BuiltinFnLikeExpander),
+ BuiltInAttr(AstId<ast::Macro>, BuiltinAttrExpander),
+ BuiltInDerive(AstId<ast::Macro>, BuiltinDeriveExpander),
+ BuiltInEager(AstId<ast::Macro>, EagerExpander),
+ ProcMacro(AstId<ast::Fn>, CustomProcMacroExpander, ProcMacroKind),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -379,7 +380,7 @@ impl MacroFileIdExt for MacroFileId {
fn is_custom_derive(&self, db: &dyn ExpandDatabase) -> bool {
matches!(
db.lookup_intern_macro_call(self.macro_call_id).def.kind,
- MacroDefKind::ProcMacro(_, ProcMacroKind::CustomDerive, _)
+ MacroDefKind::ProcMacro(_, _, ProcMacroKind::CustomDerive)
)
}
@@ -440,13 +441,13 @@ impl MacroDefId {
pub fn definition_range(&self, db: &dyn ExpandDatabase) -> InFile<TextRange> {
match self.kind {
MacroDefKind::Declarative(id)
- | MacroDefKind::BuiltIn(_, id)
- | MacroDefKind::BuiltInAttr(_, id)
- | MacroDefKind::BuiltInDerive(_, id)
- | MacroDefKind::BuiltInEager(_, id) => {
+ | MacroDefKind::BuiltIn(id, _)
+ | MacroDefKind::BuiltInAttr(id, _)
+ | MacroDefKind::BuiltInDerive(id, _)
+ | MacroDefKind::BuiltInEager(id, _) => {
id.with_value(db.ast_id_map(id.file_id).get(id.value).text_range())
}
- MacroDefKind::ProcMacro(_, _, id) => {
+ MacroDefKind::ProcMacro(id, _, _) => {
id.with_value(db.ast_id_map(id.file_id).get(id.value).text_range())
}
}
@@ -454,12 +455,12 @@ impl MacroDefId {
pub fn ast_id(&self) -> Either<AstId<ast::Macro>, AstId<ast::Fn>> {
match self.kind {
- MacroDefKind::ProcMacro(.., id) => Either::Right(id),
+ MacroDefKind::ProcMacro(id, ..) => Either::Right(id),
MacroDefKind::Declarative(id)
- | MacroDefKind::BuiltIn(_, id)
- | MacroDefKind::BuiltInAttr(_, id)
- | MacroDefKind::BuiltInDerive(_, id)
- | MacroDefKind::BuiltInEager(_, id) => Either::Left(id),
+ | MacroDefKind::BuiltIn(id, _)
+ | MacroDefKind::BuiltInAttr(id, _)
+ | MacroDefKind::BuiltInDerive(id, _)
+ | MacroDefKind::BuiltInEager(id, _) => Either::Left(id),
}
}
@@ -470,7 +471,7 @@ impl MacroDefId {
pub fn is_attribute(&self) -> bool {
matches!(
self.kind,
- MacroDefKind::BuiltInAttr(..) | MacroDefKind::ProcMacro(_, ProcMacroKind::Attr, _)
+ MacroDefKind::BuiltInAttr(..) | MacroDefKind::ProcMacro(_, _, ProcMacroKind::Attr)
)
}
@@ -478,7 +479,7 @@ impl MacroDefId {
matches!(
self.kind,
MacroDefKind::BuiltInDerive(..)
- | MacroDefKind::ProcMacro(_, ProcMacroKind::CustomDerive, _)
+ | MacroDefKind::ProcMacro(_, _, ProcMacroKind::CustomDerive)
)
}
@@ -486,26 +487,26 @@ impl MacroDefId {
matches!(
self.kind,
MacroDefKind::BuiltIn(..)
- | MacroDefKind::ProcMacro(_, ProcMacroKind::Bang, _)
+ | MacroDefKind::ProcMacro(_, _, ProcMacroKind::Bang)
| MacroDefKind::BuiltInEager(..)
| MacroDefKind::Declarative(..)
)
}
pub fn is_attribute_derive(&self) -> bool {
- matches!(self.kind, MacroDefKind::BuiltInAttr(expander, ..) if expander.is_derive())
+ matches!(self.kind, MacroDefKind::BuiltInAttr(_, expander) if expander.is_derive())
}
pub fn is_include(&self) -> bool {
- matches!(self.kind, MacroDefKind::BuiltInEager(expander, ..) if expander.is_include())
+ matches!(self.kind, MacroDefKind::BuiltInEager(_, expander) if expander.is_include())
}
pub fn is_include_like(&self) -> bool {
- matches!(self.kind, MacroDefKind::BuiltInEager(expander, ..) if expander.is_include_like())
+ matches!(self.kind, MacroDefKind::BuiltInEager(_, expander) if expander.is_include_like())
}
pub fn is_env_or_option_env(&self) -> bool {
- matches!(self.kind, MacroDefKind::BuiltInEager(expander, ..) if expander.is_env_or_option_env())
+ matches!(self.kind, MacroDefKind::BuiltInEager(_, expander) if expander.is_env_or_option_env())
}
}