-
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
macros: improve 1.0/2.0 interaction #46551
Merged
bors
merged 2 commits into
rust-lang:master
from
jseyfried:improve_legacy_modern_macro_interaction
Jan 12, 2018
Merged
macros: improve 1.0/2.0 interaction #46551
bors
merged 2 commits into
rust-lang:master
from
jseyfried:improve_legacy_modern_macro_interaction
Jan 12, 2018
Conversation
This file contains 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
jseyfried
force-pushed
the
improve_legacy_modern_macro_interaction
branch
from
December 7, 2017 05:09
fb6fc6a
to
fc3dadb
Compare
jseyfried
commented
Dec 7, 2017
@@ -95,7 +95,7 @@ impl FromStr for TokenStream { | |||
// notify the expansion info that it is unhygienic | |||
let mark = Mark::fresh(mark); | |||
mark.set_expn_info(expn_info); | |||
let span = call_site.with_ctxt(call_site.ctxt().apply_mark(mark)); | |||
let span = call_site.with_ctxt(SyntaxContext::empty().apply_mark(mark)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Déjà vu :)
kennytm
added
the
S-blocked
Status: Blocked on something else such as an RFC or other implementation work.
label
Dec 7, 2017
kennytm
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
and removed
S-blocked
Status: Blocked on something else such as an RFC or other implementation work.
labels
Dec 13, 2017
jseyfried
force-pushed
the
improve_legacy_modern_macro_interaction
branch
2 times, most recently
from
December 13, 2017 20:42
fb04829
to
d6a8566
Compare
jseyfried
force-pushed
the
improve_legacy_modern_macro_interaction
branch
from
December 13, 2017 21:33
d6a8566
to
b766fa8
Compare
Review ping for you @nrc! |
ping @nrc, this may be ready for a look now! |
Review ping for you @nrc! |
@bors: r+ |
📌 Commit b766fa8 has been approved by |
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? @nrc
☀️ Test successful - status-appveyor, status-travis |
Sign up for free
to 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