hash_substructure(a, b, c)
})
}
- )
+ ),
+ associated_types: Vec::new(),
};
hash_trait_def.expand(cx, mitem, item, push);
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 call_hash = |&: span, thing_expr| {
let hash_path = {
// iteration function.
let discriminant = match variant.node.disr_expr {
Some(ref d) => d.clone(),
- None => cx.expr_uint(trait_span, index)
+ None => cx.expr_usize(trait_span, index)
};
stmts.push(call_hash(trait_span, discriminant));
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))
}