@@ -502,6 +502,16 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
502502 let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
503503 do enter_match(bcx, tcx.def_map, m, col, val) |p| {
504504 match p.node {
505+ ast::pat_enum(*) |
506+ ast::pat_ident(_, _, None) if pat_is_const(tcx.def_map, p) => {
507+ let const_def = tcx.def_map.get(&p.id);
508+ let const_def_id = ast_util::def_id_of_def(const_def);
509+ if opt_eq(tcx, &lit(ConstLit(const_def_id)), opt) {
510+ Some(~[])
511+ } else {
512+ None
513+ }
514+ }
505515 ast::pat_enum(_, ref subpats) => {
506516 if opt_eq(tcx, &variant_opt(bcx, p.id), opt) {
507517 match *subpats {
@@ -520,15 +530,6 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
520530 None
521531 }
522532 }
523- ast::pat_ident(_, _, None) if pat_is_const(tcx.def_map, p) => {
524- let const_def = tcx.def_map.get(&p.id);
525- let const_def_id = ast_util::def_id_of_def(const_def);
526- if opt_eq(tcx, &lit(ConstLit(const_def_id)), opt) {
527- Some(~[])
528- } else {
529- None
530- }
531- }
532533 ast::pat_lit(l) => {
533534 if opt_eq(tcx, &lit(ExprLit(l)), opt) {Some(~[])} else {None}
534535 }
@@ -806,6 +807,10 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
806807 add_to_set(ccx.tcx, &mut found,
807808 variant_opt(bcx, cur.id));
808809 }
810+ Some(ast::def_const(const_did)) => {
811+ add_to_set(ccx.tcx, &mut found,
812+ lit(ConstLit(const_did)));
813+ }
809814 _ => {}
810815 }
811816 }
@@ -1782,6 +1787,9 @@ pub fn bind_irrefutable_pat(bcx: block,
17821787 }
17831788 }
17841789 }
1790+ Some ( ast:: def_const ( * ) ) => {
1791+ bcx = bind_irrefutable_pat ( bcx, pat, val, make_copy, binding_mode) ;
1792+ }
17851793 _ => {
17861794 // Nothing to do here.
17871795 }
0 commit comments