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.
This commit is contained in:
Tim Chevalier
2013-05-02 15:38:19 -07:00
parent 4332f8188b
commit 13df2ea69c
4 changed files with 85 additions and 34 deletions

View File

@@ -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
}
}