@@ -22,7 +22,8 @@ use rustc::ty::layout::{self, LayoutTyper};
2222use rustc:: ty:: cast:: { CastTy , IntTy } ;
2323use rustc:: ty:: subst:: { Kind , Substs , Subst } ;
2424use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
25- use { abi, adt, base, machine} ;
25+ use { adt, base, machine} ;
26+ use abi:: { self , Abi } ;
2627use callee;
2728use builder:: Builder ;
2829use common:: { self , CrateContext , const_get_elt, val_ty} ;
@@ -339,17 +340,34 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
339340 func, fn_ty)
340341 } ;
341342
342- let mut const_args = IndexVec :: with_capacity ( args. len ( ) ) ;
343+ let mut arg_vals = IndexVec :: with_capacity ( args. len ( ) ) ;
343344 for arg in args {
344345 match self . const_operand ( arg, span) {
345- Ok ( arg) => { const_args . push ( arg) ; } ,
346+ Ok ( arg) => { arg_vals . push ( arg) ; } ,
346347 Err ( err) => if failure. is_ok ( ) { failure = Err ( err) ; }
347348 }
348349 }
349350 if let Some ( ( ref dest, target) ) = * destination {
350- match MirConstContext :: trans_def ( self . ccx , def_id, substs, const_args) {
351- Ok ( value) => self . store ( dest, value, span) ,
352- Err ( err) => if failure. is_ok ( ) { failure = Err ( err) ; }
351+ if fn_ty. fn_sig ( tcx) . abi ( ) == Abi :: RustIntrinsic {
352+ let value = match & tcx. item_name ( def_id) . as_str ( ) [ ..] {
353+ "size_of" => {
354+ let llval = C_uint ( self . ccx ,
355+ self . ccx . size_of ( substs. type_at ( 0 ) ) ) ;
356+ Const :: new ( llval, tcx. types . usize )
357+ }
358+ "min_align_of" => {
359+ let llval = C_uint ( self . ccx ,
360+ self . ccx . align_of ( substs. type_at ( 0 ) ) ) ;
361+ Const :: new ( llval, tcx. types . usize )
362+ }
363+ _ => span_bug ! ( span, "{:?} in constant" , terminator. kind)
364+ } ;
365+ self . store ( dest, value, span) ;
366+ } else {
367+ match MirConstContext :: trans_def ( self . ccx , def_id, substs, arg_vals) {
368+ Ok ( value) => self . store ( dest, value, span) ,
369+ Err ( err) => if failure. is_ok ( ) { failure = Err ( err) ; }
370+ }
353371 }
354372 target
355373 } else {
0 commit comments