Make the CrateNum part of the ExpnId.
This commit is contained in:
parent
c2d43e1329
commit
6e78d6c9d6
9 changed files with 310 additions and 115 deletions
|
@ -30,9 +30,10 @@ use rustc_middle::ty::codec::TyDecoder;
|
|||
use rustc_middle::ty::{self, Ty, TyCtxt, Visibility};
|
||||
use rustc_serialize::{opaque, Decodable, Decoder};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::hygiene::{ExpnIndex, MacroKind};
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
use rustc_span::{self, hygiene::MacroKind, BytePos, ExpnId, Pos, Span, SyntaxContext, DUMMY_SP};
|
||||
use rustc_span::{self, BytePos, ExpnId, Pos, Span, SyntaxContext, DUMMY_SP};
|
||||
|
||||
use proc_macro::bridge::client::ProcMacro;
|
||||
use std::io;
|
||||
|
@ -348,6 +349,12 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for DefIndex {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for ExpnIndex {
|
||||
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Result<ExpnIndex, String> {
|
||||
Ok(ExpnIndex::from_u32(d.read_u32()?))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for SyntaxContext {
|
||||
fn decode(decoder: &mut DecodeContext<'a, 'tcx>) -> Result<SyntaxContext, String> {
|
||||
let cdata = decoder.cdata();
|
||||
|
|
|
@ -18,11 +18,11 @@ use rustc_middle::ty::query::Providers;
|
|||
use rustc_middle::ty::{self, TyCtxt, Visibility};
|
||||
use rustc_session::utils::NativeLibKind;
|
||||
use rustc_session::{Session, StableCrateId};
|
||||
use rustc_span::hygiene::{ExpnData, ExpnHash, ExpnId};
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_span::ExpnId;
|
||||
use smallvec::SmallVec;
|
||||
use std::any::Any;
|
||||
|
||||
|
@ -494,6 +494,23 @@ impl CrateStore for CStore {
|
|||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
fn decode_expn_data(&self, sess: &Session, expn_id: ExpnId) -> (ExpnData, ExpnHash) {
|
||||
let crate_data = self.get_crate_data(expn_id.krate);
|
||||
(
|
||||
crate_data
|
||||
.root
|
||||
.expn_data
|
||||
.get(&crate_data, expn_id.local_id)
|
||||
.unwrap()
|
||||
.decode((&crate_data, sess)),
|
||||
crate_data
|
||||
.root
|
||||
.expn_hashes
|
||||
.get(&crate_data, expn_id.local_id)
|
||||
.unwrap()
|
||||
.decode((&crate_data, sess)),
|
||||
)
|
||||
}
|
||||
|
||||
fn crate_name(&self, cnum: CrateNum) -> Symbol {
|
||||
self.get_crate_data(cnum).root.name
|
||||
|
|
|
@ -31,7 +31,7 @@ use rustc_session::config::CrateType;
|
|||
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
use rustc_span::{self, ExternalSource, FileName, SourceFile, Span, SyntaxContext};
|
||||
use rustc_span::{
|
||||
hygiene::{HygieneEncodeContext, MacroKind},
|
||||
hygiene::{ExpnIndex, HygieneEncodeContext, MacroKind},
|
||||
RealFileName,
|
||||
};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
|
@ -168,6 +168,12 @@ impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for DefIndex {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for ExpnIndex {
|
||||
fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
|
||||
s.emit_u32(self.as_u32())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for SyntaxContext {
|
||||
fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
|
||||
rustc_span::hygiene::raw_encode_syntax_context(*self, &s.hygiene_ctxt, s)
|
||||
|
@ -1588,8 +1594,10 @@ impl EncodeContext<'a, 'tcx> {
|
|||
Ok(())
|
||||
},
|
||||
|(this, _, expn_data_table, expn_hash_table), index, expn_data, hash| {
|
||||
expn_data_table.set(index, this.lazy(expn_data));
|
||||
expn_hash_table.set(index, this.lazy(hash));
|
||||
if let Some(index) = index.as_local() {
|
||||
expn_data_table.set(index.as_raw(), this.lazy(expn_data));
|
||||
expn_hash_table.set(index.as_raw(), this.lazy(hash));
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ use rustc_middle::ty::{self, ReprOptions, Ty};
|
|||
use rustc_serialize::opaque::Encoder;
|
||||
use rustc_session::config::SymbolManglingVersion;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::hygiene::{ExpnIndex, MacroKind};
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span};
|
||||
use rustc_target::spec::{PanicStrategy, TargetTriple};
|
||||
|
@ -170,8 +170,8 @@ macro_rules! Lazy {
|
|||
}
|
||||
|
||||
type SyntaxContextTable = Lazy<Table<u32, Lazy<SyntaxContextData>>>;
|
||||
type ExpnDataTable = Lazy<Table<u32, Lazy<ExpnData>>>;
|
||||
type ExpnHashTable = Lazy<Table<u32, Lazy<ExpnHash>>>;
|
||||
type ExpnDataTable = Lazy<Table<ExpnIndex, Lazy<ExpnData>>>;
|
||||
type ExpnHashTable = Lazy<Table<ExpnIndex, Lazy<ExpnHash>>>;
|
||||
|
||||
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||
crate struct ProcMacroData {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue