Skip to content

Commit 69f4126

Browse files
authored
Rollup merge of #37034 - nox:empty-trait-list, r=alexcrichton
Do not add an empty #[derive()] list in expand_derive (fixes #37033)
2 parents c1a19b8 + 0d1ab4e commit 69f4126

File tree

1 file changed

+6
-4
lines changed
  • src/libsyntax_ext/deriving

1 file changed

+6
-4
lines changed

src/libsyntax_ext/deriving/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ pub fn expand_derive(cx: &mut ExtCtxt,
154154
});
155155
if new_attributes.len() > 0 {
156156
item = item.map(|mut i| {
157-
let list = cx.meta_list(mitem.span,
158-
intern_and_get_ident("derive"),
159-
traits);
160157
i.attrs.extend(new_attributes);
161-
i.attrs.push(cx.attribute(mitem.span, list));
158+
if traits.len() > 0 {
159+
let list = cx.meta_list(mitem.span,
160+
intern_and_get_ident("derive"),
161+
traits);
162+
i.attrs.push(cx.attribute(mitem.span, list));
163+
}
162164
i
163165
});
164166
return vec![Annotatable::Item(item)]

0 commit comments

Comments
 (0)