@@ -725,14 +725,14 @@ fn contains_null(s: &str) -> bool {
725
725
s. bytes ( ) . any ( |b| b == 0 )
726
726
}
727
727
728
- fn write_metadata ( cx : & SharedCrateContext ,
729
- link_meta : & LinkMeta ,
730
- exported_symbols : & NodeSet )
731
- -> ( ContextRef , ModuleRef , EncodedMetadata ) {
728
+ fn write_metadata < ' a , ' gcx > ( tcx : TyCtxt < ' a , ' gcx , ' gcx > ,
729
+ link_meta : & LinkMeta ,
730
+ exported_symbols : & NodeSet )
731
+ -> ( ContextRef , ModuleRef , EncodedMetadata ) {
732
732
use flate;
733
733
734
734
let ( metadata_llcx, metadata_llmod) = unsafe {
735
- context:: create_context_and_module ( cx . sess ( ) , "metadata" )
735
+ context:: create_context_and_module ( tcx . sess , "metadata" )
736
736
} ;
737
737
738
738
#[ derive( PartialEq , Eq , PartialOrd , Ord ) ]
@@ -742,7 +742,7 @@ fn write_metadata(cx: &SharedCrateContext,
742
742
Compressed
743
743
}
744
744
745
- let kind = cx . sess ( ) . crate_types . borrow ( ) . iter ( ) . map ( |ty| {
745
+ let kind = tcx . sess . crate_types . borrow ( ) . iter ( ) . map ( |ty| {
746
746
match * ty {
747
747
config:: CrateTypeExecutable |
748
748
config:: CrateTypeStaticlib |
@@ -762,8 +762,8 @@ fn write_metadata(cx: &SharedCrateContext,
762
762
} ) ;
763
763
}
764
764
765
- let cstore = & cx . tcx ( ) . sess . cstore ;
766
- let metadata = cstore. encode_metadata ( cx . tcx ( ) ,
765
+ let cstore = & tcx. sess . cstore ;
766
+ let metadata = cstore. encode_metadata ( tcx,
767
767
& link_meta,
768
768
exported_symbols) ;
769
769
if kind == MetadataKind :: Uncompressed {
@@ -776,15 +776,15 @@ fn write_metadata(cx: &SharedCrateContext,
776
776
777
777
let llmeta = C_bytes_in_context ( metadata_llcx, & compressed) ;
778
778
let llconst = C_struct_in_context ( metadata_llcx, & [ llmeta] , false ) ;
779
- let name = symbol_export:: metadata_symbol_name ( cx . tcx ( ) ) ;
779
+ let name = symbol_export:: metadata_symbol_name ( tcx) ;
780
780
let buf = CString :: new ( name) . unwrap ( ) ;
781
781
let llglobal = unsafe {
782
782
llvm:: LLVMAddGlobal ( metadata_llmod, val_ty ( llconst) . to_ref ( ) , buf. as_ptr ( ) )
783
783
} ;
784
784
unsafe {
785
785
llvm:: LLVMSetInitializer ( llglobal, llconst) ;
786
786
let section_name =
787
- cx . tcx ( ) . sess . cstore . metadata_section_name ( & cx . sess ( ) . target . target ) ;
787
+ tcx. sess . cstore . metadata_section_name ( & tcx . sess . target . target ) ;
788
788
let name = CString :: new ( section_name) . unwrap ( ) ;
789
789
llvm:: LLVMSetSection ( llglobal, name. as_ptr ( ) ) ;
790
790
@@ -1078,7 +1078,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1078
1078
// Translate the metadata.
1079
1079
let ( metadata_llcx, metadata_llmod, metadata) =
1080
1080
time ( tcx. sess . time_passes ( ) , "write metadata" , || {
1081
- write_metadata ( & shared_ccx , & link_meta, shared_ccx. exported_symbols ( ) )
1081
+ write_metadata ( tcx , & link_meta, shared_ccx. exported_symbols ( ) )
1082
1082
} ) ;
1083
1083
1084
1084
let metadata_module = ModuleTranslation {
0 commit comments