Add comment about the lack of ExpnData serialization for proc-macro crates

This commit is contained in:
Aaron Hill 2020-08-09 08:42:41 -04:00
parent 955aebf529
commit ef49032297
No known key found for this signature in database
GPG key ID: B4087E510E98B164
2 changed files with 7 additions and 0 deletions

View file

@ -280,6 +280,10 @@ impl<'a, 'tcx> SpecializedEncoder<Span> for EncodeContext<'a, 'tcx> {
// cross-crate inconsistencies (getting one behavior in the same
// crate, and a different behavior in another crate) due to the
// limited surface that proc-macros can expose.
//
// IMPORTANT: If this is ever changed, be sure to update
// `rustc_span::hygiene::raw_encode_expn_id` to handle
// encoding `ExpnData` for proc-macro crates.
if self.is_proc_macro {
SyntaxContext::root().encode(self)?;
} else {

View file

@ -1188,6 +1188,9 @@ pub fn raw_encode_expn_id<E: Encoder>(
let data = expn.expn_data();
// We only need to serialize the ExpnData
// if it comes from this crate.
// We currently don't serialize any hygiene information data for
// proc-macro crates: see the `SpecializedEncoder<Span>` impl
// for crate metadata.
if data.krate == LOCAL_CRATE {
needs_data();
}