-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Span hygiene data should be serialized to crate metadata #68686
Copy link
Copy link
Closed
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-metadataArea: Crate metadataArea: Crate metadataC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-metadataArea: Crate metadataArea: Crate metadataC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
When we serialize a
Spanto crate metadata, we currently throw away theSyntaxContext:rust/src/librustc_span/lib.rs
Lines 631 to 650 in 34700c1
This is because the backing
HygieneDatais stored in a thread-local inrustc_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 thecaller_locationintrinsic).It would be useful if we were to serialize
HygieneDatainto crate metadata, and deserialize spans with the properSyntaxContext. This will also ensure that parallel compilation works properly, since storingHygieneDatain a thread local will cause problems if aSpanis used on multiple threads.I'm not really sure how best to go about doing this.
ExpnIds are currently unique per-crate, since they are never serialized. We need some way of makingExpnIdsglobally unique.