mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #13425 - Manishearth:no-crash-empty-dom, r=emilio,Ms2ger
Don't crash when #[dom_struct] is applied on an empty struct <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13425) <!-- Reviewable:end -->
This commit is contained in:
commit
1ed3521dcf
1 changed files with 5 additions and 0 deletions
|
@ -12,6 +12,11 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, annotatable:
|
|||
push: &mut FnMut(Annotatable)) {
|
||||
if let &Annotatable::Item(ref item) = annotatable {
|
||||
if let ItemKind::Struct(ref def, _) = item.node {
|
||||
if def.fields().is_empty() {
|
||||
cx.span_err(span, "#[dom_struct] should have a reflector or \
|
||||
parent dom struct as its first field");
|
||||
return;
|
||||
}
|
||||
let struct_name = item.ident;
|
||||
// This path has to be hardcoded, unfortunately, since we can't resolve paths at expansion time
|
||||
match def.fields().iter().find(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue