Skip to content

Commit f1aa9f0

Browse files
committed
---
yaml --- r: 40760 b: refs/heads/dist-snap c: 7d556e1 h: refs/heads/master v: v3
1 parent 9a2fd60 commit f1aa9f0

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
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: 6e38e334de13d878da91991c4c5e9014a06f93cb
10+
refs/heads/dist-snap: 7d556e18b05dbac67d2c5d17c332b5d44afcb192
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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)