@@ -13,15 +13,12 @@ use back::abi;
13
13
use back:: link:: { mangle_internal_name_by_path_and_seq} ;
14
14
use lib:: llvm:: { llvm, ValueRef } ;
15
15
use middle:: moves;
16
- use middle:: lang_items:: ClosureExchangeMallocFnLangItem ;
17
16
use middle:: trans:: base:: * ;
18
17
use middle:: trans:: build:: * ;
19
- use middle:: trans:: callee;
20
18
use middle:: trans:: common:: * ;
21
19
use middle:: trans:: datum:: { Datum , INIT , ByRef , ZeroMem } ;
22
20
use middle:: trans:: expr;
23
21
use middle:: trans:: glue;
24
- use middle:: trans:: machine;
25
22
use middle:: trans:: type_of:: * ;
26
23
use middle:: ty;
27
24
use util:: ppaux:: ty_to_str;
@@ -508,52 +505,9 @@ pub fn make_opaque_cbox_take_glue(
508
505
return bcx;
509
506
}
510
507
ast:: OwnedSigil => {
511
- /* hard case: fallthrough to code below */
508
+ fail! ( "unique closures are not copyable" )
512
509
}
513
510
}
514
-
515
- // ~fn requires a deep copy.
516
- let ccx = bcx. ccx( ) ;
517
- let tcx = ccx. tcx;
518
- let llopaquecboxty = Type :: opaque_box( ccx) . ptr_to( ) ;
519
- let cbox_in = Load ( bcx, cboxptr) ;
520
- do with_cond( bcx, IsNotNull ( bcx, cbox_in) ) |bcx| {
521
- // Load the size from the type descr found in the cbox
522
- let cbox_in = PointerCast ( bcx, cbox_in, llopaquecboxty) ;
523
- let tydescptr = GEPi ( bcx, cbox_in, [ 0 u, abi:: box_field_tydesc] ) ;
524
- let tydesc = Load ( bcx, tydescptr) ;
525
- let tydesc = PointerCast ( bcx, tydesc, ccx. tydesc_type. ptr_to( ) ) ;
526
- let sz = Load ( bcx, GEPi ( bcx, tydesc, [ 0 u, abi:: tydesc_field_size] ) ) ;
527
-
528
- // Adjust sz to account for the rust_opaque_box header fields
529
- let sz = Add ( bcx, sz, machine:: llsize_of( ccx, Type :: box_header( ccx) ) ) ;
530
-
531
- // Allocate memory, update original ptr, and copy existing data
532
- let opaque_tydesc = PointerCast ( bcx, tydesc, Type :: i8p( ) ) ;
533
- let mut bcx = bcx;
534
- let alloc_fn = langcall( bcx, None ,
535
- fmt!( "allocation of type with sigil `%s`",
536
- sigil. to_str( ) ) ,
537
- ClosureExchangeMallocFnLangItem ) ;
538
- let llresult = unpack_result!( bcx, callee:: trans_lang_call(
539
- bcx,
540
- alloc_fn,
541
- [ opaque_tydesc, sz] ,
542
- None ) ) ;
543
- let cbox_out = PointerCast ( bcx, llresult, llopaquecboxty) ;
544
- call_memcpy( bcx, cbox_out, cbox_in, sz, 1 ) ;
545
- Store ( bcx, cbox_out, cboxptr) ;
546
-
547
- // Take the (deeply cloned) type descriptor
548
- let tydesc_out = GEPi ( bcx, cbox_out, [ 0 u, abi:: box_field_tydesc] ) ;
549
- let bcx = glue:: take_ty( bcx, tydesc_out, ty:: mk_type( tcx) ) ;
550
-
551
- // Take the data in the tuple
552
- let cdata_out = GEPi ( bcx, cbox_out, [ 0 u, abi:: box_field_body] ) ;
553
- glue:: call_tydesc_glue_full( bcx, cdata_out, tydesc,
554
- abi:: tydesc_field_take_glue, None ) ;
555
- bcx
556
- }
557
511
}
558
512
559
513
pub fn make_opaque_cbox_drop_glue(
0 commit comments