Skip to content

Commit 34bf0b9

Browse files
committed
trans: overhaul match bindings. No more phi, one code path for guards.
Fixes #3256. Fixes #3291.
1 parent ff54ac8 commit 34bf0b9

File tree

8 files changed

+724
-401
lines changed

8 files changed

+724
-401
lines changed

src/rustc/driver/session.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type config =
3838
uint_type: uint_ty,
3939
float_type: float_ty};
4040

41-
const ppregions: uint = 1 << 0;
41+
const verbose: uint = 1 << 0;
4242
const time_passes: uint = 1 << 1;
4343
const count_llvm_insns: uint = 1 << 2;
4444
const time_llvm_passes: uint = 1 << 3;
@@ -60,8 +60,7 @@ const meta_stats: uint = 1 << 16;
6060
const no_opt: uint = 1 << 17;
6161

6262
fn debugging_opts_map() -> ~[(~str, ~str, uint)] {
63-
~[(~"ppregions", ~"prettyprint regions with \
64-
internal repr details", ppregions),
63+
~[(~"verbose", ~"in general, enable more debug printouts", verbose),
6564
(~"time-passes", ~"measure time of each rustc pass", time_passes),
6665
(~"count-llvm-insns", ~"count where LLVM \
6766
instrs originate", count_llvm_insns),
@@ -219,7 +218,7 @@ impl session {
219218
fn impossible_case(sp: span, msg: &str) -> ! {
220219
self.span_bug(sp, #fmt("Impossible case reached: %s", msg));
221220
}
222-
fn ppregions() -> bool { self.debugging_opt(ppregions) }
221+
fn verbose() -> bool { self.debugging_opt(verbose) }
223222
fn time_passes() -> bool { self.debugging_opt(time_passes) }
224223
fn count_llvm_insns() -> bool { self.debugging_opt(count_llvm_insns) }
225224
fn count_type_sizes() -> bool { self.debugging_opt(count_type_sizes) }

src/rustc/middle/pat_util.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use syntax::fold::*;
66
use syntax::codemap::span;
77
use std::map::HashMap;
88

9-
export pat_binding_ids, pat_bindings, pat_id_map;
10-
export pat_is_variant;
9+
export pat_binding_ids, pat_bindings, pat_id_map, PatIdMap;
10+
export pat_is_variant, pat_is_binding_or_wild;
1111

12-
type pat_id_map = std::map::HashMap<ident, node_id>;
12+
type PatIdMap = std::map::HashMap<ident, node_id>;
1313

1414
// This is used because same-named variables in alternative patterns need to
1515
// use the node_id of their namesake in the first pattern.
16-
fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> pat_id_map {
16+
fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> PatIdMap {
1717
let map = std::map::uint_hash();
1818
do pat_bindings(dm, pat) |_bm, p_id, _s, n| {
1919
map.insert(path_to_ident(n), p_id);
@@ -32,6 +32,14 @@ fn pat_is_variant(dm: resolve::DefMap, pat: @pat) -> bool {
3232
}
3333
}
3434

35+
fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool {
36+
match pat.node {
37+
pat_ident(*) => !pat_is_variant(dm, pat),
38+
pat_wild => true,
39+
_ => false
40+
}
41+
}
42+
3543
fn pat_bindings(dm: resolve::DefMap, pat: @pat,
3644
it: fn(binding_mode, node_id, span, @path)) {
3745
do walk_pat(pat) |p| {

0 commit comments

Comments
 (0)