@@ -64,6 +64,8 @@ pub struct Registry<'a> {
6464
6565 #[ doc( hidden) ]
6666 pub attributes : Vec < ( String , AttributeType ) > ,
67+
68+ whitelisted_custom_derives : Vec < ast:: Name > ,
6769}
6870
6971impl < ' a > Registry < ' a > {
@@ -80,6 +82,7 @@ impl<'a> Registry<'a> {
8082 llvm_passes : vec ! [ ] ,
8183 attributes : vec ! [ ] ,
8284 mir_passes : Vec :: new ( ) ,
85+ whitelisted_custom_derives : Vec :: new ( ) ,
8386 }
8487 }
8588
@@ -115,6 +118,21 @@ impl<'a> Registry<'a> {
115118 } ) ) ;
116119 }
117120
121+ /// This can be used in place of `register_syntax_extension` to register legacy custom derives
122+ /// (i.e. attribute syntax extensions whose name begins with `derive_`). Legacy custom
123+ /// derives defined by this function do not trigger deprecation warnings when used.
124+ #[ unstable( feature = "rustc_private" , issue = "27812" ) ]
125+ #[ rustc_deprecated( since = "1.15.0" , reason = "replaced by macros 1.1 (RFC 1861)" ) ]
126+ pub fn register_custom_derive ( & mut self , name : ast:: Name , extension : SyntaxExtension ) {
127+ assert ! ( name. as_str( ) . starts_with( "derive_" ) ) ;
128+ self . whitelisted_custom_derives . push ( name) ;
129+ self . register_syntax_extension ( name, extension) ;
130+ }
131+
132+ pub fn take_whitelisted_custom_derives ( & mut self ) -> Vec < ast:: Name > {
133+ :: std:: mem:: replace ( & mut self . whitelisted_custom_derives , Vec :: new ( ) )
134+ }
135+
118136 /// Register a macro of the usual kind.
119137 ///
120138 /// This is a convenience wrapper for `register_syntax_extension`.
0 commit comments