Skip to content

Commit 2ec3a0b

Browse files
committed
correct fully qualified type names to include the crate; add tests
fixes #1745
1 parent d972226 commit 2ec3a0b

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/comp/metadata/csearch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
6060
fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {
6161
let cstore = tcx.sess.cstore;
6262
let cdata = cstore::get_crate_data(cstore, def.crate);
63-
ret decoder::get_item_path(cdata, def.node);
63+
let path = decoder::get_item_path(cdata, def.node);
64+
[ast_map::path_mod(cdata.name)] + path
6465
}
6566

6667
fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] {

src/comp/middle/ast_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn path_to_str_with_sep(p: path, sep: str) -> str {
1717
}
1818

1919
fn path_to_str(p: path) -> str {
20-
path_to_str_with_sep(p, "::")
20+
"::" + path_to_str_with_sep(p, "::")
2121
}
2222

2323
enum ast_node {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Test that we use fully-qualified type names in error messages.
2+
3+
fn main() {
4+
let x: option<uint>;
5+
x = 5;
6+
//!^ ERROR mismatched types: expected `::core::option::t<uint>`
7+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Test that we use fully-qualified type names in error messages.
2+
3+
mod x {
4+
enum foo { }
5+
}
6+
7+
mod y {
8+
enum foo { }
9+
}
10+
11+
fn bar(x: x::foo) -> y::foo {
12+
ret x;
13+
//!^ ERROR mismatched types: expected `::y::foo` but found `::x::foo`
14+
}
15+
16+
fn main() {
17+
}

0 commit comments

Comments
 (0)