-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Cleanup handling of hygiene for built-in macros #64469
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
Conversation
r=me with Centril's comment addressed |
1742e1e
to
8ab67c8
Compare
@bors r=petrochenkov |
📌 Commit 8ab67c8 has been approved by |
…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); |
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.
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.)
☀️ Test successful - checks-azure |
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 aSpan
and is preferred toIdent::{from_str, from_str_and_span}
Span::with_legacy_ctxt
assert
now uses call-site hygiene because it needs to resolvepanic
unhygienically.concat_idents
now uses call-site hygiene because it wouldn't be very useful with def-site hygiene.r? @petrochenkov