Cleanup handling of hygiene for built-in macros#64469
Merged
bors merged 4 commits intorust-lang:masterfrom Sep 15, 2019
Merged
Conversation
Centril
reviewed
Sep 14, 2019
Contributor
|
r=me with Centril's comment addressed |
1742e1e to
8ab67c8
Compare
Contributor
Author
|
@bors r=petrochenkov |
Collaborator
|
📌 Commit 8ab67c8 has been approved by |
Collaborator
bors
added a commit
that referenced
this pull request
Sep 15, 2019
…nkov
Cleanup handling of hygiene for built-in macros
This makes most identifiers generated by built-in macros use def-site hygiene, not only the ones that previously used gensyms.
* `ExtCtxt::ident_of` now takes a `Span` and is preferred to `Ident::{from_str, from_str_and_span}`
* Remove `Span::with_legacy_ctxt`
* `assert` now uses call-site hygiene because it needs to resolve `panic` unhygienically.
* `concat_idents` now uses call-site hygiene because it wouldn't be very useful with def-site hygiene.
* everything else is moved to def-site hygiene
r? @petrochenkov
| let sp = cx.with_legacy_ctxt(sp); | ||
| // `core::panic` and `std::panic` are different macros, so we use call-site | ||
| // context to pick up whichever is currently in scope. | ||
| let sp = cx.with_call_site_ctxt(sp); |
Contributor
There was a problem hiding this comment.
I'd rather use the call-site span in a more targeted way though, for the panic identifier specifically, and def-site for everything else.
(Not sure if this makes observable difference in this case, but it's a safer default.)
Collaborator
|
☀️ Test successful - checks-azure |
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 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 makes most identifiers generated by built-in macros use def-site hygiene, not only the ones that previously used gensyms.
ExtCtxt::ident_ofnow takes aSpanand is preferred toIdent::{from_str, from_str_and_span}Span::with_legacy_ctxtassertnow uses call-site hygiene because it needs to resolvepanicunhygienically.concat_identsnow uses call-site hygiene because it wouldn't be very useful with def-site hygiene.r? @petrochenkov