Skip to content

Add span to some import resolution errors #6476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,8 @@ pub impl Resolver {
self.resolve_single_import(module_,
containing_module,
target,
source);
source,
span);
}
GlobImport => {
let span = import_directive.span;
Expand Down Expand Up @@ -2121,7 +2122,8 @@ pub impl Resolver {
module_: @mut Module,
containing_module: @mut Module,
target: ident,
source: ident)
source: ident,
span: span)
-> ResolveResult<()> {
debug!("(resolving single import) resolving `%s` = `%s::%s` from \
`%s`",
Expand Down Expand Up @@ -2325,14 +2327,14 @@ pub impl Resolver {
}

if resolve_fail {
self.session.err(fmt!("unresolved import: there is no `%s` in `%s`",
*self.session.str_of(source),
self.module_to_str(containing_module)));
self.session.span_err(span, fmt!("unresolved import: there is no `%s` in `%s`",
*self.session.str_of(source),
self.module_to_str(containing_module)));
return Failed;
} else if priv_fail {
self.session.err(fmt!("unresolved import: found `%s` in `%s` but it is private",
*self.session.str_of(source),
self.module_to_str(containing_module)));
self.session.span_err(span, fmt!("unresolved import: found `%s` in `%s` but it is \
private", *self.session.str_of(source),
self.module_to_str(containing_module)));
return Failed;
}

Expand Down
10 changes: 8 additions & 2 deletions src/test/compile-fail/unresolved-import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use foo::bar; //~ ERROR unresolved import. maybe a missing
//~^ ERROR failed to resolve import
use foo::bar; //~ ERROR unresolved import. maybe a missing `extern mod foo`?
//~^ ERROR failed to resolve import `foo::bar`
use x = bar::baz; //~ ERROR unresolved import: there is no `baz` in `bar`
//~^ ERROR failed to resolve import `bar::baz`

mod bar {
struct bar;
}