Description
When we serialize a Span
to crate metadata, we currently throw away the SyntaxContext
:
Lines 631 to 650 in 34700c1
This is because the backing HygieneData
is stored in a thread-local in rustc_span
, and not serialized into crate metadata.
The result is that spans deserialized from crate metadata may have less information available than spans from the current crate. If the MIR inlining pass decides to inline a function from another crate, we may end up with suboptimal messages when we invoke span.ctxt()
(e.g. when emitting debuginfo, and when evaluating the caller_location
intrinsic).
It would be useful if we were to serialize HygieneData
into crate metadata, and deserialize spans with the proper SyntaxContext
. This will also ensure that parallel compilation works properly, since storing HygieneData
in a thread local will cause problems if a Span
is used on multiple threads.
I'm not really sure how best to go about doing this. ExpnId
s are currently unique per-crate, since they are never serialized. We need some way of making ExpnIds
globally unique.