@@ -28,14 +28,12 @@ use rustc_errors::{ErrorReported, FatalError, Handler};
2828use rustc_middle:: dep_graph:: { WorkProduct , WorkProductId } ;
2929use rustc_middle:: middle:: cstore:: { EncodedMetadata , MetadataLoaderDyn } ;
3030use rustc_middle:: ty:: { self , TyCtxt } ;
31- use rustc_serialize:: json;
32- use rustc_session:: config:: { self , OptLevel , OutputFilenames , PrintRequest } ;
31+ use rustc_session:: config:: { OptLevel , OutputFilenames , PrintRequest } ;
3332use rustc_session:: Session ;
3433use rustc_span:: symbol:: Symbol ;
3534
3635use std:: any:: Any ;
3736use std:: ffi:: CStr ;
38- use std:: fs;
3937use std:: sync:: Arc ;
4038
4139mod back {
@@ -275,7 +273,7 @@ impl CodegenBackend for LlvmCodegenBackend {
275273 & self ,
276274 ongoing_codegen : Box < dyn Any > ,
277275 sess : & Session ,
278- ) -> Result < ( Box < dyn Any > , FxHashMap < WorkProductId , WorkProduct > ) , ErrorReported > {
276+ ) -> Result < ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) , ErrorReported > {
279277 let ( codegen_results, work_products) = ongoing_codegen
280278 . downcast :: < rustc_codegen_ssa:: back:: write:: OngoingCodegen < LlvmCodegenBackend > > ( )
281279 . expect ( "Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>" )
@@ -284,31 +282,15 @@ impl CodegenBackend for LlvmCodegenBackend {
284282 rustc_codegen_ssa:: back:: write:: dump_incremental_data ( & codegen_results) ;
285283 }
286284
287- Ok ( ( Box :: new ( codegen_results) , work_products) )
285+ Ok ( ( codegen_results, work_products) )
288286 }
289287
290288 fn link (
291289 & self ,
292290 sess : & Session ,
293- codegen_results : Box < dyn Any > ,
291+ codegen_results : CodegenResults ,
294292 outputs : & OutputFilenames ,
295293 ) -> Result < ( ) , ErrorReported > {
296- let codegen_results = codegen_results
297- . downcast :: < CodegenResults > ( )
298- . expect ( "Expected CodegenResults, found Box<Any>" ) ;
299-
300- if sess. opts . debugging_opts . no_link {
301- // FIXME: use a binary format to encode the `.rlink` file
302- let rlink_data = json:: encode ( & codegen_results) . map_err ( |err| {
303- sess. fatal ( & format ! ( "failed to encode rlink: {}" , err) ) ;
304- } ) ?;
305- let rlink_file = outputs. with_extension ( config:: RLINK_EXT ) ;
306- fs:: write ( & rlink_file, rlink_data) . map_err ( |err| {
307- sess. fatal ( & format ! ( "failed to write file {}: {}" , rlink_file. display( ) , err) ) ;
308- } ) ?;
309- return Ok ( ( ) ) ;
310- }
311-
312294 // Run the linker on any artifacts that resulted from the LLVM run.
313295 // This should produce either a finished executable or library.
314296 sess. time ( "link_crate" , || {
0 commit comments