Avoid extra error for type mismatches in patterns

When a type error has already occurred, don't call ty::subst,
which may ICE due to the mismatch in the number of type params
involved.

I'm deeming this too small to review.

Closes #3680
This commit is contained in:
Tim Chevalier 2012-12-11 13:10:30 -08:00
parent 35209cb9ec
commit 6439f2d546
2 changed files with 11 additions and 3 deletions

View File

@ -95,7 +95,16 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
let vinfo =
ty::enum_variant_with_id(
tcx, v_def_ids.enm, v_def_ids.var);
vinfo.args.map(|t| { ty::subst(tcx, expected_substs, *t) })
let var_tpt = ty::lookup_item_type(tcx, v_def_ids.var);
vinfo.args.map(|t| {
if var_tpt.bounds.len() == expected_substs.tps.len() {
ty::subst(tcx, expected_substs, *t)
}
else {
*t // In this case, an error was already signaled
// anyway
}
})
};
kind_name = "variant";

View File

@ -8,8 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
fn f() {
fn main() {
match None {
Err(_) => () //~ ERROR expected `core::result
}