Skip to content

Commit 62cbea1

Browse files
committed
Add span to some import resolution errors
1 parent 52f8b22 commit 62cbea1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/librustc/middle/resolve.rs

Lines changed: 10 additions & 8 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+
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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
use foo::bar; //~ ERROR unresolved import. maybe a missing `extern mod foo`?
12-
//~^ ERROR failed to resolve import
13-
use x = bar::baz; //~ ERROR unresolved import: could not find `baz` in `bar`
14-
//~^ ERROR failed to resolve import
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`
1515

1616
mod bar {
1717
struct bar;

0 commit comments

Comments
 (0)