1
Fork 0

deriving: error out when used on a non-type

Besides being more helpful, this gives us the flexibility to later define
a meaning for something like

    #[deriving(...)]
    mod bar { ... }
This commit is contained in:
Keegan McAllister 2014-11-18 14:02:40 -08:00
parent 09e2ad13d0
commit ad61ff4b81
2 changed files with 45 additions and 2 deletions

View file

@ -335,7 +335,7 @@ pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>)
impl<'a> TraitDef<'a> {
pub fn expand(&self,
cx: &mut ExtCtxt,
_mitem: &ast::MetaItem,
mitem: &ast::MetaItem,
item: &ast::Item,
push: |P<ast::Item>|) {
let newitem = match item.node {
@ -351,7 +351,10 @@ impl<'a> TraitDef<'a> {
item.ident,
generics)
}
_ => return
_ => {
cx.span_err(mitem.span, "`deriving` may only be applied to structs and enums");
return;
}
};
// Keep the lint attributes of the previous item to control how the
// generated implementations are linted