Skip to content

Commit 382e72d

Browse files
committed
---
yaml --- r: 36665 b: refs/heads/try2 c: 7d556e1 h: refs/heads/master i: 36663: b44d7cd v: v3
1 parent 343c42b commit 382e72d

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 6e38e334de13d878da91991c4c5e9014a06f93cb
8+
refs/heads/try2: 7d556e18b05dbac67d2c5d17c332b5d44afcb192
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/libsyntax/ext/deriving.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -698,26 +698,30 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
698698
};
699699
other_arms.push(move matching_arm);
700700

701-
// Create the nonmatching pattern.
702-
let nonmatching_pat = @{
703-
id: cx.next_id(),
704-
node: pat_wild,
705-
span: span
706-
};
707-
708-
// Create the nonmatching pattern body.
709-
let nonmatching_expr = build::mk_bool(cx, span, !is_eq);
710-
let nonmatching_body_block = build::mk_simple_block(cx,
711-
span,
712-
nonmatching_expr);
713-
714-
// Create the nonmatching arm.
715-
let nonmatching_arm = {
716-
pats: ~[ nonmatching_pat ],
717-
guard: None,
718-
body: move nonmatching_body_block
719-
};
720-
other_arms.push(move nonmatching_arm);
701+
// Maybe generate a non-matching case. If there is only one
702+
// variant then there will always be a match.
703+
if enum_definition.variants.len() > 1 {
704+
// Create the nonmatching pattern.
705+
let nonmatching_pat = @{
706+
id: cx.next_id(),
707+
node: pat_wild,
708+
span: span
709+
};
710+
711+
// Create the nonmatching pattern body.
712+
let nonmatching_expr = build::mk_bool(cx, span, !is_eq);
713+
let nonmatching_body_block = build::mk_simple_block(cx,
714+
span,
715+
nonmatching_expr);
716+
717+
// Create the nonmatching arm.
718+
let nonmatching_arm = {
719+
pats: ~[ nonmatching_pat ],
720+
guard: None,
721+
body: move nonmatching_body_block
722+
};
723+
other_arms.push(move nonmatching_arm);
724+
}
721725

722726
// Create the self pattern.
723727
let self_pat = create_enum_variant_pattern(cx,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
type task_id = int;
2+
3+
#[deriving_eq]
4+
pub enum Task {
5+
TaskHandle(task_id)
6+
}
7+
8+
fn main() { }

0 commit comments

Comments
 (0)