aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-03-22 14:56:59 +0000
committerLukas Wirth <[email protected]>2021-03-23 10:32:14 +0000
commit7c4eb66c1acf10216fa866e05d646bdaea229ded (patch)
tree89df7b614ec5f88d7a4e43313e84d62c12cbceee /crates/hir/src
parentbad4e48672f928644457cece3b7e21dd78ea1e9b (diff)
Merge hir::MacroDef::is_* into hir::MacroDef::kind
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/lib.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index ea0a60961..5da6a0340 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1117,6 +1117,14 @@ impl BuiltinType {
1117} 1117}
1118 1118
1119#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 1119#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1120pub enum MacroKind {
1121 Declarative,
1122 ProcMacro,
1123 Derive,
1124 BuiltIn,
1125}
1126
1127#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1120pub struct MacroDef { 1128pub struct MacroDef {
1121 pub(crate) id: MacroDefId, 1129 pub(crate) id: MacroDefId,
1122} 1130}
@@ -1140,20 +1148,15 @@ impl MacroDef {
1140 } 1148 }
1141 } 1149 }
1142 1150
1143 /// Indicate it is a proc-macro 1151 pub fn kind(&self) -> MacroKind {
1144 pub fn is_proc_macro(&self) -> bool { 1152 match self.id.kind {
1145 matches!(self.id.kind, MacroDefKind::ProcMacro(..)) 1153 MacroDefKind::Declarative(_) => MacroKind::Declarative,
1146 } 1154 MacroDefKind::BuiltIn(_, _) => MacroKind::BuiltIn,
1147 1155 MacroDefKind::BuiltInDerive(_, _) => MacroKind::Derive,
1148 /// Indicate it is a derive macro 1156 MacroDefKind::BuiltInEager(_, _) => MacroKind::BuiltIn,
1149 pub fn is_derive_macro(&self) -> bool { 1157 // FIXME might be a derive
1150 // FIXME: wrong for `ProcMacro` 1158 MacroDefKind::ProcMacro(_, _) => MacroKind::ProcMacro,
1151 matches!(self.id.kind, MacroDefKind::ProcMacro(..) | MacroDefKind::BuiltInDerive(..)) 1159 }
1152 }
1153
1154 /// Indicate it is a declarative macro
1155 pub fn is_declarative(&self) -> bool {
1156 matches!(self.id.kind, MacroDefKind::Declarative(..))
1157 } 1160 }
1158} 1161}
1159 1162