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:
Corey Richardson 2013-04-26 04:59:28 -04:00
parent 0604468fd5
commit b085b51357

View file

@ -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.