@@ -22,7 +22,8 @@ use rustc::ty::layout::{self, LayoutTyper};
22
22
use rustc:: ty:: cast:: { CastTy , IntTy } ;
23
23
use rustc:: ty:: subst:: { Kind , Substs , Subst } ;
24
24
use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
25
- use { abi, adt, base, machine} ;
25
+ use { adt, base, machine} ;
26
+ use abi:: { self , Abi } ;
26
27
use callee;
27
28
use builder:: Builder ;
28
29
use common:: { self , CrateContext , const_get_elt, val_ty} ;
@@ -339,17 +340,34 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
339
340
func, fn_ty)
340
341
} ;
341
342
342
- let mut const_args = IndexVec :: with_capacity ( args. len ( ) ) ;
343
+ let mut arg_vals = IndexVec :: with_capacity ( args. len ( ) ) ;
343
344
for arg in args {
344
345
match self . const_operand ( arg, span) {
345
- Ok ( arg) => { const_args . push ( arg) ; } ,
346
+ Ok ( arg) => { arg_vals . push ( arg) ; } ,
346
347
Err ( err) => if failure. is_ok ( ) { failure = Err ( err) ; }
347
348
}
348
349
}
349
350
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
+ }
353
371
}
354
372
target
355
373
} else {
0 commit comments