@@ -684,34 +684,37 @@ pub fn miri_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::ConstantKind<'t
684
684
} ,
685
685
_ => None ,
686
686
} ,
687
- mir:: ConstantKind :: Val ( ConstValue :: ByRef { alloc, offset : _ } , _) => match result. ty ( ) . kind ( ) {
688
- ty:: Adt ( adt_def, _) if adt_def. is_struct ( ) => Some ( Constant :: Adt ( result) ) ,
689
- ty:: Array ( sub_type, len) => match sub_type. kind ( ) {
690
- ty:: Float ( FloatTy :: F32 ) => match len. try_to_target_usize ( lcx. tcx ) {
691
- Some ( len) => alloc
692
- . inner ( )
693
- . inspect_with_uninit_and_ptr_outside_interpreter ( 0 ..( 4 * usize:: try_from ( len) . unwrap ( ) ) )
694
- . to_owned ( )
695
- . array_chunks :: < 4 > ( )
696
- . map ( |& chunk| Some ( Constant :: F32 ( f32:: from_le_bytes ( chunk) ) ) )
697
- . collect :: < Option < Vec < Constant < ' tcx > > > > ( )
698
- . map ( Constant :: Vec ) ,
699
- _ => None ,
700
- } ,
701
- ty:: Float ( FloatTy :: F64 ) => match len. try_to_target_usize ( lcx. tcx ) {
702
- Some ( len) => alloc
703
- . inner ( )
704
- . inspect_with_uninit_and_ptr_outside_interpreter ( 0 ..( 8 * usize:: try_from ( len) . unwrap ( ) ) )
705
- . to_owned ( )
706
- . array_chunks :: < 8 > ( )
707
- . map ( |& chunk| Some ( Constant :: F64 ( f64:: from_le_bytes ( chunk) ) ) )
708
- . collect :: < Option < Vec < Constant < ' tcx > > > > ( )
709
- . map ( Constant :: Vec ) ,
687
+ mir:: ConstantKind :: Val ( ConstValue :: ByRef { alloc_id, offset : _ } , _) => {
688
+ let alloc = lcx. tcx . global_alloc ( alloc_id) . unwrap_memory ( ) ;
689
+ match result. ty ( ) . kind ( ) {
690
+ ty:: Adt ( adt_def, _) if adt_def. is_struct ( ) => Some ( Constant :: Adt ( result) ) ,
691
+ ty:: Array ( sub_type, len) => match sub_type. kind ( ) {
692
+ ty:: Float ( FloatTy :: F32 ) => match len. try_to_target_usize ( lcx. tcx ) {
693
+ Some ( len) => alloc
694
+ . inner ( )
695
+ . inspect_with_uninit_and_ptr_outside_interpreter ( 0 ..( 4 * usize:: try_from ( len) . unwrap ( ) ) )
696
+ . to_owned ( )
697
+ . array_chunks :: < 4 > ( )
698
+ . map ( |& chunk| Some ( Constant :: F32 ( f32:: from_le_bytes ( chunk) ) ) )
699
+ . collect :: < Option < Vec < Constant < ' tcx > > > > ( )
700
+ . map ( Constant :: Vec ) ,
701
+ _ => None ,
702
+ } ,
703
+ ty:: Float ( FloatTy :: F64 ) => match len. try_to_target_usize ( lcx. tcx ) {
704
+ Some ( len) => alloc
705
+ . inner ( )
706
+ . inspect_with_uninit_and_ptr_outside_interpreter ( 0 ..( 8 * usize:: try_from ( len) . unwrap ( ) ) )
707
+ . to_owned ( )
708
+ . array_chunks :: < 8 > ( )
709
+ . map ( |& chunk| Some ( Constant :: F64 ( f64:: from_le_bytes ( chunk) ) ) )
710
+ . collect :: < Option < Vec < Constant < ' tcx > > > > ( )
711
+ . map ( Constant :: Vec ) ,
712
+ _ => None ,
713
+ } ,
710
714
_ => None ,
711
715
} ,
712
716
_ => None ,
713
- } ,
714
- _ => None ,
717
+ }
715
718
} ,
716
719
_ => None ,
717
720
}
0 commit comments