@@ -129,14 +129,12 @@ pub mod jit {
129
129
130
130
debug ! ( "linking: %s" , path) ;
131
131
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
+ }
140
138
}
141
139
142
140
// We custom-build a JIT execution engine via some rust wrappers
@@ -203,11 +201,10 @@ pub mod write {
203
201
use core:: str;
204
202
205
203
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
209
207
}
210
- return false ;
211
208
}
212
209
213
210
pub fn run_passes ( sess : Session ,
@@ -290,11 +287,11 @@ pub mod write {
290
287
session:: Aggressive => LLVMOptAggressive
291
288
} ;
292
289
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
+
298
295
// Write optimized bitcode if --save-temps was on.
299
296
300
297
if opts. save_temps {
@@ -384,11 +381,11 @@ pub mod write {
384
381
(--android-cross-path)")
385
382
}
386
383
} ;
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 ( ) ] ;
392
389
393
390
let prog = run:: process_output ( cc_prog, cc_args) ;
394
391
@@ -474,19 +471,19 @@ pub fn build_link_meta(sess: Session,
474
471
let linkage_metas = attr:: find_linkage_metas ( c. node . attrs ) ;
475
472
attr:: require_unique_names ( sess. diagnostic ( ) , linkage_metas) ;
476
473
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
+ }
490
487
}
491
488
492
489
ProvidedMetas {
@@ -548,32 +545,32 @@ pub fn build_link_meta(sess: Session,
548
545
}
549
546
550
547
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 => {
555
552
// to_managed could go away if there was a version of
556
553
// filestem that returned an @str
557
554
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 ( ) ;
562
559
warn_missing ( sess, "name" , name) ;
563
560
name
564
- }
565
- } ;
561
+ }
562
+ }
566
563
}
567
564
568
565
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 => {
572
569
let vers = @"0.0 ";
573
570
warn_missing ( sess, "vers" , vers) ;
574
571
vers
575
- }
576
- } ;
572
+ }
573
+ }
577
574
}
578
575
579
576
let ProvidedMetas {
@@ -699,10 +696,10 @@ pub fn exported_name(sess: Session,
699
696
path : path ,
700
697
hash : & str ,
701
698
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) ) ) )
706
703
}
707
704
708
705
pub fn mangle_exported_name ( ccx : & mut CrateContext ,
@@ -739,16 +736,16 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &mut CrateContext,
739
736
pub fn mangle_internal_name_by_path_and_seq ( ccx : & mut CrateContext ,
740
737
path : path ,
741
738
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) ) ) )
744
741
}
745
742
746
743
pub fn mangle_internal_name_by_path ( ccx : & mut CrateContext , path : path ) -> ~str {
747
- return mangle ( ccx. sess , path) ;
744
+ mangle ( ccx. sess , path)
748
745
}
749
746
750
747
pub 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)
752
749
}
753
750
754
751
@@ -776,8 +773,8 @@ pub fn link_binary(sess: Session,
776
773
// so we add a condition to make it use gcc.
777
774
let cc_prog: ~str = match sess. opts . linker {
778
775
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 =>
781
778
match & sess. opts . android_cross_path {
782
779
& Some ( ref path) => {
783
780
fmt ! ( "%s/bin/arm-linux-androideabi-gcc" , * path)
@@ -786,12 +783,9 @@ pub fn link_binary(sess: Session,
786
783
sess. fatal ( "need Android NDK path for linking \
787
784
(--android-cross-path)")
788
785
}
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"
795
789
}
796
790
} ;
797
791
// The invocations of cc share some flags across platforms
@@ -866,17 +860,14 @@ pub fn link_args(sess: Session,
866
860
867
861
let mut args = vec:: append ( ~[ stage] , sess. targ_cfg . target_strs . cc_args ) ;
868
862
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 ( ) ] ) ;
872
866
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
+ } ;
880
871
881
872
// # Crate linking
882
873
0 commit comments