334373324d
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.
31 lines
1.0 KiB
Plaintext
31 lines
1.0 KiB
Plaintext
Def site: $DIR/auxiliary/make-macro.rs:5:9: 8:10 (#3)
|
|
#![feature /* 280#0 */(prelude_import)]
|
|
#[prelude_import /* 527#1 */]
|
|
use std /* 687#1 */::prelude /* 526#1 */::v1 /* 783#1 */::*;
|
|
#[macro_use /* 404#1 */]
|
|
extern crate std /* 687#1 */;
|
|
// aux-build:make-macro.rs
|
|
// aux-build:meta-macro.rs
|
|
// edition:2018
|
|
// compile-flags: -Z span-debug -Z unpretty=expanded,hygiene
|
|
// check-pass
|
|
|
|
extern crate meta_macro /* 834#0 */;
|
|
|
|
fn main /* 406#0 */() { }
|
|
|
|
/*
|
|
Expansions:
|
|
0: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Root
|
|
1: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
|
|
2: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "meta_macro::print_def_site")
|
|
|
|
SyntaxContexts:
|
|
#0: parent: #0, outer_mark: (ExpnId(0), Opaque)
|
|
#1: parent: #0, outer_mark: (ExpnId(1), Opaque)
|
|
#2: parent: #0, outer_mark: (ExpnId(1), Transparent)
|
|
#3: parent: #0, outer_mark: (ExpnId(2), Opaque)
|
|
#4: parent: #0, outer_mark: (ExpnId(2), Transparent)
|
|
#5: parent: #0, outer_mark: (ExpnId(2), SemiTransparent)
|
|
*/
|