diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index d2c8320d8baf5..ba12dd821d63b 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -2593,7 +2593,12 @@ pub impl Resolver { let start_index; match module_prefix_result { Failed => { - self.session.span_err(span, ~"unresolved name"); + let mpath = self.idents_to_str(module_path); + let idx = str::rfind(self.idents_to_str(module_path), |c| { c == ':' }).unwrap(); + self.session.span_err(span, fmt!("unresolved import: could not find `%s` in `%s`", + str::substr(mpath, idx, mpath.len() - idx), + // idx - 1 to account for the extra semicolon + str::substr(mpath, 0, idx - 1))); return Failed; } Indeterminate => { diff --git a/src/test/compile-fail/unresolved-import.rs b/src/test/compile-fail/unresolved-import.rs index 1bd3efeadcbba..9c5ff311b0d03 100644 --- a/src/test/compile-fail/unresolved-import.rs +++ b/src/test/compile-fail/unresolved-import.rs @@ -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 +use foo::bar; //~ ERROR unresolved import. maybe a missing `extern mod foo`? //~^ ERROR failed to resolve import +use x = bar::baz; //~ ERROR unresolved import: could not find `baz` in `bar` + //~^ ERROR failed to resolve import + +mod bar { + struct bar; +}