@@ -23,6 +23,7 @@ extern crate proc_macro;
2323use rustc_expand:: base:: { MacroExpanderFn , ResolverExpand , SyntaxExtensionKind } ;
2424use rustc_expand:: proc_macro:: BangProcMacro ;
2525use rustc_span:: symbol:: sym;
26+ use smallvec:: smallvec;
2627
2728use crate :: deriving:: * ;
2829
@@ -66,8 +67,16 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
6667 macro register_attr( $( $name: ident: $f: expr, ) * ) {
6768 $( register ( sym:: $name, SyntaxExtensionKind :: LegacyAttr ( Box :: new ( $f) ) ) ; ) *
6869 }
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+ ( ) => { } ;
7180 }
7281
7382 register_bang ! {
@@ -128,7 +137,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
128137 PartialOrd : partial_ord:: expand_deriving_partial_ord,
129138 RustcDecodable : decodable:: expand_deriving_rustc_decodable,
130139 RustcEncodable : encodable:: expand_deriving_rustc_encodable,
131- SmartPointer : smart_ptr:: expand_deriving_smart_ptr,
140+ SmartPointer ( attrs = [ pointee ] ) : smart_ptr:: expand_deriving_smart_ptr,
132141 }
133142
134143 let client = proc_macro:: bridge:: client:: Client :: expand1 ( proc_macro:: quote) ;
0 commit comments