Skip to content

Commit 16b7b39

Browse files
committed
Auto merge of rust-lang#116228 - bvanjoi:fix-116164, r=cjgillot
resolve: skip underscore character during candidate lookup Fixes rust-lang#116164 In use statement, an underscore is merely a placeholder symbol and does not bind to any name. Therefore, it can be safely ignored.
2 parents 6c29b45 + cfb819f commit 16b7b39

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11691169
return;
11701170
}
11711171

1172+
if ident.name == kw::Underscore {
1173+
return;
1174+
}
1175+
11721176
let child_accessible =
11731177
accessible && this.is_accessible_from(name_binding.vis, parent_scope.module);
11741178

tests/ui/resolve/issue-116164.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
mod inner {
4+
pub enum Example {
5+
ExOne,
6+
}
7+
}
8+
9+
mod reexports {
10+
pub use crate::inner::Example as _;
11+
}
12+
13+
use crate::reexports::*;
14+
//~^ SUGGESTION: use inner::Example::ExOne
15+
16+
fn main() {
17+
ExOne;
18+
//~^ ERROR: cannot find value `ExOne` in this scope
19+
}

tests/ui/resolve/issue-116164.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0425]: cannot find value `ExOne` in this scope
2+
--> $DIR/issue-116164.rs:17:5
3+
|
4+
LL | ExOne;
5+
| ^^^^^ not found in this scope
6+
|
7+
help: consider importing this unit variant
8+
|
9+
LL + use inner::Example::ExOne;
10+
|
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)