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.
This commit is contained in:
parent
0604468fd5
commit
b085b51357
1 changed files with 8 additions and 1 deletions
|
@ -2996,7 +2996,14 @@ pub impl Resolver {
|
|||
let imports: &mut ~[@ImportDirective] = &mut *module_.imports;
|
||||
let import_count = imports.len();
|
||||
if index != import_count {
|
||||
self.session.span_err(imports[index].span, ~"unresolved import");
|
||||
let sn = self.session.codemap.span_to_snippet(imports[index].span);
|
||||
if str::contains(sn, "::") {
|
||||
self.session.span_err(imports[index].span, ~"unresolved import");
|
||||
} else {
|
||||
let err = fmt!("unresolved import (maybe you meant `%s::*`?)",
|
||||
sn.slice(0, sn.len() - 1));
|
||||
self.session.span_err(imports[index].span, err);
|
||||
}
|
||||
}
|
||||
|
||||
// Descend into children and anonymous children.
|
||||
|
|
Loading…
Add table
Reference in a new issue