Report privacy errors at most once per import (fixes )

This commit is contained in:
Jeffrey Seyfried 2016-02-11 06:17:01 +00:00
parent 97842f54c9
commit b7889ef235

@ -403,6 +403,23 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
module_.increment_outstanding_references_for(target, TypeNS);
}
match (&value_result, &type_result) {
(&Indeterminate, _) | (_, &Indeterminate) => return Indeterminate,
(&Failed(_), &Failed(_)) => {
let children = target_module.children.borrow();
let names = children.keys().map(|&(ref name, _)| name);
let lev_suggestion = match find_best_match_for_name(names, &source.as_str(), None) {
Some(name) => format!(". Did you mean to use `{}`?", name),
None => "".to_owned(),
};
let msg = format!("There is no `{}` in `{}`{}",
source,
module_to_string(target_module), lev_suggestion);
return Failed(Some((directive.span, msg)));
}
_ => (),
}
match (&value_result, &type_result) {
(&Success(name_binding), _) if !name_binding.is_import() &&
directive.is_public &&
@ -437,23 +454,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
_ => {}
}
match (&value_result, &type_result) {
(&Indeterminate, _) | (_, &Indeterminate) => return Indeterminate,
(&Failed(_), &Failed(_)) => {
let children = target_module.children.borrow();
let names = children.keys().map(|&(ref name, _)| name);
let lev_suggestion = match find_best_match_for_name(names, &source.as_str(), None) {
Some(name) => format!(". Did you mean to use `{}`?", name),
None => "".to_owned(),
};
let msg = format!("There is no `{}` in `{}`{}",
source,
module_to_string(target_module), lev_suggestion);
return Failed(Some((directive.span, msg)));
}
_ => (),
}
for &(ns, result) in &[(ValueNS, &value_result), (TypeNS, &type_result)] {
if let Success(binding) = *result {
if !binding.defined_with(DefModifiers::IMPORTABLE) {