about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-23 12:46:33 +0000
committerbors <bors@rust-lang.org>2014-06-23 12:46:33 +0000
commitbaa72085f41a4e935e671041899da7360f8ba151 (patch)
treeae57c03d738ee5586e9795bbe3ab6ebcb7020573 /src/libsyntax/parse/parser.rs
parent4362db0d6878ef2bdb3407d7ce55cb72a3277b82 (diff)
parentff50ce9a1b43720d7147251904c29b9503ea9dd9 (diff)
downloadrust-baa72085f41a4e935e671041899da7360f8ba151.tar.gz
rust-baa72085f41a4e935e671041899da7360f8ba151.zip
auto merge of #15098 : ben0x539/rust/nullary-tuple-struct, r=pcwalton
Reject `struct Foo();` to fix #15095.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 043ce3bf5b0..4a75473ac11 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4116,6 +4116,11 @@ impl<'a> Parser<'a> {
                 };
                 spanned(lo, p.span.hi, struct_field_)
             });
+            if fields.len() == 0 {
+                self.fatal(format!("unit-like struct definition should be \
+                                    written as `struct {};`",
+                                   token::get_ident(class_name)).as_slice());
+            }
             self.expect(&token::SEMI);
         } else if self.eat(&token::SEMI) {
             // It's a unit-like struct.