]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_span/lib.rs
Rollup merge of #68388 - varkor:toogeneric-wf, r=eddyb
[rust.git] / src / librustc_span / lib.rs
index a58c12f23508ac74f0744edf2021c57dd43a3570..5779d17e3e51ebe57cdb66de56232338b192696b 100644 (file)
@@ -5,7 +5,6 @@
 //! This API is completely unstable and subject to change.
 
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![feature(const_fn)]
 #![feature(crate_visibility_modifier)]
 #![feature(nll)]
 #![feature(optin_builtin_traits)]
@@ -309,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())
@@ -1052,7 +1056,7 @@ fn decode<D: Decoder>(d: &mut D) -> Result<SourceFile, D::Error> {
                 name_was_remapped,
                 unmapped_path: None,
                 // `crate_of_origin` has to be set by the importer.
-                // This value matches up with `rustc::hir::def_id::INVALID_CRATE`.
+                // This value matches up with `rustc_hir::def_id::INVALID_CRATE`.
                 // That constant is not available here, unfortunately.
                 crate_of_origin: std::u32::MAX - 1,
                 start_pos,