Skip to content

Commit 56c5ce8

Browse files
committed
---
yaml --- r: 6547 b: refs/heads/master c: 8a1cc73 h: refs/heads/master i: 6545: 8c20f21 6543: 50e7423 v: v3
1 parent 68efa09 commit 56c5ce8

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
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: 7655b3c0c673a6857ccf94835f6cedbe778a8667
2+
refs/heads/master: 8a1cc738fa9bc4af134da01386414d057cc2e719

trunk/src/comp/middle/resolve.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ export ext_map;
2727
// locates all names (in expressions, types, and alt patterns) and resolves
2828
// them, storing the resulting def in the AST nodes.
2929

30-
// This module internally uses -1 as a def_id for the top_level module in a
31-
// crate. The parser doesn't assign a def_id to this module.
32-
// (FIXME See https://github.com/graydon/rust/issues/358 for the reason this
33-
// isn't a const.)
30+
const crate_mod: int = -1;
31+
3432
tag scope {
3533
scope_crate;
3634
scope_item(@ast::item);
@@ -158,7 +156,7 @@ fn map_crate(e: @env, c: @ast::crate) {
158156
visit::visit_crate(*c, cons(scope_crate, @nil), visit::mk_vt(v_map_mod));
159157

160158
// Register the top-level mod
161-
e.mod_map.insert(-1,
159+
e.mod_map.insert(crate_mod,
162160
@{m: some(c.node.module),
163161
index: index_mod(c.node.module),
164162
mutable glob_imports: [],
@@ -228,7 +226,7 @@ fn map_crate(e: @env, c: @ast::crate) {
228226
e.block_map.insert(b.node.id, globs);
229227
}
230228
scope_crate. {
231-
e.mod_map.get(-1).glob_imports += [glob];
229+
e.mod_map.get(crate_mod).glob_imports += [glob];
232230
}
233231
}
234232
}
@@ -636,7 +634,7 @@ fn lookup_in_scope(e: env, sc: scopes, sp: span, name: ident, ns: namespace)
636634
option::t<def> {
637635
alt s {
638636
scope_crate. {
639-
ret lookup_in_local_mod(e, -1, sp, name, ns, inside);
637+
ret lookup_in_local_mod(e, crate_mod, sp, name, ns, inside);
640638
}
641639
scope_item(it) {
642640
alt it.node {
@@ -932,11 +930,10 @@ fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace,
932930
let defid = ast_util::def_id_of_def(m);
933931
if defid.crate != ast::local_crate {
934932
// examining a module in an external crate
935-
936933
let cached = e.ext_cache.find({did: defid, ident: name, ns: ns});
937934
if !is_none(cached) { ret cached; }
938935
let path = [name];
939-
if defid.node != -1 { path = e.ext_map.get(defid) + path; }
936+
if defid.node != crate_mod { path = e.ext_map.get(defid) + path; }
940937
let fnd = lookup_external(e, defid.crate, path, ns);
941938
if !is_none(fnd) {
942939
e.ext_cache.insert({did: defid, ident: name, ns: ns},
@@ -958,7 +955,7 @@ fn found_view_item(e: env, vi: @ast::view_item) -> option::t<def> {
958955
alt vi.node {
959956
ast::view_item_use(_, _, id) {
960957
let cnum = cstore::get_use_stmt_cnum(e.cstore, id);
961-
ret some(ast::def_mod({crate: cnum, node: -1}));
958+
ret some(ast::def_mod({crate: cnum, node: crate_mod}));
962959
}
963960
}
964961
}

0 commit comments

Comments
 (0)