about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorAndrew Paseltiner <apaseltiner@gmail.com>2015-01-14 18:56:17 -0500
committerAndrew Paseltiner <apaseltiner@gmail.com>2015-01-15 10:16:44 -0500
commit716effa34900781ddb201fbd50ee679a4964cb25 (patch)
treee36390bee59c4326820c156686249695e51dee57 /src/libsyntax
parent1c78ad937b4da9dd872b0a865025f3e2e885f90d (diff)
downloadrust-716effa34900781ddb201fbd50ee679a4964cb25.tar.gz
rust-716effa34900781ddb201fbd50ee679a4964cb25.zip
support deriving `Hash` for nullary structs
fixes #16530
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/deriving/hash.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs
index db99c142443..0c3ceb2b90b 100644
--- a/src/libsyntax/ext/deriving/hash.rs
+++ b/src/libsyntax/ext/deriving/hash.rs
@@ -63,7 +63,7 @@ pub fn expand_deriving_hash<F>(cx: &mut ExtCtxt,
 fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
     let state_expr = match substr.nonself_args {
         [ref state_expr] => state_expr,
-        _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(Hash)`")
+        _ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`")
     };
     let hash_ident = substr.method_ident;
     let call_hash = |&: span, thing_expr| {
@@ -86,16 +86,12 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
 
             fs
         }
-        _ => cx.span_bug(trait_span, "impossible substructure in `deriving(Hash)`")
+        _ => cx.span_bug(trait_span, "impossible substructure in `derive(Hash)`")
     };
 
     for &FieldInfo { ref self_, span, .. } in fields.iter() {
         stmts.push(call_hash(span, self_.clone()));
     }
 
-    if stmts.len() == 0 {
-        cx.span_bug(trait_span, "#[derive(Hash)] needs at least one field");
-    }
-
     cx.expr_block(cx.block(trait_span, stmts, None))
 }