Skip to content

Commit c734a9e

Browse files
authored
Rollup merge of rust-lang#90127 - JohnTitor:fix-90113, r=estebank
Do not mention a reexported item if it's private Fixes rust-lang#90113 The _actual_ regression was introduced in rust-lang#73652, then rust-lang#88838 made it worse. This fixes the issue by not counting such an import as a candidate.
2 parents b25172b + 3b2dd70 commit c734a9e

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+9
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,15 @@ impl<'a> Resolver<'a> {
829829
return;
830830
}
831831

832+
// #90113: Do not count an inaccessible reexported item as a candidate.
833+
if let NameBindingKind::Import { binding, .. } = name_binding.kind {
834+
if this.is_accessible_from(binding.vis, parent_scope.module)
835+
&& !this.is_accessible_from(name_binding.vis, parent_scope.module)
836+
{
837+
return;
838+
}
839+
}
840+
832841
// collect results based on the filter function
833842
// avoid suggesting anything from the same module in which we are resolving
834843
if ident.name == lookup_ident.name

src/test/ui/resolve/issue-90113.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
mod list {
2+
pub use self::List::Cons;
3+
4+
pub enum List<T> {
5+
Cons(T, Box<List<T>>),
6+
}
7+
}
8+
9+
mod alias {
10+
use crate::list::List;
11+
12+
pub type Foo = List<String>;
13+
}
14+
15+
fn foo(l: crate::alias::Foo) {
16+
match l {
17+
Cons(..) => {} //~ ERROR: cannot find tuple struct or tuple variant `Cons` in this scope
18+
}
19+
}
20+
21+
fn main() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0531]: cannot find tuple struct or tuple variant `Cons` in this scope
2+
--> $DIR/issue-90113.rs:17:9
3+
|
4+
LL | Cons(..) => {}
5+
| ^^^^ not found in this scope
6+
|
7+
help: consider importing this tuple variant
8+
|
9+
LL | use list::List::Cons;
10+
|
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0531`.

0 commit comments

Comments
 (0)