aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-09-27 06:04:57 -0500
committerGitHub <noreply@github.com>2016-09-27 06:04:57 -0500
commit1ed3521dcfdf573dd68afe18148e785a8af2389a (patch)
treef7a2e83a81a6636c59a02bbe56610122a7603009
parent2474393d15b4e6259bdcf366d3423c3a6cd2eaac (diff)
parent85b65fc0d3c5e6ceca3f79b24f6e8f3c83a3f136 (diff)
downloadservo-1ed3521dcfdf573dd68afe18148e785a8af2389a.tar.gz
servo-1ed3521dcfdf573dd68afe18148e785a8af2389a.zip
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 -->
-rw-r--r--components/plugins/reflector.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/components/plugins/reflector.rs b/components/plugins/reflector.rs
index 04e22fa826c..27f8054fd54 100644
--- a/components/plugins/reflector.rs
+++ b/components/plugins/reflector.rs
@@ -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(