Skip to content

Commit fdaf022

Browse files
committed
resolve: Patch up an inconsistent resolution ICE revealed by the previous commit
1 parent 086b1f7 commit fdaf022

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
12911291
parent_scope: &ParentScope<'ra>,
12921292
) -> bool {
12931293
for single_import in &resolution.single_imports {
1294+
if let Some(binding) = resolution.non_glob_binding
1295+
&& let NameBindingKind::Import { import, .. } = binding.kind
1296+
&& import == *single_import
1297+
{
1298+
// Single import has already defined the name and we are aware of it,
1299+
// no need to block the globs.
1300+
continue;
1301+
}
12941302
if ignore_import == Some(*single_import) {
12951303
continue;
12961304
}

tests/ui/imports/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod m1 {
1313

1414
mod m2 {
1515
use two_macros::*;
16-
m! {
16+
m! { //~ ERROR `m` is ambiguous
1717
use crate::foo::m;
1818
}
1919
}

tests/ui/imports/macros.stderr

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
error[E0659]: `m` is ambiguous
2+
--> $DIR/macros.rs:16:5
3+
|
4+
LL | m! {
5+
| ^ ambiguous name
6+
|
7+
= note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution
8+
note: `m` could refer to the macro imported here
9+
--> $DIR/macros.rs:17:13
10+
|
11+
LL | use crate::foo::m;
12+
| ^^^^^^^^^^^^^
13+
= help: use `self::m` to refer to this macro unambiguously
14+
note: `m` could also refer to the macro imported here
15+
--> $DIR/macros.rs:15:9
16+
|
17+
LL | use two_macros::*;
18+
| ^^^^^^^^^^^^^
19+
= help: use `self::m` to refer to this macro unambiguously
20+
121
error[E0659]: `m` is ambiguous
222
--> $DIR/macros.rs:29:9
323
|
@@ -17,6 +37,6 @@ LL | use two_macros::m;
1737
| ^^^^^^^^^^^^^
1838
= help: use `self::m` to refer to this macro unambiguously
1939

20-
error: aborting due to 1 previous error
40+
error: aborting due to 2 previous errors
2141

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

0 commit comments

Comments
 (0)