diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 2f7de8c4aa4..2aa8925fb54 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -537,8 +537,14 @@ fn resolve_import(&mut self, directive: &'b ImportDirective<'b>) -> ResolveResul match (&value_result, &type_result) { (&Indeterminate, _) | (_, &Indeterminate) => return Indeterminate, (&Failed(_), &Failed(_)) => { - let children = target_module.resolutions.borrow(); - let names = children.keys().map(|&(ref name, _)| name); + let resolutions = target_module.resolutions.borrow(); + let names = resolutions.iter().filter_map(|(&(ref name, _), resolution)| { + match *resolution.borrow() { + NameResolution { binding: Some(_), .. } => Some(name), + NameResolution { single_imports: SingleImports::None, .. } => None, + _ => Some(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(),