Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not mention a reexported item if it's private #90127

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions src/test/ui/resolve/issue-90113.rs
Original file line number Diff line number Diff line change
@@ -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() {}
14 changes: 14 additions & 0 deletions src/test/ui/resolve/issue-90113.stderr
Original file line number Diff line number Diff line change
@@ -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`.