|
2 | 2 | import syntax::{ast, ast_util, codemap};
|
3 | 3 | import syntax::ast::*;
|
4 | 4 | import ast::{ident, fn_ident, def, def_id, node_id};
|
5 |
| -import syntax::ast_util::local_def; |
| 5 | +import syntax::ast_util::{local_def, def_id_of_def}; |
6 | 6 |
|
7 | 7 | import metadata::{csearch, cstore};
|
8 | 8 | import driver::session::session;
|
@@ -609,7 +609,15 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
|
609 | 609 | }
|
610 | 610 | }
|
611 | 611 | in_mod(def) {
|
612 |
| - path = e.mod_map.get(ast_util::def_id_of_def(def).node).path + path; |
| 612 | + let did = def_id_of_def(def); |
| 613 | + if did.crate == ast::local_crate { |
| 614 | + path = e.mod_map.get(did.node).path + path; |
| 615 | + } else { |
| 616 | + let paths = e.ext_map.get(did); |
| 617 | + if vec::len(paths) > 0u { |
| 618 | + path = str::connect(paths, "::") + "::" + path; |
| 619 | + } |
| 620 | + } |
613 | 621 | }
|
614 | 622 | }
|
615 | 623 | e.sess.span_err(sp, mk_unresolved_msg(path, kind));
|
@@ -783,7 +791,7 @@ fn lookup_in_scope(e: env, sc: scopes, sp: span, name: ident, ns: namespace)
|
783 | 791 | while i > 0u {
|
784 | 792 | i -= 1u;
|
785 | 793 | df =
|
786 |
| - ast::def_upvar(ast_util::def_id_of_def(df), @df, |
| 794 | + ast::def_upvar(def_id_of_def(df), @df, |
787 | 795 | closing[i]);
|
788 | 796 | fnd = some(df);
|
789 | 797 | }
|
@@ -997,7 +1005,7 @@ fn lookup_in_mod_strict(e: env, m: def, sp: span, name: ident,
|
997 | 1005 |
|
998 | 1006 | fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace,
|
999 | 1007 | dr: dir) -> option::t<def> {
|
1000 |
| - let defid = ast_util::def_id_of_def(m); |
| 1008 | + let defid = def_id_of_def(m); |
1001 | 1009 | if defid.crate != ast::local_crate {
|
1002 | 1010 | // examining a module in an external crate
|
1003 | 1011 | let cached = e.ext_cache.find({did: defid, ident: name, ns: ns});
|
@@ -1277,7 +1285,7 @@ fn ns_for_def(d: def) -> namespace {
|
1277 | 1285 | fn lookup_external(e: env, cnum: int, ids: [ident], ns: namespace) ->
|
1278 | 1286 | option::t<def> {
|
1279 | 1287 | for d: def in csearch::lookup_defs(e.sess.get_cstore(), cnum, ids) {
|
1280 |
| - e.ext_map.insert(ast_util::def_id_of_def(d), ids); |
| 1288 | + e.ext_map.insert(def_id_of_def(d), ids); |
1281 | 1289 | if ns == ns_for_def(d) { ret some(d); }
|
1282 | 1290 | }
|
1283 | 1291 | ret none::<def>;
|
|
0 commit comments