about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2021-10-21 23:36:51 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2021-10-21 23:36:51 +0100
commit1536d7220b847d8a843a3357cc62ef5704f2c690 (patch)
tree6aa49a0b1775c1847c9eaad088414e1ac667b0dc
parent4ecb49eba3770e4826346486252b9e7a1b5fcb33 (diff)
downloadrust-1536d7220b847d8a843a3357cc62ef5704f2c690.tar.gz
rust-1536d7220b847d8a843a3357cc62ef5704f2c690.zip
Don't suggest importing items with hygienic names
This will potentially hide a few correct suggestions, but importing
these items from another module is not generally possible.
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs2
-rw-r--r--compiler/rustc_span/src/hygiene.rs2
2 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index 63000a9d13d..aefb3f2cb9c 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -831,9 +831,11 @@ impl<'a> Resolver<'a> {
 
                 // collect results based on the filter function
                 // avoid suggesting anything from the same module in which we are resolving
+                // avoid suggesting anything with a hygienic name
                 if ident.name == lookup_ident.name
                     && ns == namespace
                     && !ptr::eq(in_module, parent_scope.module)
+                    && !ident.span.normalize_to_macros_2_0().from_expansion()
                 {
                     let res = name_binding.res();
                     if filter_fn(res) {
diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs
index aa15febe885..724d1904dc3 100644
--- a/compiler/rustc_span/src/hygiene.rs
+++ b/compiler/rustc_span/src/hygiene.rs
@@ -709,7 +709,7 @@ impl SyntaxContext {
     ///         pub fn f() {} // `f`'s `SyntaxContext` has a single `ExpnId` from `m`.
     ///         pub fn $i() {} // `$i`'s `SyntaxContext` is empty.
     ///     }
-    ///     n(f);
+    ///     n!(f);
     ///     macro n($j:ident) {
     ///         use foo::*;
     ///         f(); // `f`'s `SyntaxContext` has a mark from `m` and a mark from `n`