about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-05-30 20:11:14 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-05-30 20:42:20 +0300
commit21fca7aae7213b651399e95d3d83f85f00734036 (patch)
tree9ced362f74724aeb6fd1d37bcb3ab6e55bcb9b8d
parent52f1847bca00890aaf424634f9c0f52960866ee0 (diff)
downloadrust-21fca7aae7213b651399e95d3d83f85f00734036.tar.gz
rust-21fca7aae7213b651399e95d3d83f85f00734036.zip
resolve: Do not suggest imports from the same module in which we are resolving
-rw-r--r--src/librustc_resolve/diagnostics.rs8
-rw-r--r--src/test/ui/lexical-scopes.stderr5
-rw-r--r--src/test/ui/proc-macro/mixed-site-span.stderr4
3 files changed, 6 insertions, 11 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 176204affde..a952e08c2d6 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -629,7 +629,7 @@ impl<'a> Resolver<'a> {
         &mut self,
         lookup_ident: Ident,
         namespace: Namespace,
-        _parent_scope: &ParentScope<'a>,
+        parent_scope: &ParentScope<'a>,
         start_module: Module<'a>,
         crate_name: Ident,
         filter_fn: FilterFn,
@@ -656,7 +656,11 @@ impl<'a> Resolver<'a> {
                 }
 
                 // collect results based on the filter function
-                if ident.name == lookup_ident.name && ns == namespace {
+                // avoid suggesting anything from the same module in which we are resolving
+                if ident.name == lookup_ident.name
+                    && ns == namespace
+                    && !ptr::eq(in_module, parent_scope.module)
+                {
                     let res = name_binding.res();
                     if filter_fn(res) {
                         // create the path
diff --git a/src/test/ui/lexical-scopes.stderr b/src/test/ui/lexical-scopes.stderr
index dce70545170..1e6a35ed479 100644
--- a/src/test/ui/lexical-scopes.stderr
+++ b/src/test/ui/lexical-scopes.stderr
@@ -3,11 +3,6 @@ error[E0574]: expected struct, variant or union type, found type parameter `T`
    |
 LL |     let t = T { i: 0 };
    |             ^ not a struct, variant or union type
-   |
-help: consider importing this struct instead
-   |
-LL | use T;
-   |
 
 error[E0599]: no function or associated item named `f` found for type parameter `Foo` in the current scope
   --> $DIR/lexical-scopes.rs:10:10
diff --git a/src/test/ui/proc-macro/mixed-site-span.stderr b/src/test/ui/proc-macro/mixed-site-span.stderr
index 2b851a76f6a..6244ffc47a6 100644
--- a/src/test/ui/proc-macro/mixed-site-span.stderr
+++ b/src/test/ui/proc-macro/mixed-site-span.stderr
@@ -27,10 +27,6 @@ LL | pass_dollar_crate!();
    | ^^^^^^^^^^^^^^^^^^^^^ not found in `$crate`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-help: consider importing this struct
-   |
-LL | use ItemUse;
-   |
 
 error: aborting due to 4 previous errors