Rollup merge of #90127 - JohnTitor:fix-90113, r=estebank

Do not mention a reexported item if it's private

Fixes #90113
The _actual_ regression was introduced in #73652, then #88838 made it worse. This fixes the issue by not counting such an import as a candidate.
This commit is contained in:
Matthias Krüger 2021-10-25 07:54:13 +02:00 committed by GitHub
commit c734a9e076
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 0 deletions

View file

@ -829,6 +829,15 @@ impl<'a> Resolver<'a> {
return;
}
// #90113: Do not count an inaccessible reexported item as a candidate.
if let NameBindingKind::Import { binding, .. } = name_binding.kind {
if this.is_accessible_from(binding.vis, parent_scope.module)
&& !this.is_accessible_from(name_binding.vis, parent_scope.module)
{
return;
}
}
// collect results based on the filter function
// avoid suggesting anything from the same module in which we are resolving
if ident.name == lookup_ident.name

View file

@ -0,0 +1,21 @@
mod list {
pub use self::List::Cons;
pub enum List<T> {
Cons(T, Box<List<T>>),
}
}
mod alias {
use crate::list::List;
pub type Foo = List<String>;
}
fn foo(l: crate::alias::Foo) {
match l {
Cons(..) => {} //~ ERROR: cannot find tuple struct or tuple variant `Cons` in this scope
}
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0531]: cannot find tuple struct or tuple variant `Cons` in this scope
--> $DIR/issue-90113.rs:17:9
|
LL | Cons(..) => {}
| ^^^^ not found in this scope
|
help: consider importing this tuple variant
|
LL | use list::List::Cons;
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0531`.