Change:
For this code: You get the following error message: The suggestion may be excused to be not 100% perfect, but here it suggests to add an use statement despite that same item being imported already. What I want is this exactly: that it removes stuff from the suggestion list that is already being imported. Note that changing the glob import to a non glob one doesn't change anything.
cc
Why is that even an error?
tuple structs have private fields by default, you can't construct instances of B outside of the foo module.
oh ^^ maybe we should simply modify this error message then to say that the "function" is private?
It already says "constructor is not visible here due to private fields". That's okay, but maybe you might have meant another B from another module or something. However, the candidate offered is not any better as its the same one you are attempting to use.
Reopening to track "removal of suggestion" work for pub tuple structs with private fields.

Discussion:
// Try to lookup name in more relaxed fashion for better error reporting. let ident = path.last().unwrap().ident; <del> let candidates = self.lookup_import_candidates(ident, ns, is_expected); </del> <ins> let candidates = self.lookup_import_candidates(ident, ns, is_expected) .drain(..) .filter(|ImportSuggestion { did, .. }| { match (did, def.and_then(|def| def.opt_def_id())) { (Some(suggestion_did), Some(actual_did)) => *suggestion_did != actual_did, _ => true, } }) .collect::<Vec<_>>(); </ins> if candidates.is_empty() && is_expected(Def::Enum(DefId::local(CRATE_DEF_INDEX))) { let enum_candidates = self.lookup_import_candidates(ident, ns, is_enum_variant);

use rustc::hir::def::Namespace::*; use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId}; use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap}; <del> use rustc::ty; </del> <ins> use rustc::ty::{self, DefIdTree}; </ins> use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap}; use rustc::{bug, span_bug};

/// A free importable items suggested in case of resolution failure. struct ImportSuggestion { <ins> did: Option<DefId>, </ins> path: Path, }

// collect results based on the filter function if ident.name == lookup_ident.name && ns == namespace { <del> if filter_fn(name_binding.def()) { </del> <ins> let def = name_binding.def(); if filter_fn(def) { </ins> // create the path let mut segms = path_segments.clone(); if lookup_ident.span.rust_2018() {

// declared as public (due to pruning, we don't explore // outside crate private modules => no need to check this) if !in_module_is_extern || name_binding.vis == ty::Visibility::Public { <del> candidates.push(ImportSuggestion { path }); </del> <ins> let did = match def { Def::StructCtor(did, _) | Def::VariantCtor(did, _) => self.parent(did), _ => def.opt_def_id(), }; candidates.push(ImportSuggestion { did, path }); </ins> } } }

span: name_binding.span, segments: path_segments, }; <del> result = Some((module, ImportSuggestion { path })); </del> <ins> let did = module.def().and_then(|def| def.opt_def_id()); result = Some((module, ImportSuggestion { did, path })); </ins> } else { // add the module to the lookup if seen_modules.insert(module.def_id().unwrap()) {

<ins> mod foo { pub struct B(()); } mod bar { use foo::B; fn foo() { B(()); //~ ERROR expected function, found struct `B` [E0423] } } mod baz { fn foo() { B(()); //~ ERROR cannot find function `B` in this scope [E0425] } } fn main() {} </ins>

<ins> error[E0423]: expected function, found struct `B` --> $DIR/issue-42944.rs:9:9 | LL |         B(()); //~ ERROR expected function, found struct `B` [E0423] |         ^ constructor is not visible here due to private fields error[E0425]: cannot find function `B` in this scope --> $DIR/issue-42944.rs:15:9 | LL |         B(()); //~ ERROR cannot find function `B` in this scope [E0425] |         ^ not found in this scope help: possible candidate is found in another module, you can import it into scope | LL |     use foo::B; | error: aborting due to 2 previous errors Some errors occurred: E0423, E0425. For more information about an error, try `rustc --explain E0423`. </ins>

--> $DIR/privacy-struct-ctor.rs:20:9 | LL |         Z; <del> |         ^ constructor is not visible here due to private fields help: a tuple struct with a similar name exists | LL |         S; </del> |         ^ <del> help: possible better candidate is found in another module, you can import it into scope | LL |     use m::n::Z; | </del> <ins> |         | |         constructor is not visible here due to private fields |         help: a tuple struct with a similar name exists: `S` </ins> error[E0423]: expected value, found struct `S` --> $DIR/privacy-struct-ctor.rs:33:5 | LL |     S; |     ^ constructor is not visible here due to private fields <del> help: possible better candidate is found in another module, you can import it into scope | LL | use m::S; | </del> error[E0423]: expected value, found struct `S2` --> $DIR/privacy-struct-ctor.rs:38:5