correct fully qualified type names to include the crate; add tests
fixes #1745
This commit is contained in:
parent
d972226567
commit
2ec3a0b608
4 changed files with 27 additions and 2 deletions
|
|
@ -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] {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
7
src/test/compile-fail/fully-qualified-type-name1.rs
Normal file
7
src/test/compile-fail/fully-qualified-type-name1.rs
Normal 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>`
|
||||
}
|
||||
17
src/test/compile-fail/fully-qualified-type-name2.rs
Normal file
17
src/test/compile-fail/fully-qualified-type-name2.rs
Normal 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() {
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue