diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 0ecff4260fbc..e3718933caad 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1264,7 +1264,18 @@ fn valid_range_bounds(from: @ast::expr, to: @ast::expr) -> bool { fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat, expected: ty::t) { alt pat.node { - ast::pat_wild. { write::ty_only_fixup(fcx, pat.id, expected); } + ast::pat_wild. { + alt structure_of(fcx, pat.span, expected) { + ty::ty_tag(_, expected_tps) { + let path_tpt = {substs: some(expected_tps), + ty: expected}; + write::ty_fixup(fcx, pat.id, path_tpt); + } + _ { + write::ty_only_fixup(fcx, pat.id, expected); + } + } + } ast::pat_lit(lt) { check_expr_with(fcx, lt, expected); write::ty_only_fixup(fcx, pat.id, expr_ty(fcx.ccx.tcx, lt)); diff --git a/src/test/run-fail/alt-wildcards.rs b/src/test/run-fail/alt-wildcards.rs new file mode 100644 index 000000000000..4d89679e70ee --- /dev/null +++ b/src/test/run-fail/alt-wildcards.rs @@ -0,0 +1,9 @@ +// error-pattern:squirrelcupcake +fn cmp() -> int { + alt(option::some('a'), option::none::) { + (option::some(_), _) { fail "squirrelcupcake"; } + (_, option::some(_)) { fail; } + } +} + +fn main() { log(error, cmp()); }