about summary refs log tree commit diff
path: root/src/libproc_macro
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-09-22 18:38:02 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-10-03 11:28:06 +0300
commitd1310dc6c989e191d85c73c943d4175fbf1dccb8 (patch)
treed0ca6fac9bdb651e328a8a6990c16208ad5dc43a /src/libproc_macro
parentc6293e359848c8c7275330719b33ccd168df04c3 (diff)
proc_macro: Add `Span::mixed_site` exposing `macro_rules` hygiene
Diffstat (limited to 'src/libproc_macro')
-rw-r--r--src/libproc_macro/bridge/mod.rs1
-rw-r--r--src/libproc_macro/lib.rs9
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libproc_macro/bridge/mod.rs b/src/libproc_macro/bridge/mod.rs
index 3c48466fffa..c26b59f473c 100644
--- a/src/libproc_macro/bridge/mod.rs
+++ b/src/libproc_macro/bridge/mod.rs
@@ -148,6 +148,7 @@ macro_rules! with_api {
                 fn debug($self: $S::Span) -> String;
                 fn def_site() -> $S::Span;
                 fn call_site() -> $S::Span;
+                fn mixed_site() -> $S::Span;
                 fn source_file($self: $S::Span) -> $S::SourceFile;
                 fn parent($self: $S::Span) -> Option<$S::Span>;
                 fn source($self: $S::Span) -> $S::Span;
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs
index d5cdc266acb..e199670b561 100644
--- a/src/libproc_macro/lib.rs
+++ b/src/libproc_macro/lib.rs
@@ -271,6 +271,15 @@ impl Span {
         Span(bridge::client::Span::call_site())
     }
 
+    /// A span that represents `macro_rules` hygiene, and sometimes resolves at the macro
+    /// definition site (local variables, labels, `$crate`) and sometimes at the macro
+    /// call site (everything else).
+    /// The span location is taken from the call-site.
+    #[unstable(feature = "proc_macro_mixed_site", issue = "65049")]
+    pub fn mixed_site() -> Span {
+        Span(bridge::client::Span::mixed_site())
+    }
+
     /// The original source file into which this span points.
     #[unstable(feature = "proc_macro_span", issue = "54725")]
     pub fn source_file(&self) -> SourceFile {