Skip to content

Commit e47f8fc

Browse files
committed
Handle external-crate case when printing full unresolved paths
Closes #1283
1 parent 163c42b commit e47f8fc

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/comp/middle/resolve.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import syntax::{ast, ast_util, codemap};
33
import syntax::ast::*;
44
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};
66

77
import metadata::{csearch, cstore};
88
import driver::session::session;
@@ -609,7 +609,15 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
609609
}
610610
}
611611
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+
}
613621
}
614622
}
615623
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)
783791
while i > 0u {
784792
i -= 1u;
785793
df =
786-
ast::def_upvar(ast_util::def_id_of_def(df), @df,
794+
ast::def_upvar(def_id_of_def(df), @df,
787795
closing[i]);
788796
fnd = some(df);
789797
}
@@ -997,7 +1005,7 @@ fn lookup_in_mod_strict(e: env, m: def, sp: span, name: ident,
9971005

9981006
fn lookup_in_mod(e: env, m: def, sp: span, name: ident, ns: namespace,
9991007
dr: dir) -> option::t<def> {
1000-
let defid = ast_util::def_id_of_def(m);
1008+
let defid = def_id_of_def(m);
10011009
if defid.crate != ast::local_crate {
10021010
// examining a module in an external crate
10031011
let cached = e.ext_cache.find({did: defid, ident: name, ns: ns});
@@ -1277,7 +1285,7 @@ fn ns_for_def(d: def) -> namespace {
12771285
fn lookup_external(e: env, cnum: int, ids: [ident], ns: namespace) ->
12781286
option::t<def> {
12791287
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);
12811289
if ns == ns_for_def(d) { ret some(d); }
12821290
}
12831291
ret none::<def>;

0 commit comments

Comments
 (0)