Skip to content

Commit 84f489c

Browse files
committed
---
yaml --- r: 3805 b: refs/heads/master c: c893188 h: refs/heads/master i: 3803: 0c0dcc5 v: v3
1 parent de179f9 commit 84f489c

File tree

2 files changed

+35
-71
lines changed

2 files changed

+35
-71
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 55e348280efbaddd9b5b23617cdaa4f04cebefa0
2+
refs/heads/master: c8931885496aaa8f5cf207a607883a90b68ad519

trunk/src/comp/middle/resolve.rs

Lines changed: 34 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,10 @@ fn map_crate(&@env e, &@ast::crate c) {
206206
alt (sc) {
207207
case (cons(scope_item(?i), ?tl)) {
208208
alt (i.node) {
209-
case (ast::item_mod(_)) {
209+
ast::item_mod(_) | ast::item_native_mod(_) {
210210
ret e.mod_map.get(i.id);
211211
}
212-
case (ast::item_native_mod(_)) {
213-
ret e.mod_map.get(i.id);
214-
}
215-
case (_) { be find_mod(e, *tl); }
212+
_ { be find_mod(e, *tl); }
216213
}
217214
}
218215
case (_) {
@@ -222,9 +219,8 @@ fn map_crate(&@env e, &@ast::crate c) {
222219
}
223220
}
224221
alt (vi.node) {
225-
case (
226-
//if it really is a glob import, that is
227-
ast::view_item_import_glob(?path, _)) {
222+
//if it really is a glob import, that is
223+
case (ast::view_item_import_glob(?path, _)) {
228224
auto imp = follow_import(*e, sc, path, vi.span);
229225
if (option::is_some(imp)) {
230226
find_mod(e, sc).glob_imports +=
@@ -363,14 +359,11 @@ fn visit_arm_with_scope(&ast::arm a, &scopes sc, &vt[scopes] v) {
363359
fn visit_expr_with_scope(&@ast::expr x, &scopes sc, &vt[scopes] v) {
364360
auto new_sc =
365361
alt (x.node) {
366-
case (ast::expr_for(?d, _, _)) {
367-
cons[scope](scope_loop(d), @sc)
368-
}
369-
case (ast::expr_for_each(?d, _, _)) {
362+
ast::expr_for(?d, _, _) | ast::expr_for_each(?d, _, _) {
370363
cons[scope](scope_loop(d), @sc)
371364
}
372-
case (ast::expr_fn(?f)) { cons(scope_fn(f.decl, ~[]), @sc) }
373-
case (_) { sc }
365+
ast::expr_fn(?f) { cons(scope_fn(f.decl, ~[]), @sc) }
366+
_ { sc }
374367
};
375368
visit::visit_expr(x, new_sc, v);
376369
}
@@ -388,9 +381,8 @@ fn follow_import(&env e, &scopes sc, &ident[] path, &span sp)
388381
}
389382
if (i == path_len) {
390383
alt (option::get(dcur)) {
391-
case (ast::def_mod(?def_id)) { ret dcur; }
392-
case (ast::def_native_mod(?def_id)) { ret dcur; }
393-
case (_) {
384+
ast::def_mod(_) | ast::def_native_mod(_) { ret dcur; }
385+
_ {
394386
e.sess.span_err(sp, str::connect_ivec(path, "::") +
395387
" does not name a module.");
396388
ret none;
@@ -579,19 +571,16 @@ fn lookup_in_scope_strict(&env e, scopes sc, &span sp, &ident name,
579571

580572
fn scope_is_fn(&scope sc) -> bool {
581573
ret alt (sc) {
582-
case (scope_fn(_, _)) { true }
583-
case (scope_native_item(_)) { true }
584-
case (_) { false }
574+
scope_fn(_, _) | scope_native_item(_) { true }
575+
_ { false }
585576
};
586577
}
587578

588579
fn def_is_local(&def d) -> bool {
589580
ret alt (d) {
590-
case (ast::def_arg(_)) { true }
591-
case (ast::def_local(_)) { true }
592-
case (ast::def_binding(_)) { true }
593-
case (_) { false }
594-
};
581+
ast::def_arg(_) | ast::def_local(_) | ast::def_binding(_) { true }
582+
_ { false }
583+
};
595584
}
596585

597586
fn def_is_obj_field(&def d) -> bool {
@@ -1092,25 +1081,12 @@ fn index_mod(&ast::_mod md) -> mod_index {
10921081
}
10931082
for (@ast::item it in md.items) {
10941083
alt (it.node) {
1095-
case (ast::item_const(_, _)) {
1096-
add_to_index(index, it.ident, mie_item(it));
1097-
}
1098-
case (ast::item_fn(_, _)) {
1099-
add_to_index(index, it.ident, mie_item(it));
1100-
}
1101-
case (ast::item_mod(_)) {
1102-
add_to_index(index, it.ident, mie_item(it));
1103-
}
1104-
case (ast::item_native_mod(_)) {
1105-
add_to_index(index, it.ident, mie_item(it));
1106-
}
1107-
case (ast::item_ty(_, _)) {
1108-
add_to_index(index, it.ident, mie_item(it));
1109-
}
1110-
case (ast::item_res(_, _, _, _)) {
1084+
ast::item_const(_, _) | ast::item_fn(_, _) | ast::item_mod(_) |
1085+
ast::item_native_mod(_) | ast::item_ty(_, _) |
1086+
ast::item_res(_, _, _, _) | ast::item_obj(_, _, _) {
11111087
add_to_index(index, it.ident, mie_item(it));
11121088
}
1113-
case (ast::item_tag(?variants, _)) {
1089+
ast::item_tag(?variants, _) {
11141090
add_to_index(index, it.ident, mie_item(it));
11151091
let uint variant_idx = 0u;
11161092
for (ast::variant v in variants) {
@@ -1119,9 +1095,6 @@ fn index_mod(&ast::_mod md) -> mod_index {
11191095
variant_idx += 1u;
11201096
}
11211097
}
1122-
case (ast::item_obj(_, _, _)) {
1123-
add_to_index(index, it.ident, mie_item(it));
1124-
}
11251098
}
11261099
}
11271100
ret index;
@@ -1228,12 +1201,12 @@ fn check_mod_name(&env e, &ident name, list[mod_index_entry] entries) {
12281201
}
12291202

12301203
fn mie_span(&mod_index_entry mie) -> span {
1231-
alt (mie) {
1232-
case (mie_view_item(?item)) { ret item.span; }
1233-
case (mie_item(?item)) { ret item.span; }
1234-
case (mie_tag_variant(?item, _)) { ret item.span; }
1235-
case (mie_native_item(?item)) { ret item.span; }
1236-
}
1204+
ret alt (mie) {
1205+
mie_view_item(?item) { item.span }
1206+
mie_item(?item) { item.span }
1207+
mie_tag_variant(?item, _) { item.span }
1208+
mie_native_item(?item) { item.span }
1209+
};
12371210
}
12381211

12391212
fn check_item(@env e, &@ast::item i, &() x, &vt[()] v) {
@@ -1313,41 +1286,32 @@ fn check_block(@env e, &ast::block b, &() x, &vt[()] v) {
13131286
alt (st.node) {
13141287
case (ast::stmt_decl(?d, _)) {
13151288
alt (d.node) {
1316-
case (ast::decl_local(?loc)) {
1289+
ast::decl_local(?loc) {
13171290
add_name(values, d.span, loc.node.ident);
13181291
}
1319-
case (ast::decl_item(?it)) {
1292+
ast::decl_item(?it) {
13201293
alt (it.node) {
1321-
case (ast::item_tag(?variants, _)) {
1294+
ast::item_tag(?variants, _) {
13221295
add_name(types, it.span, it.ident);
13231296
for (ast::variant v in variants) {
13241297
add_name(values, v.span, v.node.name);
13251298
}
13261299
}
1327-
case (ast::item_const(_, _)) {
1328-
add_name(values, it.span, it.ident);
1329-
}
1330-
case (ast::item_fn(_, _)) {
1331-
add_name(values, it.span, it.ident);
1332-
}
1333-
case (ast::item_mod(_)) {
1334-
add_name(mods, it.span, it.ident);
1335-
}
1336-
case (ast::item_native_mod(_)) {
1300+
ast::item_mod(_) | ast::item_native_mod(_) {
13371301
add_name(mods, it.span, it.ident);
13381302
}
1339-
case (ast::item_ty(_, _)) {
1340-
add_name(types, it.span, it.ident);
1303+
ast::item_const(_, _) | ast::item_fn(_, _) {
1304+
add_name(values, it.span, it.ident);
13411305
}
1342-
case (ast::item_res(_, _, _, _)) {
1306+
ast::item_ty(_, _) {
13431307
add_name(types, it.span, it.ident);
1344-
add_name(values, it.span, it.ident);
13451308
}
1346-
case (ast::item_obj(_, _, _)) {
1309+
ast::item_res(_, _, _, _) |
1310+
ast::item_obj(_, _, _) {
13471311
add_name(types, it.span, it.ident);
13481312
add_name(values, it.span, it.ident);
13491313
}
1350-
case (_) { }
1314+
_ { }
13511315
}
13521316
}
13531317
}

0 commit comments

Comments
 (0)