Skip to content

Commit de6eadb

Browse files
committed
resolve: Relax one restriction on macro namespace
1 parent cd48ce1 commit de6eadb

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/librustc_resolve/resolve_imports.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
323323
// shadowing is enabled, see `macro_expanded_macro_export_errors`).
324324
let unexpanded_macros = !module.unresolved_invocations.borrow().is_empty();
325325
if let Some(binding) = resolution.binding {
326-
if !unexpanded_macros || ns == MacroNS || restricted_shadowing {
326+
if !unexpanded_macros || restricted_shadowing {
327327
return check_usable(self, binding);
328328
} else {
329329
return Err((Undetermined, Weak::No));
@@ -492,14 +492,8 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
492492
} else {
493493
(binding, old_binding)
494494
};
495-
if glob_binding.def() != nonglob_binding.def() &&
496-
ns == MacroNS && nonglob_binding.expansion != Mark::root() {
497-
resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsExpanded,
498-
nonglob_binding, glob_binding));
499-
} else {
500-
resolution.binding = Some(nonglob_binding);
501-
resolution.shadowed_glob = Some(glob_binding);
502-
}
495+
resolution.binding = Some(nonglob_binding);
496+
resolution.shadowed_glob = Some(glob_binding);
503497
}
504498
(false, false) => {
505499
if let (&NameBindingKind::Def(_, true), &NameBindingKind::Def(_, true)) =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// compile-pass
2+
3+
#![feature(decl_macro)]
4+
5+
macro_rules! gen_mac { () => {
6+
pub macro mac() { () }
7+
}}
8+
9+
mod m1 {
10+
pub macro mac() { 0 }
11+
}
12+
13+
mod m2 {
14+
use m1::*;
15+
16+
gen_mac!();
17+
}
18+
19+
fn main() {
20+
m2::mac!() // OK
21+
}

0 commit comments

Comments
 (0)