@@ -23,6 +23,7 @@ extern crate proc_macro;
23
23
use rustc_expand:: base:: { MacroExpanderFn , ResolverExpand , SyntaxExtensionKind } ;
24
24
use rustc_expand:: proc_macro:: BangProcMacro ;
25
25
use rustc_span:: symbol:: sym;
26
+ use smallvec:: smallvec;
26
27
27
28
use crate :: deriving:: * ;
28
29
@@ -66,8 +67,16 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
66
67
macro register_attr( $( $name: ident: $f: expr, ) * ) {
67
68
$( register ( sym:: $name, SyntaxExtensionKind :: LegacyAttr ( Box :: new ( $f) ) ) ; ) *
68
69
}
69
- macro register_derive( $( $name: ident: $f: expr, ) * ) {
70
- $( register ( sym:: $name, SyntaxExtensionKind :: LegacyDerive ( Box :: new ( BuiltinDerive ( $f) ) ) ) ; ) *
70
+ macro_rules! register_derive {
71
+ ( $name: ident: $f: expr, $( $rest: tt) * ) => {
72
+ register( sym:: $name, SyntaxExtensionKind :: LegacyDerive ( Box :: new( BuiltinDerive ( $f) ) , smallvec![ ] ) ) ;
73
+ register_derive!( $( $rest) * ) ;
74
+ } ;
75
+ ( $name: ident( attrs = [ $( $attr: ident) ,+] ) : $f: expr, $( $rest: tt) * ) => {
76
+ register( sym:: $name, SyntaxExtensionKind :: LegacyDerive ( Box :: new( BuiltinDerive ( $f) ) , smallvec![ $( sym:: $attr) ,* ] ) ) ;
77
+ register_derive!( $( $rest) * ) ;
78
+ } ;
79
+ ( ) => { } ;
71
80
}
72
81
73
82
register_bang ! {
@@ -128,7 +137,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
128
137
PartialOrd : partial_ord:: expand_deriving_partial_ord,
129
138
RustcDecodable : decodable:: expand_deriving_rustc_decodable,
130
139
RustcEncodable : encodable:: expand_deriving_rustc_encodable,
131
- SmartPointer : smart_ptr:: expand_deriving_smart_ptr,
140
+ SmartPointer ( attrs = [ pointee ] ) : smart_ptr:: expand_deriving_smart_ptr,
132
141
}
133
142
134
143
let client = proc_macro:: bridge:: client:: Client :: expand1 ( proc_macro:: quote) ;
0 commit comments