This commit is contained in:
Tim Chevalier 2013-05-03 13:03:01 -07:00
parent 13df2ea69c
commit 32b3d3e9eb

View File

@ -120,12 +120,12 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
let enum_tpt = ty::lookup_item_type(tcx, enm);
instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id,
pcx.block_region);
// check that the type of the value being matched is a subtype
// of the type of the pattern:
let pat_ty = fcx.node_ty(pat.id);
demand::subtype(fcx, pat.span, expected, pat_ty);
// Get the expected types of the arguments.
arg_types = {
let vinfo =
@ -143,7 +143,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
}
})
};
kind_name = "variant";
}
None => {
@ -151,10 +151,10 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
fcx.infcx().type_error_message_str(pat.span,
|actual| {
fmt!("mismatched types: expected `%s` but found %s",
resolved_expected, actual)},
~"a structure pattern",
None);
fmt!("mismatched types: expected `%s` but found %s",
resolved_expected, actual)},
~"a structure pattern",
None);
fcx.write_error(pat.id);
kind_name = "[error]";
arg_types = (copy subpats).get_or_default(~[]).map(|_|