@@ -77,7 +77,7 @@ pub fn eval_body<'a, 'tcx>(
77
77
instance,
78
78
mir. span ,
79
79
mir,
80
- Place :: from_ptr ( ptr) ,
80
+ Place :: from_ptr ( ptr, layout . align ) ,
81
81
cleanup. clone ( ) ,
82
82
) ?;
83
83
@@ -357,10 +357,11 @@ pub fn const_eval_provider<'a, 'tcx>(
357
357
( _, Err ( err) ) => Err ( err) ,
358
358
( Ok ( ( miri_val, miri_ty) ) , Ok ( ctfe) ) => {
359
359
let mut ecx = mk_eval_cx ( tcx, instance, key. param_env ) . unwrap ( ) ;
360
- check_ctfe_against_miri ( & mut ecx , PtrAndAlign {
360
+ let miri_ptr = PtrAndAlign {
361
361
ptr : miri_val,
362
- aligned : true
363
- } , miri_ty, ctfe. val ) ;
362
+ align : ecx. layout_of ( miri_ty) . unwrap ( ) . align
363
+ } ;
364
+ check_ctfe_against_miri ( & mut ecx, miri_ptr, miri_ty, ctfe. val ) ;
364
365
Ok ( ctfe)
365
366
}
366
367
}
@@ -380,7 +381,7 @@ fn check_ctfe_against_miri<'a, 'tcx>(
380
381
use rustc:: ty:: TypeVariants :: * ;
381
382
match miri_ty. sty {
382
383
TyInt ( int_ty) => {
383
- let value = ecx. read_maybe_aligned ( miri_val. aligned , |ectx| {
384
+ let value = ecx. read_with_align ( miri_val. align , |ectx| {
384
385
ectx. try_read_value ( miri_val. ptr , miri_ty)
385
386
} ) ;
386
387
let prim = get_prim ( ecx, value) ;
@@ -391,7 +392,7 @@ fn check_ctfe_against_miri<'a, 'tcx>(
391
392
assert_eq ! ( c, ctfe, "miri evaluated to {:?}, but ctfe yielded {:?}" , c, ctfe) ;
392
393
} ,
393
394
TyUint ( uint_ty) => {
394
- let value = ecx. read_maybe_aligned ( miri_val. aligned , |ectx| {
395
+ let value = ecx. read_with_align ( miri_val. align , |ectx| {
395
396
ectx. try_read_value ( miri_val. ptr , miri_ty)
396
397
} ) ;
397
398
let prim = get_prim ( ecx, value) ;
@@ -402,15 +403,15 @@ fn check_ctfe_against_miri<'a, 'tcx>(
402
403
assert_eq ! ( c, ctfe, "miri evaluated to {:?}, but ctfe yielded {:?}" , c, ctfe) ;
403
404
} ,
404
405
TyFloat ( ty) => {
405
- let value = ecx. read_maybe_aligned ( miri_val. aligned , |ectx| {
406
+ let value = ecx. read_with_align ( miri_val. align , |ectx| {
406
407
ectx. try_read_value ( miri_val. ptr , miri_ty)
407
408
} ) ;
408
409
let prim = get_prim ( ecx, value) ;
409
410
let f = ConstVal :: Float ( ConstFloat { bits : prim, ty } ) ;
410
411
assert_eq ! ( f, ctfe, "miri evaluated to {:?}, but ctfe yielded {:?}" , f, ctfe) ;
411
412
} ,
412
413
TyBool => {
413
- let value = ecx. read_maybe_aligned ( miri_val. aligned , |ectx| {
414
+ let value = ecx. read_with_align ( miri_val. align , |ectx| {
414
415
ectx. try_read_value ( miri_val. ptr , miri_ty)
415
416
} ) ;
416
417
let bits = get_prim ( ecx, value) ;
@@ -421,7 +422,7 @@ fn check_ctfe_against_miri<'a, 'tcx>(
421
422
assert_eq ! ( b, ctfe, "miri evaluated to {:?}, but ctfe yielded {:?}" , b, ctfe) ;
422
423
} ,
423
424
TyChar => {
424
- let value = ecx. read_maybe_aligned ( miri_val. aligned , |ectx| {
425
+ let value = ecx. read_with_align ( miri_val. align , |ectx| {
425
426
ectx. try_read_value ( miri_val. ptr , miri_ty)
426
427
} ) ;
427
428
let bits = get_prim ( ecx, value) ;
@@ -435,7 +436,7 @@ fn check_ctfe_against_miri<'a, 'tcx>(
435
436
}
436
437
} ,
437
438
TyStr => {
438
- let value = ecx. read_maybe_aligned ( miri_val. aligned , |ectx| {
439
+ let value = ecx. read_with_align ( miri_val. align , |ectx| {
439
440
ectx. try_read_value ( miri_val. ptr , miri_ty)
440
441
} ) ;
441
442
if let Ok ( Some ( Value :: ByValPair ( PrimVal :: Ptr ( ptr) , PrimVal :: Bytes ( len) ) ) ) = value {
@@ -522,8 +523,7 @@ fn check_ctfe_against_miri<'a, 'tcx>(
522
523
Field :: new ( field) ,
523
524
layout,
524
525
) . unwrap ( ) ;
525
- let ptr = place. to_ptr_extra_aligned ( ) . 0 ;
526
- check_ctfe_against_miri ( ecx, ptr, elem. ty , elem. val ) ;
526
+ check_ctfe_against_miri ( ecx, place. to_ptr_align ( ) , elem. ty , elem. val ) ;
527
527
}
528
528
} ,
529
529
TySlice ( _) => bug ! ( "miri produced a slice?" ) ,
@@ -543,7 +543,7 @@ fn check_ctfe_against_miri<'a, 'tcx>(
543
543
// should be fine
544
544
TyFnDef ( ..) => { }
545
545
TyFnPtr ( _) => {
546
- let value = ecx. read_maybe_aligned ( miri_val. aligned , |ectx| {
546
+ let value = ecx. read_with_align ( miri_val. align , |ectx| {
547
547
ectx. try_read_value ( miri_val. ptr , miri_ty)
548
548
} ) ;
549
549
let ptr = match value {
0 commit comments