Skip to content

Commit ef2ebf4

Browse files
committed
resolve: Update glob bindings in case of ambiguities (non-recursively)
1 parent 5633798 commit ef2ebf4

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

compiler/rustc_resolve/src/imports.rs

+2
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
324324
} else if !old_binding.vis.is_at_least(binding.vis, this.tcx) {
325325
// We are glob-importing the same item but with greater visibility.
326326
resolution.binding = Some(binding);
327+
} else if binding.is_ambiguity() {
328+
resolution.binding = Some(binding);
327329
}
328330
}
329331
(old_glob @ true, false) | (old_glob @ false, true) => {

tests/ui/imports/duplicate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mod g {
3333
fn main() {
3434
e::foo();
3535
f::foo(); //~ ERROR `foo` is ambiguous
36-
g::foo();
36+
g::foo(); //~ ERROR `foo` is ambiguous
3737
}
3838

3939
mod ambiguous_module_errors {

tests/ui/imports/duplicate.stderr

+21-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ LL | pub use b::*;
4848
| ^^^^
4949
= help: consider adding an explicit import of `foo` to disambiguate
5050

51+
error[E0659]: `foo` is ambiguous
52+
--> $DIR/duplicate.rs:36:8
53+
|
54+
LL | g::foo();
55+
| ^^^ ambiguous name
56+
|
57+
= note: ambiguous because of multiple glob imports of a name in the same module
58+
note: `foo` could refer to the function imported here
59+
--> $DIR/duplicate.rs:24:13
60+
|
61+
LL | pub use a::*;
62+
| ^^^^
63+
= help: consider adding an explicit import of `foo` to disambiguate
64+
note: `foo` could also refer to the function imported here
65+
--> $DIR/duplicate.rs:25:13
66+
|
67+
LL | pub use b::*;
68+
| ^^^^
69+
= help: consider adding an explicit import of `foo` to disambiguate
70+
5171
error[E0659]: `foo` is ambiguous
5272
--> $DIR/duplicate.rs:49:9
5373
|
@@ -68,7 +88,7 @@ LL | use self::m2::*;
6888
| ^^^^^^^^^^^
6989
= help: consider adding an explicit import of `foo` to disambiguate
7090

71-
error: aborting due to 4 previous errors
91+
error: aborting due to 5 previous errors
7292

7393
Some errors have detailed explanations: E0252, E0659.
7494
For more information about an error, try `rustc --explain E0252`.

0 commit comments

Comments
 (0)