diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-05-02 15:38:19 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-05-03 13:03:53 -0700 |
| commit | 13df2ea69c332d7a20c7ab394020430a09dad507 (patch) | |
| tree | b22cc70abd3fa39f64e09fffffbc362a88db0d0c /src/libsyntax | |
| parent | 4332f8188b5dca743dfe2913b3f50a7a693ee3ef (diff) | |
| download | rust-13df2ea69c332d7a20c7ab394020430a09dad507.tar.gz rust-13df2ea69c332d7a20c7ab394020430a09dad507.zip | |
rustc: Handle struct patterns where the expected type is an enum
Previously, rustc would ICE if you matched on an enum-typed thing with a structure pattern. Error out correctly.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 47ef7227842..10350413f2d 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -41,12 +41,12 @@ pub fn stmt_id(s: &stmt) -> node_id { } } -pub fn variant_def_ids(d: def) -> (def_id, def_id) { +pub fn variant_def_ids(d: def) -> Option<(def_id, def_id)> { match d { def_variant(enum_id, var_id) => { - return (enum_id, var_id); + Some((enum_id, var_id)) } - _ => fail!(~"non-variant in variant_def_ids") + _ => None } } |
