-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolve: Disambiguate a subset of conflicts "macro_rules" vs "macro name in module" #54605
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
cc @rust-lang/lang |
This all looks and sounds good to me, thanks @petrochenkov! r=me with some tests |
@bors r=alexcrichton |
📌 Commit d8887bf61a626f39e26302902128b6915517c99a has been approved by |
Argh, asserts are firing. Will fix tomorrow. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
…ons in some cases
@bors r=alexcrichton |
📌 Commit 078fc52 has been approved by |
resolve: Disambiguate a subset of conflicts "macro_rules" vs "macro name in module" Currently if macro name may refer to both a `macro_rules` macro definition and a macro defined/imported into module we conservatively report an ambiguity error. Unfortunately, these errors became a source of regressions when macro modularization was enabled - see issue #54472. This PR disambiguates such conflicts in favor of `macro_rules` if both the `macro_rules` item and in-module macro name are defined in the same normal (named) module and `macro_rules` is closer in scope to the point of use (see the tests for examples). This is a subset of more general approach described in #54472 (comment). The subset is enough to fix all the regressions from #54472, but it can be extended to apply to all "macro_rules" vs "macro name in module" conflicts in the future. To give an analogy, this is equivalent to scoping rules for `let` variables and items defined in blocks (`macro_rules` behaves like "`let` at module level" in general). ```rust { // beginning of the block use xxx::m; // (1) // Starting from the beginning of the block and until here m!() refers to (1) macro_rules! m { ... } // (2) // Starting from here and until the end of the block m!() refers to (2) } // end of the block ``` More complex examples with `use` and `macro_rules` from different modules still report ambiguity errors, even if equivalent examples with `let` are legal. Fixes #54472 (stable-to-beta regression)
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The relevant link error message:
|
Spurious? I don't this emscripten-specific linking error has anything to do with my PR. |
resolve: Disambiguate a subset of conflicts "macro_rules" vs "macro name in module" Currently if macro name may refer to both a `macro_rules` macro definition and a macro defined/imported into module we conservatively report an ambiguity error. Unfortunately, these errors became a source of regressions when macro modularization was enabled - see issue #54472. This PR disambiguates such conflicts in favor of `macro_rules` if both the `macro_rules` item and in-module macro name are defined in the same normal (named) module and `macro_rules` is closer in scope to the point of use (see the tests for examples). This is a subset of more general approach described in #54472 (comment). The subset is enough to fix all the regressions from #54472, but it can be extended to apply to all "macro_rules" vs "macro name in module" conflicts in the future. To give an analogy, this is equivalent to scoping rules for `let` variables and items defined in blocks (`macro_rules` behaves like "`let` at module level" in general). ```rust { // beginning of the block use xxx::m; // (1) // Starting from the beginning of the block and until here m!() refers to (1) macro_rules! m { ... } // (2) // Starting from here and until the end of the block m!() refers to (2) } // end of the block ``` More complex examples with `use` and `macro_rules` from different modules still report ambiguity errors, even if equivalent examples with `let` are legal. Fixes #54472 (stable-to-beta regression)
☀️ Test successful - status-appveyor, status-travis |
discussed at T-compiler meeting. accepting for beta backport. |
[beta] Rollup backports Merged and approved: * #54605: resolve: Disambiguate a subset of conflicts "macro_rules" vs "macro name in module" * #54557: incr.comp.: Don't automatically enable -Zshare-generics for incr. comp. builds. * #54759: do not normalize non-scalar constants to a ConstValue::ScalarPair Closes #54759 r? @ghost
Currently if macro name may refer to both a
macro_rules
macro definition and a macro defined/imported into module we conservatively report an ambiguity error.Unfortunately, these errors became a source of regressions when macro modularization was enabled - see issue #54472.
This PR disambiguates such conflicts in favor of
macro_rules
if both themacro_rules
item and in-module macro name are defined in the same normal (named) module andmacro_rules
is closer in scope to the point of use (see the tests for examples).This is a subset of more general approach described in #54472 (comment).
The subset is enough to fix all the regressions from #54472, but it can be extended to apply to all "macro_rules" vs "macro name in module" conflicts in the future.
To give an analogy, this is equivalent to scoping rules for
let
variables and items defined in blocks (macro_rules
behaves like "let
at module level" in general).More complex examples with
use
andmacro_rules
from different modules still report ambiguity errors, even if equivalent examples withlet
are legal.Fixes #54472 (stable-to-beta regression)