about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbohan <bohan-zhang@foxmail.com>2023-09-28 19:47:58 +0800
committerbohan <bohan-zhang@foxmail.com>2023-09-28 19:47:58 +0800
commitcfb819fa7e7dd16e756eca6d19ac78c7635436bd (patch)
treea0544b761c8c51a98852818608c606bb898e1655
parent46da927abb389f646d9b0c500e5c386aec61ecf9 (diff)
downloadrust-cfb819fa7e7dd16e756eca6d19ac78c7635436bd.tar.gz
rust-cfb819fa7e7dd16e756eca6d19ac78c7635436bd.zip
resolve: skip underscore character during candidate lookup
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs4
-rw-r--r--tests/ui/resolve/issue-116164.rs19
-rw-r--r--tests/ui/resolve/issue-116164.stderr14
3 files changed, 37 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index 907a6b1c46c..110286255c5 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -1169,6 +1169,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                     return;
                 }
 
+                if ident.name == kw::Underscore {
+                    return;
+                }
+
                 let child_accessible =
                     accessible && this.is_accessible_from(name_binding.vis, parent_scope.module);
 
diff --git a/tests/ui/resolve/issue-116164.rs b/tests/ui/resolve/issue-116164.rs
new file mode 100644
index 00000000000..d30c8f514b3
--- /dev/null
+++ b/tests/ui/resolve/issue-116164.rs
@@ -0,0 +1,19 @@
+#![allow(unused_imports)]
+
+mod inner {
+    pub enum Example {
+        ExOne,
+    }
+}
+
+mod reexports {
+    pub use crate::inner::Example as _;
+}
+
+use crate::reexports::*;
+//~^ SUGGESTION: use inner::Example::ExOne
+
+fn main() {
+    ExOne;
+    //~^ ERROR: cannot find value `ExOne` in this scope
+}
diff --git a/tests/ui/resolve/issue-116164.stderr b/tests/ui/resolve/issue-116164.stderr
new file mode 100644
index 00000000000..5820a189fd5
--- /dev/null
+++ b/tests/ui/resolve/issue-116164.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find value `ExOne` in this scope
+  --> $DIR/issue-116164.rs:17:5
+   |
+LL |     ExOne;
+   |     ^^^^^ not found in this scope
+   |
+help: consider importing this unit variant
+   |
+LL + use inner::Example::ExOne;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.