Skip to content

Commit cef2b26

Browse files
committed
don't stop after successful non-glob resolution
1 parent 2818f1d commit cef2b26

File tree

5 files changed

+67
-8
lines changed

5 files changed

+67
-8
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
549549
);
550550
}
551551

552-
// Don't visit Scope::GlobModule after successful resolution in
553-
// Scope::NonGlobModule with ScopeSet::Module.
554-
if matches!(scope_set, ScopeSet::Module(..)) {
555-
return Some(Ok(binding));
556-
}
557-
558552
let misc_flags = this.create_module_misc_flags(module);
559553
Ok((binding, Flags::NON_GLOB_MODULE | misc_flags))
560554
}

tests/ui/imports/imports.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ run-pass
21
#![allow(unused)]
32

43
// Like other items, private imports can be imported and used non-lexically in paths.
@@ -22,13 +21,15 @@ fn g() {
2221
use crate::bar::*;
2322
fn f() -> bool { true }
2423
let _: bool = f();
24+
//~^ ERROR `f` is ambiguous
2525
}
2626

2727
fn h() {
2828
use crate::foo::*;
2929
use crate::bar::*;
3030
use crate::f;
3131
let _: bool = f();
32+
//~^ ERROR `f` is ambiguous
3233
}
3334

3435
// Here, there appears to be shadowing but isn't because of namespaces.

tests/ui/imports/imports.stderr

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0659]: `f` is ambiguous
2+
--> $DIR/imports.rs:23:19
3+
|
4+
LL | let _: bool = f();
5+
| ^ ambiguous name
6+
|
7+
= note: ambiguous because of multiple glob imports of a name in the same module
8+
note: `f` could refer to the function imported here
9+
--> $DIR/imports.rs:20:9
10+
|
11+
LL | use crate::foo::*;
12+
| ^^^^^^^^^^^^^
13+
= help: consider adding an explicit import of `f` to disambiguate
14+
note: `f` could also refer to the function imported here
15+
--> $DIR/imports.rs:21:9
16+
|
17+
LL | use crate::bar::*;
18+
| ^^^^^^^^^^^^^
19+
= help: consider adding an explicit import of `f` to disambiguate
20+
21+
error[E0659]: `f` is ambiguous
22+
--> $DIR/imports.rs:31:19
23+
|
24+
LL | let _: bool = f();
25+
| ^ ambiguous name
26+
|
27+
= note: ambiguous because of multiple glob imports of a name in the same module
28+
note: `f` could refer to the function imported here
29+
--> $DIR/imports.rs:28:9
30+
|
31+
LL | use crate::foo::*;
32+
| ^^^^^^^^^^^^^
33+
= help: consider adding an explicit import of `f` to disambiguate
34+
note: `f` could also refer to the function imported here
35+
--> $DIR/imports.rs:29:9
36+
|
37+
LL | use crate::bar::*;
38+
| ^^^^^^^^^^^^^
39+
= help: consider adding an explicit import of `f` to disambiguate
40+
41+
error: aborting due to 2 previous errors
42+
43+
For more information about this error, try `rustc --explain E0659`.

tests/ui/resolve/issue-109153.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ mod foo {
1010

1111
use bar::bar; //~ ERROR `bar` is ambiguous
1212
use bar::*;
13+
//~^ ERROR `bar` is ambiguous
1314

1415
fn main() { }

tests/ui/resolve/issue-109153.stderr

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ LL | use bar::*;
1818
| ^^^^^^
1919
= help: consider adding an explicit import of `bar` to disambiguate
2020

21-
error: aborting due to 1 previous error
21+
error[E0659]: `bar` is ambiguous
22+
--> $DIR/issue-109153.rs:12:5
23+
|
24+
LL | use bar::*;
25+
| ^^^ ambiguous name
26+
|
27+
= note: ambiguous because of multiple glob imports of a name in the same module
28+
note: `bar` could refer to the module imported here
29+
--> $DIR/issue-109153.rs:1:5
30+
|
31+
LL | use foo::*;
32+
| ^^^^^^
33+
= help: consider adding an explicit import of `bar` to disambiguate
34+
note: `bar` could also refer to the module imported here
35+
--> $DIR/issue-109153.rs:12:5
36+
|
37+
LL | use bar::*;
38+
| ^^^^^^
39+
= help: consider adding an explicit import of `bar` to disambiguate
40+
41+
error: aborting due to 2 previous errors
2242

2343
For more information about this error, try `rustc --explain E0659`.

0 commit comments

Comments
 (0)