8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+
11
12
use back:: rpath;
12
13
use driver:: session;
13
14
use lib:: llvm:: llvm;
@@ -56,11 +57,13 @@ impl output_type : cmp::Eq {
56
57
pure fn ne ( & self , other : & output_type ) -> bool { !( * self ) . eq ( other) }
57
58
}
58
59
59
- fn llvm_err ( sess : Session , msg : ~str ) -> ! unsafe {
60
+ fn llvm_err ( sess : Session , + msg : ~str ) -> ! unsafe {
60
61
let cstr = llvm:: LLVMRustGetLastError ( ) ;
61
62
if cstr == ptr:: null ( ) {
62
63
sess. fatal ( msg) ;
63
- } else { sess. fatal ( msg + ~": " + str::raw::from_c_str(cstr)); }
64
+ } else {
65
+ sess. fatal ( msg + ~": " + str::raw::from_c_str(cstr));
66
+ }
64
67
}
65
68
66
69
fn WriteOutputFile(sess: Session,
@@ -147,7 +150,7 @@ pub mod jit {
147
150
} ;
148
151
let func: fn ( ++argv : ~[ ~str ] ) = cast:: transmute ( move closure) ;
149
152
150
- func ( ~[ sess. opts . binary ] ) ;
153
+ func ( ~[ /*bad*/ copy sess. opts . binary ] ) ;
151
154
}
152
155
}
153
156
}
@@ -177,7 +180,7 @@ mod write {
177
180
if sess. time_llvm_passes ( ) { llvm:: LLVMRustEnableTimePasses ( ) ; }
178
181
let mut pm = mk_pass_manager ( ) ;
179
182
let td = mk_target_data (
180
- sess. targ_cfg . target_strs . data_layout ) ;
183
+ /*bad*/ copy sess. targ_cfg . target_strs . data_layout ) ;
181
184
llvm:: LLVMAddTargetData ( td. lltd , pm. llpm ) ;
182
185
// FIXME (#2812): run the linter here also, once there are llvm-c
183
186
// bindings for it.
@@ -438,17 +441,19 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
438
441
let mut name: Option < ~str > = None ;
439
442
let mut vers: Option < ~str > = None ;
440
443
let mut cmh_items: ~[ @ast:: meta_item ] = ~[ ] ;
441
- let linkage_metas = attr:: find_linkage_metas ( c. node . attrs ) ;
442
- attr:: require_unique_names ( sess. diagnostic ( ) , linkage_metas) ;
444
+ let linkage_metas =
445
+ attr:: find_linkage_metas ( /*bad*/ copy c. node . attrs ) ;
446
+ // XXX: Bad copy.
447
+ attr:: require_unique_names ( sess. diagnostic ( ) , copy linkage_metas) ;
443
448
for linkage_metas. each |meta| {
444
449
if attr:: get_meta_item_name ( * meta) == ~"name" {
445
450
match attr:: get_meta_item_value_str ( * meta) {
446
- Some ( ref v) => { name = Some ( ( * v) ) ; }
451
+ Some ( ref v) => { name = Some ( ( /*bad*/ copy * v) ) ; }
447
452
None => cmh_items. push ( * meta)
448
453
}
449
454
} else if attr:: get_meta_item_name ( * meta) == ~"vers" {
450
455
match attr:: get_meta_item_value_str ( * meta) {
451
- Some ( ref v) => { vers = Some ( ( * v) ) ; }
456
+ Some ( ref v) => { vers = Some ( ( /*bad*/ copy * v) ) ; }
452
457
None => cmh_items. push ( * meta)
453
458
}
454
459
} else { cmh_items. push ( * meta) ; }
@@ -469,7 +474,7 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
469
474
return len_and_str ( pprust:: lit_to_str ( @l) ) ;
470
475
}
471
476
472
- let cmh_items = attr:: sort_meta_items ( metas. cmh_items ) ;
477
+ let cmh_items = attr:: sort_meta_items ( /*bad*/ copy metas. cmh_items ) ;
473
478
474
479
symbol_hasher. reset ( ) ;
475
480
for cmh_items. each |m| {
@@ -504,15 +509,16 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
504
509
fn crate_meta_name ( sess : Session , _crate : ast:: crate ,
505
510
output : & Path , metas : provided_metas ) -> ~str {
506
511
return match metas. name {
507
- Some ( ref v) => ( * v) ,
512
+ Some ( ref v) => ( /*bad*/ copy * v) ,
508
513
None => {
509
514
let name = match output. filestem ( ) {
510
515
None => sess. fatal ( fmt ! ( "output file name `%s` doesn't\
511
516
appear to have a stem",
512
517
output. to_str( ) ) ) ,
513
- Some ( ref s) => ( * s)
518
+ Some ( ref s) => ( /*bad*/ copy * s)
514
519
} ;
515
- warn_missing ( sess, ~"name", name) ;
520
+ // XXX: Bad copy.
521
+ warn_missing ( sess, ~"name", copy name) ;
516
522
name
517
523
}
518
524
} ;
@@ -521,10 +527,11 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
521
527
fn crate_meta_vers ( sess : Session , _crate : ast:: crate ,
522
528
metas : provided_metas ) -> ~str {
523
529
return match metas. vers {
524
- Some ( ref v) => ( * v) ,
530
+ Some ( ref v) => ( /*bad*/ copy * v) ,
525
531
None => {
526
532
let vers = ~"0.0 ";
527
- warn_missing ( sess, ~"vers", vers) ;
533
+ // Bad copy.
534
+ warn_missing ( sess, ~"vers", copy vers) ;
528
535
vers
529
536
}
530
537
} ;
@@ -565,10 +572,11 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
565
572
566
573
fn get_symbol_hash ( ccx : @crate_ctxt , t : ty:: t ) -> ~str {
567
574
match ccx. type_hashcodes . find ( t) {
568
- Some ( ref h) => return ( * h) ,
575
+ Some ( ref h) => return ( /*bad*/ copy * h) ,
569
576
None => {
570
577
let hash = symbol_hash ( ccx. tcx , ccx. symbol_hasher , t, ccx. link_meta ) ;
571
- ccx. type_hashcodes . insert ( t, hash) ;
578
+ // XXX: Bad copy. Prefer `@str`?
579
+ ccx. type_hashcodes . insert ( t, copy hash) ;
572
580
return hash;
573
581
}
574
582
}
@@ -625,21 +633,26 @@ fn mangle(sess: Session, ss: path) -> ~str {
625
633
n
626
634
}
627
635
628
- fn exported_name ( sess : Session , path : path , hash : ~str , vers : ~str ) -> ~str {
636
+ fn exported_name ( sess : Session ,
637
+ +path : path,
638
+ +hash : ~str ,
639
+ +vers : ~str ) -> ~str {
629
640
return mangle ( sess,
630
641
vec:: append_one (
631
642
vec:: append_one ( path, path_name ( sess. ident_of ( hash) ) ) ,
632
643
path_name ( sess. ident_of ( vers) ) ) ) ;
633
644
}
634
645
635
- fn mangle_exported_name ( ccx : @crate_ctxt , path : path , t : ty:: t ) -> ~str {
646
+ fn mangle_exported_name ( ccx : @crate_ctxt , + path : path, t : ty:: t ) -> ~str {
636
647
let hash = get_symbol_hash ( ccx, t) ;
637
- return exported_name ( ccx. sess , path, hash, ccx. link_meta . vers ) ;
648
+ return exported_name ( ccx. sess , path,
649
+ hash,
650
+ /*bad*/ copy ccx. link_meta . vers ) ;
638
651
}
639
652
640
653
fn mangle_internal_name_by_type_only ( ccx : @crate_ctxt ,
641
- t : ty:: t , name : ~ str ) ->
642
- ~str {
654
+ t : ty:: t ,
655
+ + name : ~ str ) -> ~str {
643
656
let s = ppaux:: ty_to_short_str ( ccx. tcx , t) ;
644
657
let hash = get_symbol_hash ( ccx, t) ;
645
658
return mangle ( ccx. sess ,
@@ -648,17 +661,18 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
648
661
path_name ( ccx. sess . ident_of ( hash) ) ] ) ;
649
662
}
650
663
651
- fn mangle_internal_name_by_path_and_seq ( ccx : @crate_ctxt , path : path ,
652
- flav : ~str ) -> ~str {
664
+ fn mangle_internal_name_by_path_and_seq ( ccx : @crate_ctxt ,
665
+ +path : path,
666
+ +flav : ~str ) -> ~str {
653
667
return mangle ( ccx. sess ,
654
668
vec:: append_one ( path, path_name ( ( ccx. names ) ( flav) ) ) ) ;
655
669
}
656
670
657
- fn mangle_internal_name_by_path ( ccx : @crate_ctxt , path : path ) -> ~str {
671
+ fn mangle_internal_name_by_path ( ccx : @crate_ctxt , + path : path) -> ~str {
658
672
return mangle ( ccx. sess , path) ;
659
673
}
660
674
661
- fn mangle_internal_name_by_seq ( ccx : @crate_ctxt , flav : ~str ) -> ~str {
675
+ fn mangle_internal_name_by_seq ( ccx : @crate_ctxt , + flav : ~str ) -> ~str {
662
676
return fmt ! ( "%s_%u" , flav, ( ccx. names) ( flav) . repr) ;
663
677
}
664
678
@@ -669,7 +683,7 @@ fn link_binary(sess: Session,
669
683
out_filename : & Path ,
670
684
lm : link_meta ) {
671
685
// Converts a library file-stem into a cc -l argument
672
- fn unlib ( config : @session:: config , stem : ~str ) -> ~str {
686
+ fn unlib ( config : @session:: config , + stem : ~str ) -> ~str {
673
687
if stem. starts_with ( "lib" ) &&
674
688
config. os != session:: os_win32 {
675
689
stem. slice ( 3 , stem. len ( ) )
@@ -689,7 +703,7 @@ fn link_binary(sess: Session,
689
703
690
704
out_filename. dir_path ( ) . push ( long_libname)
691
705
} else {
692
- * out_filename
706
+ /*bad*/ copy * out_filename
693
707
} ;
694
708
695
709
log ( debug, ~"output: " + output.to_str());
@@ -736,7 +750,7 @@ fn link_binary(sess: Session,
736
750
}
737
751
738
752
let ula = cstore:: get_used_link_args ( cstore) ;
739
- for ula. each |arg| { cc_args. push ( * arg) ; }
753
+ for ula. each |arg| { cc_args. push ( /*bad*/ copy * arg) ; }
740
754
741
755
// # Extern library linking
742
756
@@ -746,7 +760,7 @@ fn link_binary(sess: Session,
746
760
// to be found at compile time so it is still entirely up to outside
747
761
// forces to make sure that library can be found at runtime.
748
762
749
- let addl_paths = sess. opts . addl_lib_search_paths ;
763
+ let addl_paths = /*bad*/ copy sess. opts . addl_lib_search_paths ;
750
764
for addl_paths. each |path| { cc_args. push ( ~"-L " + path. to_str ( ) ) ; }
751
765
752
766
// The names of the extern libraries
0 commit comments