Skip to content

Commit 62c7027

Browse files
committed
auto merge of #6485 : cmr/rust/local_rename_import_error, r=catamorphism
2 parents 4e4f90d + 6886315 commit 62c7027

File tree

8 files changed

+36
-13
lines changed

8 files changed

+36
-13
lines changed

src/librustc/middle/resolve.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,8 @@ pub impl Resolver {
20582058
self.resolve_single_import(module_,
20592059
containing_module,
20602060
target,
2061-
source);
2061+
source,
2062+
import_directive.span);
20622063
}
20632064
GlobImport => {
20642065
let span = import_directive.span;
@@ -2121,7 +2122,8 @@ pub impl Resolver {
21212122
module_: @mut Module,
21222123
containing_module: @mut Module,
21232124
target: ident,
2124-
source: ident)
2125+
source: ident,
2126+
span: span)
21252127
-> ResolveResult<()> {
21262128
debug!("(resolving single import) resolving `%s` = `%s::%s` from \
21272129
`%s`",
@@ -2325,14 +2327,14 @@ pub impl Resolver {
23252327
}
23262328

23272329
if resolve_fail {
2328-
self.session.err(fmt!("unresolved import: there is no `%s` in `%s`",
2329-
*self.session.str_of(source),
2330-
self.module_to_str(containing_module)));
2330+
self.session.span_err(span, fmt!("unresolved import: there is no `%s` in `%s`",
2331+
*self.session.str_of(source),
2332+
self.module_to_str(containing_module)));
23312333
return Failed;
23322334
} else if priv_fail {
2333-
self.session.err(fmt!("unresolved import: found `%s` in `%s` but it is private",
2334-
*self.session.str_of(source),
2335-
self.module_to_str(containing_module)));
2335+
self.session.span_err(span, fmt!("unresolved import: found `%s` in `%s` but it is \
2336+
private", *self.session.str_of(source),
2337+
self.module_to_str(containing_module)));
23362338
return Failed;
23372339
}
23382340

@@ -2593,7 +2595,18 @@ pub impl Resolver {
25932595
let start_index;
25942596
match module_prefix_result {
25952597
Failed => {
2596-
self.session.span_err(span, ~"unresolved name");
2598+
let mpath = self.idents_to_str(module_path);
2599+
match str::rfind(self.idents_to_str(module_path), |c| { c == ':' }) {
2600+
Some(idx) => {
2601+
self.session.span_err(span, fmt!("unresolved import: could not find `%s` \
2602+
in `%s`", str::substr(mpath, idx,
2603+
mpath.len() - idx),
2604+
// idx - 1 to account for the extra
2605+
// colon
2606+
str::substr(mpath, 0, idx - 1)));
2607+
},
2608+
None => (),
2609+
};
25972610
return Failed;
25982611
}
25992612
Indeterminate => {

src/test/compile-fail/issue-2123.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use x = m::f; //~ ERROR failed to resolve import
12+
//~^ unresolved import: there is no `f` in `m`
1213

1314
mod m {
1415
}

src/test/compile-fail/issue-2937.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use x = m::f; //~ ERROR failed to resolve import
12+
//~^ ERROR unresolved import: there is no `f` in `m`
1213

1314
mod m {
1415
}

src/test/compile-fail/issue-3993-2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use zoo::{duck, goose}; //~ ERROR failed to resolve import
12+
//~^ ERROR unresolved import: found `goose` in `zoo` but it is private
1213

1314
mod zoo {
1415
pub enum bird {

src/test/compile-fail/issue-3993-3.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use zoo::fly; //~ ERROR failed to resolve import
12+
//~^ ERROR unresolved import: found `fly` in `zoo` but it is private
1213

1314
mod zoo {
1415
priv type fly = ();

src/test/compile-fail/issue-3993.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use zoo::fly; //~ ERROR failed to resolve import
12+
//~^ ERROR unresolved import: found `fly` in `zoo` but it is private
1213

1314
mod zoo {
1415
priv fn fly() {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use super::f; //~ ERROR unresolved name
2-
//~^ ERROR failed to resolve import
1+
use super::f; //~ ERROR failed to resolve import
32

43
fn main() {
54
}

src/test/compile-fail/unresolved-import.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use foo::bar; //~ ERROR unresolved import. maybe a missing
12-
//~^ ERROR failed to resolve import
11+
use foo::bar; //~ ERROR unresolved import. maybe a missing `extern mod foo`?
12+
//~^ ERROR failed to resolve import `foo::bar`
13+
use x = bar::baz; //~ ERROR unresolved import: there is no `baz` in `bar`
14+
//~^ ERROR failed to resolve import `bar::baz`
15+
16+
mod bar {
17+
struct bar;
18+
}

0 commit comments

Comments
 (0)