Do not add an empty #[derive()] list in expand_derive (fixes #37033)

This commit is contained in:
Anthony Ramine 2016-10-08 01:42:58 +02:00
parent 46957f0577
commit 0d1ab4e9e4

View File

@ -154,11 +154,13 @@ pub fn expand_derive(cx: &mut ExtCtxt,
});
if new_attributes.len() > 0 {
item = item.map(|mut i| {
let list = cx.meta_list(mitem.span,
intern_and_get_ident("derive"),
traits);
i.attrs.extend(new_attributes);
i.attrs.push(cx.attribute(mitem.span, list));
if traits.len() > 0 {
let list = cx.meta_list(mitem.span,
intern_and_get_ident("derive"),
traits);
i.attrs.push(cx.attribute(mitem.span, list));
}
i
});
return vec![Annotatable::Item(item)]