about summary refs log tree commit diff
path: root/src/libsyntax_ext/assert.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-09-15 08:17:57 +0000
committerbors <bors@rust-lang.org>2019-09-15 08:17:57 +0000
commit117cdf35d46cb4dbb246e300a492c860a86233be (patch)
tree109e3227f1b4076c99874c94dc9aa1d554781f2b /src/libsyntax_ext/assert.rs
parent8bf776d5c2fc88624d2562e493aab0d324a3b7d8 (diff)
parent8ab67c8f560a730b8978f4a42deb70d01ca1cdfc (diff)
downloadrust-117cdf35d46cb4dbb246e300a492c860a86233be.tar.gz
rust-117cdf35d46cb4dbb246e300a492c860a86233be.zip
Auto merge of #64469 - matthewjasper:increase-hygiene-use, r=petrochenkov
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
Diffstat (limited to 'src/libsyntax_ext/assert.rs')
-rw-r--r--src/libsyntax_ext/assert.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libsyntax_ext/assert.rs b/src/libsyntax_ext/assert.rs
index 001996e1db7..cbfe14fa439 100644
--- a/src/libsyntax_ext/assert.rs
+++ b/src/libsyntax_ext/assert.rs
@@ -23,7 +23,9 @@ pub fn expand_assert<'cx>(
         }
     };
 
-    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);
     let panic_call = Mac {
         path: Path::from_ident(Ident::new(sym::panic, sp)),
         tts: custom_message.unwrap_or_else(|| {