@@ -13,15 +13,12 @@ use back::abi;
1313use back:: link:: { mangle_internal_name_by_path_and_seq} ;
1414use lib:: llvm:: { llvm, ValueRef } ;
1515use middle:: moves;
16- use middle:: lang_items:: ClosureExchangeMallocFnLangItem ;
1716use middle:: trans:: base:: * ;
1817use middle:: trans:: build:: * ;
19- use middle:: trans:: callee;
2018use middle:: trans:: common:: * ;
2119use middle:: trans:: datum:: { Datum , INIT , ByRef , ZeroMem } ;
2220use middle:: trans:: expr;
2321use middle:: trans:: glue;
24- use middle:: trans:: machine;
2522use middle:: trans:: type_of:: * ;
2623use middle:: ty;
2724use util:: ppaux:: ty_to_str;
@@ -508,52 +505,9 @@ pub fn make_opaque_cbox_take_glue(
508505 return bcx;
509506 }
510507 ast:: OwnedSigil => {
511- /* hard case: fallthrough to code below */
508+ fail! ( "unique closures are not copyable" )
512509 }
513510 }
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- }
557511}
558512
559513pub fn make_opaque_cbox_drop_glue(
0 commit comments