@@ -495,7 +495,7 @@ pub fn stop_after_phase_5(sess: &Session) -> bool {
495495fn write_out_deps ( sess : & Session ,
496496 input : & Input ,
497497 outputs : & OutputFilenames ,
498- krate : & ast:: Crate ) -> io :: IoResult < ( ) > {
498+ krate : & ast:: Crate ) {
499499 let id = link:: find_crate_id ( krate. attrs . as_slice ( ) , outputs. out_filestem ) ;
500500
501501 let mut out_filenames = Vec :: new ( ) ;
@@ -524,28 +524,34 @@ fn write_out_deps(sess: &Session,
524524 StrInput ( ..) => {
525525 sess. warn ( "can not write --dep-info without a filename \
526526 when compiling stdin.") ;
527- return Ok ( ( ) ) ;
527+ return
528528 } ,
529529 } ,
530- _ => return Ok ( ( ) ) ,
530+ _ => return ,
531531 } ;
532532
533- // Build a list of files used to compile the output and
534- // write Makefile-compatible dependency rules
535- let files: Vec < ~str > = sess. codemap ( ) . files . borrow ( )
536- . iter ( ) . filter_map ( |fmap| {
537- if fmap. is_real_file ( ) {
538- Some ( fmap. name . clone ( ) )
539- } else {
540- None
541- }
542- } ) . collect ( ) ;
543- let mut file = try!( io:: File :: create ( & deps_filename) ) ;
544- for path in out_filenames. iter ( ) {
545- try!( write ! ( & mut file as & mut Writer ,
546- "{}: {}\n \n " , path. display( ) , files. connect( " " ) ) ) ;
533+ let result = ( || {
534+ // Build a list of files used to compile the output and
535+ // write Makefile-compatible dependency rules
536+ let files: Vec < ~str > = sess. codemap ( ) . files . borrow ( )
537+ . iter ( ) . filter ( |fmap| fmap. is_real_file ( ) )
538+ . map ( |fmap| fmap. name . clone ( ) )
539+ . collect ( ) ;
540+ let mut file = try!( io:: File :: create ( & deps_filename) ) ;
541+ for path in out_filenames. iter ( ) {
542+ try!( write ! ( & mut file as & mut Writer ,
543+ "{}: {}\n \n " , path. display( ) , files. connect( " " ) ) ) ;
544+ }
545+ Ok ( ( ) )
546+ } ) ( ) ;
547+
548+ match result {
549+ Ok ( ( ) ) => { }
550+ Err ( e) => {
551+ sess. fatal ( format ! ( "error writing dependencies to `{}`: {}" ,
552+ deps_filename. display( ) , e) ) ;
553+ }
547554 }
548- Ok ( ( ) )
549555}
550556
551557pub fn compile_input ( sess : Session , cfg : ast:: CrateConfig , input : & Input ,
@@ -569,7 +575,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
569575 krate, & id) ;
570576 ( outputs, expanded_crate, ast_map)
571577 } ;
572- write_out_deps ( & sess, input, & outputs, & expanded_crate) . unwrap ( ) ;
578+ write_out_deps ( & sess, input, & outputs, & expanded_crate) ;
573579
574580 if stop_after_phase_2 ( & sess) { return ; }
575581
0 commit comments