@@ -107,13 +107,10 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB
107107}
108108
109109pub fn remove ( sess : & Session , path : & Path ) {
110- match fs:: remove_file ( path) {
111- Ok ( ..) => { }
112- Err ( e) => {
113- sess. err ( & format ! ( "failed to remove {}: {}" ,
114- path. display( ) ,
115- e) ) ;
116- }
110+ if let Err ( e) = fs:: remove_file ( path) {
111+ sess. err ( & format ! ( "failed to remove {}: {}" ,
112+ path. display( ) ,
113+ e) ) ;
117114 }
118115}
119116
@@ -184,7 +181,7 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
184181 // the objects as they're losslessly contained inside the archives.
185182 let output_linked = sess. crate_types . borrow ( )
186183 . iter ( )
187- . any ( |x| * x != config:: CrateType :: Rlib && * x != config:: CrateType :: Staticlib ) ;
184+ . any ( |& x| x != config:: CrateType :: Rlib && x != config:: CrateType :: Staticlib ) ;
188185 if !output_linked {
189186 return false
190187 }
@@ -289,24 +286,19 @@ fn link_binary_output(sess: &Session,
289286 // final destination, with a `fs::rename` call. In order for the rename to
290287 // always succeed, the temporary file needs to be on the same filesystem,
291288 // which is why we create it inside the output directory specifically.
292- let metadata_tmpdir = match TempFileBuilder :: new ( )
289+ let metadata_tmpdir = TempFileBuilder :: new ( )
293290 . prefix ( "rmeta" )
294291 . tempdir_in ( out_filename. parent ( ) . unwrap ( ) )
295- {
296- Ok ( tmpdir) => tmpdir,
297- Err ( err) => sess. fatal ( & format ! ( "couldn't create a temp dir: {}" , err) ) ,
298- } ;
292+ . unwrap_or_else ( |err| sess. fatal ( & format ! ( "couldn't create a temp dir: {}" , err) ) ) ;
299293 let metadata = emit_metadata ( sess, codegen_results, & metadata_tmpdir) ;
300294 if let Err ( e) = fs:: rename ( metadata, & out_filename) {
301295 sess. fatal ( & format ! ( "failed to write {}: {}" , out_filename. display( ) , e) ) ;
302296 }
303297 out_filenames. push ( out_filename) ;
304298 }
305299
306- let tmpdir = match TempFileBuilder :: new ( ) . prefix ( "rustc" ) . tempdir ( ) {
307- Ok ( tmpdir) => tmpdir,
308- Err ( err) => sess. fatal ( & format ! ( "couldn't create a temp dir: {}" , err) ) ,
309- } ;
300+ let tmpdir = TempFileBuilder :: new ( ) . prefix ( "rustc" ) . tempdir ( ) . unwrap_or_else ( |err|
301+ sess. fatal ( & format ! ( "couldn't create a temp dir: {}" , err) ) ) ;
310302
311303 if outputs. outputs . should_codegen ( ) {
312304 let out_filename = out_filename ( sess, crate_type, outputs, crate_name) ;
@@ -869,9 +861,8 @@ fn link_natively(sess: &Session,
869861 sess. opts . debuginfo != DebugInfo :: None &&
870862 !preserve_objects_for_their_debuginfo ( sess)
871863 {
872- match Command :: new ( "dsymutil" ) . arg ( out_filename) . output ( ) {
873- Ok ( ..) => { }
874- Err ( e) => sess. fatal ( & format ! ( "failed to run dsymutil: {}" , e) ) ,
864+ if let Err ( e) = Command :: new ( "dsymutil" ) . arg ( out_filename) . output ( ) {
865+ sess. fatal ( & format ! ( "failed to run dsymutil: {}" , e) )
875866 }
876867 }
877868
0 commit comments