Skip to content

Commit b085b51

Browse files
committed
Offer a hint on some unresolved imports
I didn't know how to use "use" initially, and an error message like this would have solved quite a bit of frustration. I think this properly handles cases where it's not appropriate but I'm not sure.
1 parent 0604468 commit b085b51

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustc/middle/resolve.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2996,7 +2996,14 @@ pub impl Resolver {
29962996
let imports: &mut ~[@ImportDirective] = &mut *module_.imports;
29972997
let import_count = imports.len();
29982998
if index != import_count {
2999-
self.session.span_err(imports[index].span, ~"unresolved import");
2999+
let sn = self.session.codemap.span_to_snippet(imports[index].span);
3000+
if str::contains(sn, "::") {
3001+
self.session.span_err(imports[index].span, ~"unresolved import");
3002+
} else {
3003+
let err = fmt!("unresolved import (maybe you meant `%s::*`?)",
3004+
sn.slice(0, sn.len() - 1));
3005+
self.session.span_err(imports[index].span, err);
3006+
}
30003007
}
30013008

30023009
// Descend into children and anonymous children.

0 commit comments

Comments
 (0)