1
Fork 0

only set non-ADT derive error once per attribute, not per trait

A slight eccentricity of this change is that now non-ADT-derive errors prevent
derive-macro-not-found errors from surfacing (see changes to the
gating-of-derive compile-fail tests).

Resolves #43927.
This commit is contained in:
Zack M. Davis 2017-08-22 19:22:52 -07:00
parent 17f56c549c
commit 35176867f6
6 changed files with 52 additions and 30 deletions

View file

@ -428,8 +428,9 @@ impl<'a> TraitDef<'a> {
}
}
_ => {
cx.span_err(mitem.span,
"`derive` may only be applied to structs, enums and unions");
// Non-ADT derive is an error, but it should have been
// set earlier; see
// libsyntax/ext/expand.rs:MacroExpander::expand()
return;
}
};
@ -448,8 +449,10 @@ impl<'a> TraitDef<'a> {
push(Annotatable::Item(P(ast::Item { attrs: attrs, ..(*newitem).clone() })))
}
_ => {
cx.span_err(mitem.span,
"`derive` may only be applied to structs and enums");
// Non-Item derive is an error, but it should have been
// set earlier; see
// libsyntax/ext/expand.rs:MacroExpander::expand()
return;
}
}
}