Skip to content

Commit

Permalink
Reapply the macro_rules disambiguation changes from master
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Oct 5, 2018
1 parent c29fb80 commit 0d8e9cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/Cargo.lock
Expand Up @@ -2388,6 +2388,7 @@ name = "rustc_resolve"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_resolve/macros.rs
Expand Up @@ -642,7 +642,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
}
WhereToResolve::MacroRules(legacy_scope) => match legacy_scope {
LegacyScope::Binding(legacy_binding) if ident == legacy_binding.ident =>
Ok((legacy_binding.binding, Flags::MACRO_RULES, Flags::MODULE)),
Ok((legacy_binding.binding, Flags::MACRO_RULES, Flags::empty())),
_ => Err(Determinacy::Determined),
}
WhereToResolve::Module(module) => {
Expand Down Expand Up @@ -804,7 +804,10 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
(innermost_binding.is_glob_import() ||
innermost_binding.may_appear_after(parent_scope.expansion, binding) ||
innermost_flags.intersects(ambig_flags) ||
flags.intersects(innermost_ambig_flags)) {
flags.intersects(innermost_ambig_flags) ||
(innermost_flags.contains(Flags::MACRO_RULES) &&
flags.contains(Flags::MODULE) &&
!self.disambiguate_legacy_vs_modern(innermost_binding, binding))) {
self.ambiguity_errors.push(AmbiguityError {
ident,
b1: innermost_binding,
Expand Down
19 changes: 1 addition & 18 deletions src/test/ui/imports/macros.stderr
Expand Up @@ -34,23 +34,6 @@ LL | use two_macros::m;
| ^^^^^^^^^^^^^
= note: macro-expanded macro imports do not shadow

error[E0659]: `m` is ambiguous
--> $DIR/macros.rs:48:5
|
LL | m!(); //~ ERROR ambiguous
| ^ ambiguous name
|
note: `m` could refer to the name defined here
--> $DIR/macros.rs:46:5
|
LL | macro_rules! m { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `m` could also refer to the name imported here
--> $DIR/macros.rs:47:9
|
LL | use two_macros::m;
| ^^^^^^^^^^^^^

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

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

0 comments on commit 0d8e9cd

Please sign in to comment.