Skip to content

Commit 21fca7a

Browse files
committed
resolve: Do not suggest imports from the same module in which we are resolving
1 parent 52f1847 commit 21fca7a

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/librustc_resolve/diagnostics.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl<'a> Resolver<'a> {
629629
&mut self,
630630
lookup_ident: Ident,
631631
namespace: Namespace,
632-
_parent_scope: &ParentScope<'a>,
632+
parent_scope: &ParentScope<'a>,
633633
start_module: Module<'a>,
634634
crate_name: Ident,
635635
filter_fn: FilterFn,
@@ -656,7 +656,11 @@ impl<'a> Resolver<'a> {
656656
}
657657

658658
// collect results based on the filter function
659-
if ident.name == lookup_ident.name && ns == namespace {
659+
// avoid suggesting anything from the same module in which we are resolving
660+
if ident.name == lookup_ident.name
661+
&& ns == namespace
662+
&& !ptr::eq(in_module, parent_scope.module)
663+
{
660664
let res = name_binding.res();
661665
if filter_fn(res) {
662666
// create the path

src/test/ui/lexical-scopes.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ error[E0574]: expected struct, variant or union type, found type parameter `T`
33
|
44
LL | let t = T { i: 0 };
55
| ^ not a struct, variant or union type
6-
|
7-
help: consider importing this struct instead
8-
|
9-
LL | use T;
10-
|
116

127
error[E0599]: no function or associated item named `f` found for type parameter `Foo` in the current scope
138
--> $DIR/lexical-scopes.rs:10:10

src/test/ui/proc-macro/mixed-site-span.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ LL | pass_dollar_crate!();
2727
| ^^^^^^^^^^^^^^^^^^^^^ not found in `$crate`
2828
|
2929
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
30-
help: consider importing this struct
31-
|
32-
LL | use ItemUse;
33-
|
3430

3531
error: aborting due to 4 previous errors
3632

0 commit comments

Comments
 (0)