]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #73706 - Aaron1011:fix/proc-macro-foreign-span, r=petrochenkov
authorbors <bors@rust-lang.org>
Wed, 1 Jul 2020 01:04:31 +0000 (01:04 +0000)
committerbors <bors@rust-lang.org>
Wed, 1 Jul 2020 01:04:31 +0000 (01:04 +0000)
Serialize all foreign `SourceFile`s into proc-macro crate metadata

Normally, we encode a `Span` that references a foreign `SourceFile` by
encoding information about the foreign crate. When we decode this
`Span`, we lookup the foreign crate in order to decode the `SourceFile`.

However, this approach does not work for proc-macro crates. When we load
a proc-macro crate, we do not deserialzie any of its dependencies (since
a proc-macro crate can only export proc-macros). This means that we
cannot serialize a reference to an upstream crate, since the associated
metadata will not be available when we try to deserialize it.

This commit modifies foreign span handling so that we treat all foreign
`SourceFile`s as local `SourceFile`s when serializing a proc-macro.
All `SourceFile`s will be stored into the metadata of a proc-macro
crate, allowing us to cotinue to deserialize a proc-macro crate without
needing to load any of its dependencies.

Since the number of foreign `SourceFile`s that we load during a
compilation session may be very large, we only serialize a `SourceFile`
if we have also serialized a `Span` which requires it.


Trivial merge