]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_span/lib.rs
Rollup merge of #68483 - flip1995:mailmap, r=Dylan-DPC
[rust.git] / src / librustc_span / lib.rs
index 1dc7fc5aa3ad1aec7fa4b33d7cbbfdcf225ef5e7..5779d17e3e51ebe57cdb66de56232338b192696b 100644 (file)
@@ -308,6 +308,11 @@ pub fn from_expansion(self) -> bool {
         self.ctxt() != SyntaxContext::root()
     }
 
+    /// Returns `true` if `span` originates in a derive-macro's expansion.
+    pub fn in_derive_expansion(self) -> bool {
+        matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _))
+    }
+
     #[inline]
     pub fn with_root_ctxt(lo: BytePos, hi: BytePos) -> Span {
         Span::new(lo, hi, SyntaxContext::root())