Skip to content

Commit 9763472

Browse files
committed
smart_resolve_partial_mod_path_errors should not suggest parent
1 parent 6f53e61 commit 9763472

File tree

4 files changed

+4
-18
lines changed

4 files changed

+4
-18
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,10 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
350350
.filter(|candidate| {
351351
if let Some(def_id) = candidate.did &&
352352
let Some(module) = self.r.get_module(def_id) {
353-
self.r.resolutions(module).borrow().iter().any(|(key, _r)| {
354-
key.ident.name == following_seg.ident.name
355-
})
353+
Some(def_id) != self.parent_scope.module.opt_def_id() &&
354+
self.r.resolutions(module).borrow().iter().any(|(key, _r)| {
355+
key.ident.name == following_seg.ident.name
356+
})
356357
} else {
357358
false
358359
}

tests/ui/resolve/export-fully-qualified-2018.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo`
33
|
44
LL | pub fn bar() { foo::baz(); }
55
| ^^^ use of undeclared crate or module `foo`
6-
|
7-
help: consider importing this module
8-
|
9-
LL + use crate::foo;
10-
|
116

127
error: aborting due to previous error
138

tests/ui/resolve/export-fully-qualified.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo`
33
|
44
LL | pub fn bar() { foo::baz(); }
55
| ^^^ use of undeclared crate or module `foo`
6-
|
7-
help: consider importing this module
8-
|
9-
LL + use foo;
10-
|
116

127
error: aborting due to previous error
138

tests/ui/suggestions/crate-or-module-typo.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `bar`
3636
|
3737
LL | pub fn bar() { bar::baz(); }
3838
| ^^^ use of undeclared crate or module `bar`
39-
|
40-
help: consider importing this module
41-
|
42-
LL + use crate::bar;
43-
|
4439

4540
error: aborting due to 4 previous errors
4641

0 commit comments

Comments
 (0)