Uh oh!
There was an error while loading. Please reload this page.
macros: improve 1.0/2.0 interaction - #46551
Merged
bors merged 2 commits intoJan 12, 2018
Merged
Conversation
jseyfriedforce-pushed
the
improve_legacy_modern_macro_interaction
branch
from
December 7, 2017 05:09
fb6fc6a to
fc3dadbComparejseyfried
commented
Dec 7, 2017
kennytm
commented
Dec 13, 2017
Member
jseyfriedforce-pushed
the
improve_legacy_modern_macro_interaction
branch
2 times, most recently
from
December 13, 2017 20:42
fb04829 to
d6a8566Comparejseyfriedforce-pushed
the
improve_legacy_modern_macro_interaction
branch
from
December 13, 2017 21:33
d6a8566 to
b766fa8Comparekennytm
commented
Dec 20, 2017
Member
Review ping for you @nrc! |
alexcrichton
commented
Jan 4, 2018
Member
ping @nrc, this may be ready for a look now! |
kennytm
commented
Jan 10, 2018
Member
Review ping for you @nrc! |
nrc
commented
Jan 12, 2018
Member
@bors: r+ |
bors
commented
Jan 12, 2018
Collaborator
📌 Commit b766fa8 has been approved by |
bors
commented
Jan 12, 2018
Collaborator
bors added a commit
that referenced
this pull request
Jan 12, 2018
…ion, r=nrc
macros: improve 1.0/2.0 interaction
This PR supports using unhygienic macros from hygienic macros without breaking the latter's hygiene.
```rust
// crate A:
#[macro_export]
macro_rules! m1 { () => {
f(); // unhygienic: this macro needs `f` in its environment
fn g() {} // (1) unhygienic: `g` is usable outside the macro definition
} }
// crate B:
#![feature(decl_macro)]
extern crate A;
use A::m1;
macro m2() {
fn f() {} // (2)
m1!(); // After this PR, `f()` in the expansion resolves to (2), not (3)
g(); // After this PR, this resolves to `fn g() {}` from the above expansion.
// Today, it is a resolution error.
}
fn test() {
fn f() {} // (3)
m2!(); // Today, `m2!()` can see (3) even though it should be hygienic.
fn g() {} // Today, this conflicts with `fn g() {}` from the expansion, even though it should be hygienic.
}
```
Once this PR lands, you can make an existing unhygienic macro hygienic by wrapping it in a hygienic macro. There is an [example](b766fa8) of this in the tests.
r? @nrcbors
commented
Jan 12, 2018
Collaborator
☀️ Test successful - status-appveyor, status-travis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR supports using unhygienic macros from hygienic macros without breaking the latter's hygiene.
Once this PR lands, you can make an existing unhygienic macro hygienic by wrapping it in a hygienic macro. There is an example of this in the tests.
r? @nrc