Skip to content

Commit 0d8e9cd

Browse files
committed
Reapply the macro_rules disambiguation changes from master
1 parent c29fb80 commit 0d8e9cd

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

src/Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,7 @@ name = "rustc_resolve"
23882388
version = "0.0.0"
23892389
dependencies = [
23902390
"arena 0.0.0",
2391+
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
23912392
"log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
23922393
"rustc 0.0.0",
23932394
"rustc_data_structures 0.0.0",

src/librustc_resolve/macros.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
642642
}
643643
WhereToResolve::MacroRules(legacy_scope) => match legacy_scope {
644644
LegacyScope::Binding(legacy_binding) if ident == legacy_binding.ident =>
645-
Ok((legacy_binding.binding, Flags::MACRO_RULES, Flags::MODULE)),
645+
Ok((legacy_binding.binding, Flags::MACRO_RULES, Flags::empty())),
646646
_ => Err(Determinacy::Determined),
647647
}
648648
WhereToResolve::Module(module) => {
@@ -804,7 +804,10 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
804804
(innermost_binding.is_glob_import() ||
805805
innermost_binding.may_appear_after(parent_scope.expansion, binding) ||
806806
innermost_flags.intersects(ambig_flags) ||
807-
flags.intersects(innermost_ambig_flags)) {
807+
flags.intersects(innermost_ambig_flags) ||
808+
(innermost_flags.contains(Flags::MACRO_RULES) &&
809+
flags.contains(Flags::MODULE) &&
810+
!self.disambiguate_legacy_vs_modern(innermost_binding, binding))) {
808811
self.ambiguity_errors.push(AmbiguityError {
809812
ident,
810813
b1: innermost_binding,

src/test/ui/imports/macros.stderr

+1-18
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,6 @@ LL | use two_macros::m;
3434
| ^^^^^^^^^^^^^
3535
= note: macro-expanded macro imports do not shadow
3636

37-
error[E0659]: `m` is ambiguous
38-
--> $DIR/macros.rs:48:5
39-
|
40-
LL | m!(); //~ ERROR ambiguous
41-
| ^ ambiguous name
42-
|
43-
note: `m` could refer to the name defined here
44-
--> $DIR/macros.rs:46:5
45-
|
46-
LL | macro_rules! m { () => {} }
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
48-
note: `m` could also refer to the name imported here
49-
--> $DIR/macros.rs:47:9
50-
|
51-
LL | use two_macros::m;
52-
| ^^^^^^^^^^^^^
53-
54-
error: aborting due to 3 previous errors
37+
error: aborting due to 2 previous errors
5538

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

0 commit comments

Comments
 (0)