@@ -824,56 +824,30 @@ fn trans_def_datum_unadjusted(bcx: @mut Block,
824824{
825825 let _icx = push_ctxt ( "trans_def_datum_unadjusted" ) ;
826826
827- match def {
827+ let fn_data = match def {
828828 ast:: def_fn( did, _) | ast:: def_static_method( did, None , _) => {
829- let fn_data = callee:: trans_fn_ref ( bcx, did, ref_expr. id ) ;
830- return fn_data_to_datum ( bcx, ref_expr, did, fn_data) ;
829+ callee:: trans_fn_ref ( bcx, did, ref_expr. id )
831830 }
832831 ast:: def_static_method( impl_did, Some ( trait_did) , _) => {
833- let fn_data = meth:: trans_static_method_callee ( bcx, impl_did,
834- trait_did,
835- ref_expr. id ) ;
836- return fn_data_to_datum ( bcx, ref_expr, impl_did, fn_data) ;
832+ meth:: trans_static_method_callee ( bcx, impl_did,
833+ trait_did,
834+ ref_expr. id )
837835 }
838836 _ => {
839837 bcx. tcx ( ) . sess . span_bug ( ref_expr. span , fmt ! (
840838 "Non-DPS def %? referened by %s" ,
841839 def, bcx. node_id_to_str( ref_expr. id) ) ) ;
842840 }
843- }
841+ } ;
844842
845- fn fn_data_to_datum ( bcx : @mut Block ,
846- ref_expr : & ast:: expr ,
847- def_id : ast:: def_id ,
848- fn_data : callee:: FnData ) -> DatumBlock {
849- /*!
850- *
851- * Translates a reference to a top-level fn item into a rust
852- * value. This is just a fn pointer.
853- */
854-
855- let is_extern = {
856- let fn_tpt = ty:: lookup_item_type ( bcx. tcx ( ) , def_id) ;
857- ty:: ty_fn_purity ( fn_tpt. ty ) == ast:: extern_fn
858- } ;
859- let ( rust_ty, llval) = if is_extern {
860- let rust_ty = ty:: mk_ptr (
861- bcx. tcx ( ) ,
862- ty:: mt {
863- ty : ty:: mk_mach_uint ( ast:: ty_u8) ,
864- mutbl : ast:: m_imm
865- } ) ; // *u8
866- ( rust_ty, PointerCast ( bcx, fn_data. llfn , Type :: i8p ( ) ) )
867- } else {
868- let fn_ty = expr_ty ( bcx, ref_expr) ;
869- ( fn_ty, fn_data. llfn )
870- } ;
871- return DatumBlock {
872- bcx : bcx,
873- datum : Datum { val : llval,
874- ty : rust_ty,
875- mode : ByValue }
876- } ;
843+ let fn_ty = expr_ty ( bcx, ref_expr) ;
844+ DatumBlock {
845+ bcx : bcx,
846+ datum : Datum {
847+ val : fn_data. llfn ,
848+ ty : fn_ty,
849+ mode : ByValue
850+ }
877851 }
878852}
879853
@@ -1657,6 +1631,7 @@ pub fn cast_type_kind(t: ty::t) -> cast_kind {
16571631 ty:: ty_float( * ) => cast_float,
16581632 ty:: ty_ptr( * ) => cast_pointer,
16591633 ty:: ty_rptr( * ) => cast_pointer,
1634+ ty:: ty_bare_fn( * ) => cast_pointer,
16601635 ty:: ty_int( * ) => cast_integral,
16611636 ty:: ty_uint( * ) => cast_integral,
16621637 ty:: ty_bool => cast_integral,
@@ -1719,10 +1694,16 @@ fn trans_imm_cast(bcx: @mut Block, expr: @ast::expr,
17191694 val_ty ( lldiscrim_a) ,
17201695 lldiscrim_a, true ) ,
17211696 cast_float => SIToFP ( bcx, lldiscrim_a, ll_t_out) ,
1722- _ => ccx. sess . bug ( "translating unsupported cast." )
1697+ _ => ccx. sess . bug ( fmt ! ( "translating unsupported cast: \
1698+ %s (%?) -> %s (%?)",
1699+ t_in. repr( ccx. tcx) , k_in,
1700+ t_out. repr( ccx. tcx) , k_out) )
17231701 }
17241702 }
1725- _ => ccx. sess . bug ( "translating unsupported cast." )
1703+ _ => ccx. sess . bug ( fmt ! ( "translating unsupported cast: \
1704+ %s (%?) -> %s (%?)",
1705+ t_in. repr( ccx. tcx) , k_in,
1706+ t_out. repr( ccx. tcx) , k_out) )
17261707 } ;
17271708 return immediate_rvalue_bcx ( bcx, newval, t_out) ;
17281709}
0 commit comments