Skip to content

Commit

Permalink
resolve: Do not suggest imports from the same module in which we are …
Browse files Browse the repository at this point in the history
…resolving
  • Loading branch information
petrochenkov committed May 30, 2020
1 parent 52f1847 commit 21fca7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/lexical-scopes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/test/ui/proc-macro/mixed-site-span.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 21fca7a

Please sign in to comment.