Make #[derive(Anything)] into sugar for #[derive_Anything]

This is a hack, but I don't think we can do much better as long as `derive` is
running at the syntax expansion phase.

If the custom_derive feature gate is enabled, this works with user-defined
traits and syntax extensions. Without the gate, you can't use e.g. #[derive_Clone]
directly, so this does not change the stable language.

This commit also cleans up the deriving code somewhat, and forbids some
previously-meaningless attribute syntax. For this reason it's technically a

    [breaking-change]
This commit is contained in:
Keegan McAllister
2015-03-06 13:15:54 -08:00
parent e60e6f0693
commit 491054f08e
14 changed files with 369 additions and 122 deletions

View File

@@ -491,10 +491,8 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>)
syntax_expanders.insert(intern("log_syntax"),
builtin_normal_expander(
ext::log_syntax::expand_syntax_ext));
syntax_expanders.insert(intern("derive"),
Decorator(Box::new(ext::deriving::expand_meta_derive)));
syntax_expanders.insert(intern("deriving"),
Decorator(Box::new(ext::deriving::expand_deprecated_deriving)));
ext::deriving::register_all(&mut syntax_expanders);
if ecfg.enable_quotes() {
// Quasi-quoting expanders