]> git.lizzy.rs Git - rust.git/commitdiff
Reapply the macro_rules disambiguation changes from master
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Thu, 4 Oct 2018 10:41:58 +0000 (14:41 +0400)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Fri, 5 Oct 2018 07:46:12 +0000 (11:46 +0400)
src/Cargo.lock
src/librustc_resolve/macros.rs
src/test/ui/imports/macros.stderr

index 5d9f84650470d413ee9c568db5af14765043d1d5..6a9488226b1bdc61a35479268dcce8fee9cfaf16 100644 (file)
@@ -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",
index 54eb27d4f39f52fc13030b14ca66900808975471..c31b558dedea03452bebb1a0010ec62f01465332 100644 (file)
@@ -642,7 +642,7 @@ struct Flags: u8 {
                 }
                 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) => {
@@ -804,7 +804,10 @@ macro_rules! continue_search { () => {
                            (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,
index 965b23e1a5c9ffe0ec7f2b665b04c8276bb4a320..209d449dfd84016acb13a3417fe0293c86ccf6b6 100644 (file)
@@ -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`.