From 13df2ea69c332d7a20c7ab394020430a09dad507 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 2 May 2013 15:38:19 -0700 Subject: 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. --- src/libsyntax/ast_util.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsyntax') 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 } } -- cgit 1.4.1-3-g733a5