Skip to content

Commit 337173e

Browse files
committed
Use register_custom_derive to remove custom_derive deprecation warning.
1 parent d610e0a commit 337173e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

codegen/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
#![feature(quote, concat_idents, plugin_registrar, rustc_private, unicode)]
9494
#![feature(custom_attribute)]
9595
#![allow(unused_attributes)]
96+
#![allow(deprecated)]
9697

9798
#[macro_use] extern crate syntax;
9899
#[macro_use] extern crate log;
@@ -127,6 +128,14 @@ macro_rules! register_decorators {
127128
)
128129
}
129130

131+
macro_rules! register_derives {
132+
($registry:expr, $($name:expr => $func:ident),+) => (
133+
$($registry.register_custom_derive(Symbol::intern($name),
134+
SyntaxExtension::MultiDecorator(Box::new(decorators::$func)));
135+
)+
136+
)
137+
}
138+
130139
/// Compiler hook for Rust to register plugins.
131140
#[plugin_registrar]
132141
pub fn plugin_registrar(reg: &mut Registry) {
@@ -138,9 +147,11 @@ pub fn plugin_registrar(reg: &mut Registry) {
138147
reg.register_macro("routes", macros::routes);
139148
reg.register_macro("errors", macros::errors);
140149

141-
register_decorators!(reg,
142-
"derive_FromForm" => from_form_derive,
150+
register_derives!(reg,
151+
"derive_FromForm" => from_form_derive
152+
);
143153

154+
register_decorators!(reg,
144155
"error" => error_decorator,
145156
"route" => route_decorator,
146157
"get" => get_decorator,

0 commit comments

Comments
 (0)