Skip to content

Commit cbc32cc

Browse files
committed
---
yaml --- r: 276603 b: refs/heads/try c: c480b6a h: refs/heads/master i: 276601: 3e0fcfd 276599: 4d127cd
1 parent e4cec22 commit cbc32cc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 01c0723ef247fec4b85af203c7247b66e3817e1b
4+
refs/heads/try: c480b6a75df08cef48190e3c18eab26e99bae58c
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/libsyntax_ext/deriving/hash.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use deriving;
1212
use deriving::generic::*;
1313
use deriving::generic::ty::*;
1414

15-
use syntax::ast::{MetaItem, Expr, Mutability};
15+
use syntax::ast::{self, MetaItem, Expr, Mutability};
1616
use syntax::codemap::Span;
1717
use syntax::ext::base::{ExtCtxt, Annotatable};
1818
use syntax::ext::build::AstBuilder;
@@ -81,15 +81,18 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
8181

8282
let fields = match *substr.fields {
8383
Struct(_, ref fs) => fs,
84-
EnumMatching(index, variant, ref fs) => {
85-
// Determine the discriminant. We will feed this value to the byte
86-
// iteration function.
87-
let discriminant = match variant.node.disr_expr {
88-
Some(ref d) => d.clone(),
89-
None => cx.expr_usize(trait_span, index)
90-
};
84+
EnumMatching(_, _, ref fs) => {
85+
let path = cx.std_path(&["intrinsics", "discriminant_value"]);
86+
let call = cx.expr_call_global(
87+
trait_span, path, vec![cx.expr_self(trait_span)]);
88+
let variant_value = cx.expr_block(P(ast::Block {
89+
stmts: vec![],
90+
expr: Some(call),
91+
id: ast::DUMMY_NODE_ID,
92+
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
93+
span: trait_span }));
9194

92-
stmts.push(call_hash(trait_span, discriminant));
95+
stmts.push(call_hash(trait_span, variant_value));
9396

9497
fs
9598
}

0 commit comments

Comments
 (0)