From 259c42f00e2e85594c7373166bc8467ce375a045 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 13 Dec 2019 21:43:53 +0100 Subject: Add macros for known names and paths --- crates/ra_hir_expand/src/builtin_derive.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir_expand/src/builtin_derive.rs') diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 574637602..d7f8ada78 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -12,10 +12,10 @@ use crate::db::AstDatabase; use crate::{name, quote, MacroCallId, MacroDefId, MacroDefKind}; macro_rules! register_builtin { - ( $(($name:ident, $kind: ident) => $expand:ident),* ) => { + ( $($trait:ident => $expand:ident),* ) => { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum BuiltinDeriveExpander { - $($kind),* + $($trait),* } impl BuiltinDeriveExpander { @@ -26,7 +26,7 @@ macro_rules! register_builtin { tt: &tt::Subtree, ) -> Result { let expander = match *self { - $( BuiltinDeriveExpander::$kind => $expand, )* + $( BuiltinDeriveExpander::$trait => $expand, )* }; expander(db, id, tt) } @@ -34,7 +34,7 @@ macro_rules! register_builtin { pub fn find_builtin_derive(ident: &name::Name) -> Option { let kind = match ident { - $( id if id == &name::$name => BuiltinDeriveExpander::$kind, )* + $( id if id == &name::N![$trait] => BuiltinDeriveExpander::$trait, )* _ => return None, }; @@ -44,15 +44,15 @@ macro_rules! register_builtin { } register_builtin! { - (COPY_TRAIT, Copy) => copy_expand, - (CLONE_TRAIT, Clone) => clone_expand, - (DEFAULT_TRAIT, Default) => default_expand, - (DEBUG_TRAIT, Debug) => debug_expand, - (HASH_TRAIT, Hash) => hash_expand, - (ORD_TRAIT, Ord) => ord_expand, - (PARTIAL_ORD_TRAIT, PartialOrd) => partial_ord_expand, - (EQ_TRAIT, Eq) => eq_expand, - (PARTIAL_EQ_TRAIT, PartialEq) => partial_eq_expand + Copy => copy_expand, + Clone => clone_expand, + Default => default_expand, + Debug => debug_expand, + Hash => hash_expand, + Ord => ord_expand, + PartialOrd => partial_ord_expand, + Eq => eq_expand, + PartialEq => partial_eq_expand } struct BasicAdtInfo { -- cgit v1.2.3 From 6911bc89a784ce72b4dfd8e0ba72bd22ce898395 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 13 Dec 2019 22:01:06 +0100 Subject: Rename N! to name! --- crates/ra_hir_expand/src/builtin_derive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_expand/src/builtin_derive.rs') diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index d7f8ada78..b26441253 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -34,7 +34,7 @@ macro_rules! register_builtin { pub fn find_builtin_derive(ident: &name::Name) -> Option { let kind = match ident { - $( id if id == &name::N![$trait] => BuiltinDeriveExpander::$trait, )* + $( id if id == &name::name![$trait] => BuiltinDeriveExpander::$trait, )* _ => return None, }; -- cgit v1.2.3