@@ -129,14 +129,12 @@ pub mod jit {
129129
130130 debug ! ( "linking: %s" , path) ;
131131
132- let _: ( ) = str:: as_c_str (
133- path,
134- |buf_t| {
135- if !llvm:: LLVMRustLoadCrate ( manager, buf_t) {
136- llvm_err ( sess, ~"Could not link") ;
137- }
138- debug ! ( "linked: %s" , path) ;
139- } ) ;
132+ do str:: as_c_str ( path) |buf_t| {
133+ if !llvm:: LLVMRustLoadCrate ( manager, buf_t) {
134+ llvm_err ( sess, ~"Could not link") ;
135+ }
136+ debug ! ( "linked: %s" , path) ;
137+ }
140138 }
141139
142140 // We custom-build a JIT execution engine via some rust wrappers
@@ -203,11 +201,10 @@ pub mod write {
203201 use core:: str;
204202
205203 pub fn is_object_or_assembly_or_exe ( ot : output_type ) -> bool {
206- if ot == output_type_assembly || ot == output_type_object ||
207- ot == output_type_exe {
208- return true ;
204+ match ot {
205+ output_type_assembly | output_type_object | output_type_exe => true ,
206+ _ => false
209207 }
210- return false ;
211208 }
212209
213210 pub fn run_passes ( sess : Session ,
@@ -290,11 +287,11 @@ pub mod write {
290287 session:: Aggressive => LLVMOptAggressive
291288 } ;
292289
293- let FileType ;
294- if output_type == output_type_object ||
295- output_type == output_type_exe {
296- FileType = lib :: llvm :: ObjectFile ;
297- } else { FileType = lib :: llvm :: AssemblyFile ; }
290+ let FileType = match output_type {
291+ output_type_object | output_type_exe => lib :: llvm :: ObjectFile ,
292+ _ => lib :: llvm :: AssemblyFile
293+ } ;
294+
298295 // Write optimized bitcode if --save-temps was on.
299296
300297 if opts. save_temps {
@@ -384,11 +381,11 @@ pub mod write {
384381 (--android-cross-path)")
385382 }
386383 } ;
387- let mut cc_args = ~ [ ] ;
388- cc_args. push ( ~"- c");
389- cc_args.push( ~" -o" ) ;
390- cc_args . push ( object. to_str ( ) ) ;
391- cc_args . push ( assembly. to_str ( ) ) ;
384+
385+ let cc_args = ~ [
386+ ~"-c",
387+ ~" -o" , object. to_str ( ) ,
388+ assembly. to_str ( ) ] ;
392389
393390 let prog = run:: process_output ( cc_prog, cc_args) ;
394391
@@ -474,19 +471,19 @@ pub fn build_link_meta(sess: Session,
474471 let linkage_metas = attr:: find_linkage_metas ( c. node . attrs ) ;
475472 attr:: require_unique_names ( sess. diagnostic ( ) , linkage_metas) ;
476473 for linkage_metas. each |meta| {
477- if "name" == attr:: get_meta_item_name ( * meta) {
478- match attr :: get_meta_item_value_str ( * meta ) {
479- // Changing attr would avoid the need for the copy
480- // here
481- Some ( v ) => { name = Some ( v ) ; }
482- None => cmh_items . push ( * meta )
483- }
484- } else if "vers" == attr :: get_meta_item_name ( * meta ) {
485- match attr :: get_meta_item_value_str ( * meta) {
486- Some ( v ) => { vers = Some ( v ) ; }
487- None => cmh_items . push ( * meta )
488- }
489- } else { cmh_items . push ( * meta ) ; }
474+ match attr:: get_meta_item_value_str ( * meta) {
475+ Some ( value ) => {
476+ let item_name : & str = attr :: get_meta_item_name ( * meta ) ;
477+ match item_name {
478+ // Changing attr would avoid the need for the copy
479+ // here
480+ "name" => name = Some ( value ) ,
481+ "vers" => vers = Some ( value ) ,
482+ _ => cmh_items . push ( * meta)
483+ }
484+ } ,
485+ None => cmh_items . push ( * meta )
486+ }
490487 }
491488
492489 ProvidedMetas {
@@ -548,32 +545,32 @@ pub fn build_link_meta(sess: Session,
548545 }
549546
550547 fn crate_meta_name ( sess : Session , output : & Path , opt_name : Option < @str > )
551- -> @str {
552- return match opt_name {
553- Some ( v) => v,
554- None => {
548+ -> @str {
549+ match opt_name {
550+ Some ( v) => v,
551+ None => {
555552 // to_managed could go away if there was a version of
556553 // filestem that returned an @str
557554 let name = session:: expect ( sess,
558- output. filestem ( ) ,
559- || fmt ! ( "output file name `%s` doesn't\
560- appear to have a stem",
561- output. to_str( ) ) ) . to_managed ( ) ;
555+ output. filestem ( ) ,
556+ || fmt ! ( "output file name `%s` doesn't\
557+ appear to have a stem",
558+ output. to_str( ) ) ) . to_managed ( ) ;
562559 warn_missing ( sess, "name" , name) ;
563560 name
564- }
565- } ;
561+ }
562+ }
566563 }
567564
568565 fn crate_meta_vers ( sess : Session , opt_vers : Option < @str > ) -> @str {
569- return match opt_vers {
570- Some ( v) => v,
571- None => {
566+ match opt_vers {
567+ Some ( v) => v,
568+ None => {
572569 let vers = @"0.0 ";
573570 warn_missing ( sess, "vers" , vers) ;
574571 vers
575- }
576- } ;
572+ }
573+ }
577574 }
578575
579576 let ProvidedMetas {
@@ -699,10 +696,10 @@ pub fn exported_name(sess: Session,
699696 path : path ,
700697 hash : & str ,
701698 vers : & str ) -> ~str {
702- return mangle ( sess,
703- vec:: append_one (
704- vec:: append_one ( path, path_name ( sess. ident_of ( hash) ) ) ,
705- path_name ( sess. ident_of ( vers) ) ) ) ;
699+ mangle ( sess,
700+ vec:: append_one (
701+ vec:: append_one ( path, path_name ( sess. ident_of ( hash) ) ) ,
702+ path_name ( sess. ident_of ( vers) ) ) )
706703}
707704
708705pub fn mangle_exported_name ( ccx : & mut CrateContext ,
@@ -739,16 +736,16 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &mut CrateContext,
739736pub fn mangle_internal_name_by_path_and_seq ( ccx : & mut CrateContext ,
740737 path : path ,
741738 flav : & str ) -> ~str {
742- return mangle ( ccx. sess ,
743- vec:: append_one ( path, path_name ( ( ccx. names ) ( flav) ) ) ) ;
739+ mangle ( ccx. sess ,
740+ vec:: append_one ( path, path_name ( ( ccx. names ) ( flav) ) ) )
744741}
745742
746743pub fn mangle_internal_name_by_path ( ccx : & mut CrateContext , path : path ) -> ~str {
747- return mangle ( ccx. sess , path) ;
744+ mangle ( ccx. sess , path)
748745}
749746
750747pub fn mangle_internal_name_by_seq ( ccx : & mut CrateContext , flav : & str ) -> ~str {
751- return fmt ! ( "%s_%u" , flav, ( ccx. names) ( flav) . name) ;
748+ fmt ! ( "%s_%u" , flav, ( ccx. names) ( flav) . name)
752749}
753750
754751
@@ -776,8 +773,8 @@ pub fn link_binary(sess: Session,
776773 // so we add a condition to make it use gcc.
777774 let cc_prog: ~str = match sess. opts . linker {
778775 Some ( ref linker) => copy * linker,
779- None => {
780- if sess . targ_cfg . os == session:: os_android {
776+ None => match sess . targ_cfg . os {
777+ session:: os_android =>
781778 match & sess. opts . android_cross_path {
782779 & Some ( ref path) => {
783780 fmt ! ( "%s/bin/arm-linux-androideabi-gcc" , * path)
@@ -786,12 +783,9 @@ pub fn link_binary(sess: Session,
786783 sess. fatal ( "need Android NDK path for linking \
787784 (--android-cross-path)")
788785 }
789- }
790- } else if sess. targ_cfg . os == session:: os_win32 {
791- ~"gcc"
792- } else {
793- ~"cc"
794- }
786+ } ,
787+ session:: os_win32 => ~"gcc",
788+ _ => ~"cc"
795789 }
796790 } ;
797791 // The invocations of cc share some flags across platforms
@@ -866,17 +860,14 @@ pub fn link_args(sess: Session,
866860
867861 let mut args = vec:: append ( ~[ stage] , sess. targ_cfg . target_strs . cc_args ) ;
868862
869- args. push ( ~"-o" ) ;
870- args . push ( output. to_str ( ) ) ;
871- args . push ( obj_filename. to_str ( ) ) ;
863+ args. push_all ( [
864+ ~"-o" , output. to_str ( ) ,
865+ obj_filename. to_str ( ) ] ) ;
872866
873- let lib_cmd;
874- let os = sess. targ_cfg . os ;
875- if os == session:: os_macos {
876- lib_cmd = ~"-dynamiclib";
877- } else {
878- lib_cmd = ~"-shared";
879- }
867+ let lib_cmd = match sess. targ_cfg . os {
868+ session:: os_macos => ~"-dynamiclib",
869+ _ => ~"-shared"
870+ } ;
880871
881872 // # Crate linking
882873
0 commit comments