@@ -19,7 +19,7 @@ use trans::base::*;
19
19
use trans:: build:: * ;
20
20
use trans:: cleanup:: { CleanupMethods , ScopeId } ;
21
21
use trans:: common:: * ;
22
- use trans:: datum:: { Datum , DatumBlock , Expr , Lvalue , rvalue_scratch_datum} ;
22
+ use trans:: datum:: { Datum , Lvalue , rvalue_scratch_datum} ;
23
23
use trans:: datum:: { Rvalue , ByValue } ;
24
24
use trans:: debuginfo;
25
25
use trans:: expr;
@@ -29,10 +29,8 @@ use trans::type_::Type;
29
29
use middle:: ty:: { self , Ty , UnboxedClosureTyper } ;
30
30
use middle:: subst:: { Substs } ;
31
31
use session:: config:: FullDebugInfo ;
32
- use util:: ppaux:: Repr ;
33
32
use util:: ppaux:: ty_to_string;
34
33
35
- use arena:: TypedArena ;
36
34
use syntax:: ast;
37
35
use syntax:: ast_util;
38
36
@@ -581,97 +579,3 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
581
579
582
580
bcx
583
581
}
584
-
585
- pub fn get_wrapper_for_bare_fn < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
586
- closure_ty : Ty < ' tcx > ,
587
- def_id : ast:: DefId ,
588
- fn_ptr : ValueRef ,
589
- is_local : bool ) -> ValueRef {
590
-
591
- match ccx. closure_bare_wrapper_cache ( ) . borrow ( ) . get ( & fn_ptr) {
592
- Some ( & llval) => return llval,
593
- None => { }
594
- }
595
-
596
- let tcx = ccx. tcx ( ) ;
597
-
598
- debug ! ( "get_wrapper_for_bare_fn(closure_ty={})" , closure_ty. repr( tcx) ) ;
599
-
600
- let f = match closure_ty. sty {
601
- _ => {
602
- ccx. sess ( ) . bug ( format ! ( "get_wrapper_for_bare_fn: \
603
- expected a closure ty, got {}",
604
- closure_ty. repr( tcx) ) [ ] ) ;
605
- }
606
- } ;
607
-
608
- let name = ty:: with_path ( tcx, def_id, |path| {
609
- mangle_internal_name_by_path_and_seq ( path, "as_closure" )
610
- } ) ;
611
- let llfn = if is_local {
612
- decl_internal_rust_fn ( ccx, closure_ty, name[ ] )
613
- } else {
614
- decl_rust_fn ( ccx, closure_ty, name[ ] )
615
- } ;
616
-
617
- ccx. closure_bare_wrapper_cache ( ) . borrow_mut ( ) . insert ( fn_ptr, llfn) ;
618
-
619
- // This is only used by statics inlined from a different crate.
620
- if !is_local {
621
- // Don't regenerate the wrapper, just reuse the original one.
622
- return llfn;
623
- }
624
-
625
- let _icx = push_ctxt ( "closure::get_wrapper_for_bare_fn" ) ;
626
-
627
- let arena = TypedArena :: new ( ) ;
628
- let empty_param_substs = Substs :: trans_empty ( ) ;
629
- let fcx = new_fn_ctxt ( ccx, llfn, ast:: DUMMY_NODE_ID , true , f. sig . 0 . output ,
630
- & empty_param_substs, None , & arena) ;
631
- let bcx = init_function ( & fcx, true , f. sig . 0 . output ) ;
632
-
633
- let args = create_datums_for_fn_args ( & fcx,
634
- ty:: ty_fn_args ( closure_ty)
635
- [ ] ) ;
636
- let mut llargs = Vec :: new ( ) ;
637
- match fcx. llretslotptr . get ( ) {
638
- Some ( llretptr) => {
639
- assert ! ( !fcx. needs_ret_allocas) ;
640
- llargs. push ( llretptr) ;
641
- }
642
- None => { }
643
- }
644
- llargs. extend ( args. iter ( ) . map ( |arg| arg. val ) ) ;
645
-
646
- let retval = Call ( bcx, fn_ptr, llargs. as_slice ( ) , None ) ;
647
- match f. sig . 0 . output {
648
- ty:: FnConverging ( output_type) => {
649
- if return_type_is_void ( ccx, output_type) || fcx. llretslotptr . get ( ) . is_some ( ) {
650
- RetVoid ( bcx) ;
651
- } else {
652
- Ret ( bcx, retval) ;
653
- }
654
- }
655
- ty:: FnDiverging => {
656
- RetVoid ( bcx) ;
657
- }
658
- }
659
-
660
- // HACK(eddyb) finish_fn cannot be used here, we returned directly.
661
- debuginfo:: clear_source_location ( & fcx) ;
662
- fcx. cleanup ( ) ;
663
-
664
- llfn
665
- }
666
-
667
- pub fn make_closure_from_bare_fn < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
668
- closure_ty : Ty < ' tcx > ,
669
- def_id : ast:: DefId ,
670
- fn_ptr : ValueRef )
671
- -> DatumBlock < ' blk , ' tcx , Expr > {
672
- let scratch = rvalue_scratch_datum ( bcx, closure_ty, "__adjust" ) ;
673
- let wrapper = get_wrapper_for_bare_fn ( bcx. ccx ( ) , closure_ty, def_id, fn_ptr, true ) ;
674
- fill_fn_pair ( bcx, scratch. val , wrapper, C_null ( Type :: i8p ( bcx. ccx ( ) ) ) ) ;
675
-
676
- DatumBlock :: new ( bcx, scratch. to_expr_datum ( ) )
677
- }
0 commit comments