incr.comp.: Provide session to some more decoding contexts.

This commit is contained in:
Michael Woerister 2017-11-08 14:52:00 +01:00
parent d948af1d37
commit d01b89b948
3 changed files with 23 additions and 8 deletions

View File

@ -258,14 +258,15 @@ impl<'a> CrateLoader<'a> {
let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span, dep_kind);
let def_path_table = record_time(&self.sess.perf_stats.decode_def_path_tables_time, || {
crate_root.def_path_table.decode(&metadata)
crate_root.def_path_table.decode((&metadata, self.sess))
});
let exported_symbols = crate_root.exported_symbols.decode(&metadata).collect();
let exported_symbols = crate_root.exported_symbols
.decode((&metadata, self.sess))
.collect();
let trait_impls = crate_root
.impls
.decode(&metadata)
.decode((&metadata, self.sess))
.map(|trait_impls| (trait_impls.trait_id, trait_impls.impls))
.collect();
@ -298,7 +299,7 @@ impl<'a> CrateLoader<'a> {
let dllimports: FxHashSet<_> = cmeta
.root
.native_libraries
.decode(&cmeta)
.decode((&cmeta, self.sess))
.filter(|lib| relevant_lib(self.sess, lib) &&
lib.kind == cstore::NativeLibraryKind::NativeUnknown)
.flat_map(|lib| {

View File

@ -183,7 +183,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
is_no_builtins => { cdata.is_no_builtins(tcx.sess) }
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
exported_symbol_ids => { Rc::new(cdata.get_exported_symbols()) }
native_libraries => { Rc::new(cdata.get_native_libraries()) }
native_libraries => { Rc::new(cdata.get_native_libraries(tcx.sess)) }
plugin_registrar_fn => {
cdata.root.plugin_registrar_fn.map(|index| {
DefId { krate: def_id.krate, index }

View File

@ -87,6 +87,20 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for &'a MetadataBlob {
}
}
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a MetadataBlob, &'a Session) {
fn raw_bytes(self) -> &'a [u8] {
let (blob, _) = self;
&blob.0
}
fn sess(self) -> Option<&'a Session> {
let (_, sess) = self;
Some(sess)
}
}
impl<'a, 'tcx> Metadata<'a, 'tcx> for &'a CrateMetadata {
fn raw_bytes(self) -> &'a [u8] {
self.blob.raw_bytes()
@ -1017,8 +1031,8 @@ impl<'a, 'tcx> CrateMetadata {
}
pub fn get_native_libraries(&self) -> Vec<NativeLibrary> {
self.root.native_libraries.decode(self).collect()
pub fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLibrary> {
self.root.native_libraries.decode((self, sess)).collect()
}
pub fn get_dylib_dependency_formats(&self) -> Vec<(CrateNum, LinkagePreference)> {