correct fully qualified type names to include the crate; add tests

fixes #1745
This commit is contained in:
Niko Matsakis 2012-02-10 21:28:44 -08:00
parent d972226567
commit 2ec3a0b608
4 changed files with 27 additions and 2 deletions

View file

@ -60,7 +60,8 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {
let cstore = tcx.sess.cstore;
let cdata = cstore::get_crate_data(cstore, def.crate);
ret decoder::get_item_path(cdata, def.node);
let path = decoder::get_item_path(cdata, def.node);
[ast_map::path_mod(cdata.name)] + path
}
fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] {

View file

@ -17,7 +17,7 @@ fn path_to_str_with_sep(p: path, sep: str) -> str {
}
fn path_to_str(p: path) -> str {
path_to_str_with_sep(p, "::")
"::" + path_to_str_with_sep(p, "::")
}
enum ast_node {

View file

@ -0,0 +1,7 @@
// Test that we use fully-qualified type names in error messages.
fn main() {
let x: option<uint>;
x = 5;
//!^ ERROR mismatched types: expected `::core::option::t<uint>`
}

View file

@ -0,0 +1,17 @@
// Test that we use fully-qualified type names in error messages.
mod x {
enum foo { }
}
mod y {
enum foo { }
}
fn bar(x: x::foo) -> y::foo {
ret x;
//!^ ERROR mismatched types: expected `::y::foo` but found `::x::foo`
}
fn main() {
}