@@ -34,15 +34,16 @@ use rustc_incremental;
3434use rustc_resolve:: { MakeGlobMap , Resolver } ;
3535use rustc_metadata:: creader:: CrateLoader ;
3636use rustc_metadata:: cstore:: { self , CStore } ;
37- use rustc_trans:: back:: write;
3837use rustc_trans as trans;
38+ use rustc_trans_traits:: TransCrate ;
3939use rustc_typeck as typeck;
4040use rustc_privacy;
4141use rustc_plugin:: registry:: Registry ;
4242use rustc_plugin as plugin;
4343use rustc_passes:: { ast_validation, no_asm, loops, consts, static_recursion, hir_stats} ;
4444use rustc_const_eval:: { self , check_match} ;
4545use super :: Compilation ;
46+ use :: DefaultTransCrate ;
4647
4748use serialize:: json;
4849
@@ -76,7 +77,6 @@ pub fn compile_input(sess: &Session,
7677 output : & Option < PathBuf > ,
7778 addl_plugins : Option < Vec < String > > ,
7879 control : & CompileController ) -> CompileResult {
79- use rustc_trans:: back:: write:: OngoingCrateTranslation ;
8080 use rustc:: session:: config:: CrateType ;
8181
8282 macro_rules! controller_entry_point {
@@ -122,7 +122,7 @@ pub fn compile_input(sess: &Session,
122122 // We need nested scopes here, because the intermediate results can keep
123123 // large chunks of memory alive and we want to free them as soon as
124124 // possible to keep the peak memory usage low
125- let ( outputs, trans, dep_graph) : ( OutputFilenames , OngoingCrateTranslation , DepGraph ) = {
125+ let ( outputs, trans, dep_graph) = {
126126 let krate = match phase_1_parse_input ( control, sess, input) {
127127 Ok ( krate) => krate,
128128 Err ( mut parse_error) => {
@@ -251,7 +251,7 @@ pub fn compile_input(sess: &Session,
251251 tcx. print_debug_stats ( ) ;
252252 }
253253
254- let trans = phase_4_translate_to_llvm ( tcx, rx) ;
254+ let trans = phase_4_translate_to_llvm :: < DefaultTransCrate > ( tcx, rx) ;
255255
256256 if log_enabled ! ( :: log:: LogLevel :: Info ) {
257257 println ! ( "Post-trans" ) ;
@@ -285,15 +285,15 @@ pub fn compile_input(sess: &Session,
285285 sess. code_stats . borrow ( ) . print_type_sizes ( ) ;
286286 }
287287
288- let ( phase5_result, trans) = phase_5_run_llvm_passes ( sess, & dep_graph, trans) ;
288+ let ( phase5_result, trans) = phase_5_run_llvm_passes :: < DefaultTransCrate > ( sess, & dep_graph, trans) ;
289289
290290 controller_entry_point ! ( after_llvm,
291291 sess,
292292 CompileState :: state_after_llvm( input, sess, outdir, output, & trans) ,
293293 phase5_result) ;
294294 phase5_result?;
295295
296- phase_6_link_output ( sess, & trans, & outputs) ;
296+ phase_6_link_output :: < DefaultTransCrate > ( sess, & trans, & outputs) ;
297297
298298 // Now that we won't touch anything in the incremental compilation directory
299299 // any more, we can finalize it (which involves renaming it)
@@ -972,7 +972,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
972972 mir:: provide ( & mut local_providers) ;
973973 reachable:: provide ( & mut local_providers) ;
974974 rustc_privacy:: provide ( & mut local_providers) ;
975- trans :: provide_local ( & mut local_providers) ;
975+ DefaultTransCrate :: provide_local ( & mut local_providers) ;
976976 typeck:: provide ( & mut local_providers) ;
977977 ty:: provide ( & mut local_providers) ;
978978 traits:: provide ( & mut local_providers) ;
@@ -984,7 +984,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
984984
985985 let mut extern_providers = ty:: maps:: Providers :: default ( ) ;
986986 cstore:: provide ( & mut extern_providers) ;
987- trans :: provide_extern ( & mut extern_providers) ;
987+ DefaultTransCrate :: provide_extern ( & mut extern_providers) ;
988988 ty:: provide_extern ( & mut extern_providers) ;
989989 traits:: provide_extern ( & mut extern_providers) ;
990990 // FIXME(eddyb) get rid of this once we replace const_eval with miri.
@@ -1130,9 +1130,9 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
11301130
11311131/// Run the translation phase to LLVM, after which the AST and analysis can
11321132/// be discarded.
1133- pub fn phase_4_translate_to_llvm < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1133+ pub fn phase_4_translate_to_llvm < ' a , ' tcx , T : TransCrate > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
11341134 rx : mpsc:: Receiver < Box < Any + Send > > )
1135- -> write :: OngoingCrateTranslation {
1135+ -> < T as TransCrate > :: OngoingCrateTranslation {
11361136 let time_passes = tcx. sess . time_passes ( ) ;
11371137
11381138 time ( time_passes,
@@ -1141,9 +1141,8 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11411141
11421142 let translation =
11431143 time ( time_passes, "translation" , move || {
1144- trans :: trans_crate ( tcx, rx)
1144+ T :: trans_crate ( tcx, rx)
11451145 } ) ;
1146-
11471146 if tcx. sess . profile_queries ( ) {
11481147 profile:: dump ( "profile_queries" . to_string ( ) )
11491148 }
@@ -1153,15 +1152,14 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11531152
11541153/// Run LLVM itself, producing a bitcode file, assembly file or object file
11551154/// as a side effect.
1156- #[ cfg( feature="llvm" ) ]
1157- pub fn phase_5_run_llvm_passes ( sess : & Session ,
1155+ pub fn phase_5_run_llvm_passes < T : TransCrate > ( sess : & Session ,
11581156 dep_graph : & DepGraph ,
1159- trans : write :: OngoingCrateTranslation )
1160- -> ( CompileResult , trans :: CrateTranslation ) {
1161- let trans = trans . join ( sess, dep_graph) ;
1157+ trans : < T as TransCrate > :: OngoingCrateTranslation )
1158+ -> ( CompileResult , < T as TransCrate > :: TranslatedCrate ) {
1159+ let trans = T :: join_trans ( trans , sess, dep_graph) ;
11621160
11631161 if sess. opts . debugging_opts . incremental_info {
1164- write :: dump_incremental_data ( & trans) ;
1162+ T :: dump_incremental_data ( & trans) ;
11651163 }
11661164
11671165 time ( sess. time_passes ( ) ,
@@ -1174,14 +1172,11 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
11741172/// Run the linker on any artifacts that resulted from the LLVM run.
11751173/// This should produce either a finished executable or library.
11761174#[ cfg( feature="llvm" ) ]
1177- pub fn phase_6_link_output ( sess : & Session ,
1178- trans : & trans :: CrateTranslation ,
1175+ pub fn phase_6_link_output < T : TransCrate > ( sess : & Session ,
1176+ trans : & < T as TransCrate > :: TranslatedCrate ,
11791177 outputs : & OutputFilenames ) {
11801178 time ( sess. time_passes ( ) , "linking" , || {
1181- :: rustc_trans:: back:: link:: link_binary ( sess,
1182- trans,
1183- outputs,
1184- & trans. crate_name . as_str ( ) )
1179+ T :: link_binary ( sess, trans, outputs)
11851180 } ) ;
11861181}
11871182
0 commit comments