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:
parent
35209cb9ec
commit
6439f2d546
@ -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";
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user