@@ -81,14 +81,9 @@ pub struct Frame<'mir, 'tcx, Tag = (), Extra = ()> {
81
81
////////////////////////////////////////////////////////////////////////////////
82
82
// Current position within the function
83
83
////////////////////////////////////////////////////////////////////////////////
84
- /// The block that is currently executed (or will be executed after the above call stacks
85
- /// return).
86
84
/// If this is `None`, we are unwinding and this function doesn't need any clean-up.
87
85
/// Just continue the same as with `Resume`.
88
- pub block : Option < mir:: BasicBlock > ,
89
-
90
- /// The index of the currently evaluated statement.
91
- pub stmt : usize ,
86
+ pub loc : Option < mir:: Location > ,
92
87
}
93
88
94
89
#[ derive( Clone , Eq , PartialEq , Debug , HashStable ) ] // Miri debug-prints these
@@ -168,8 +163,7 @@ impl<'mir, 'tcx, Tag> Frame<'mir, 'tcx, Tag> {
168
163
return_to_block : self . return_to_block ,
169
164
return_place : self . return_place ,
170
165
locals : self . locals ,
171
- block : self . block ,
172
- stmt : self . stmt ,
166
+ loc : self . loc ,
173
167
extra,
174
168
}
175
169
}
@@ -178,10 +172,10 @@ impl<'mir, 'tcx, Tag> Frame<'mir, 'tcx, Tag> {
178
172
impl < ' mir , ' tcx , Tag , Extra > Frame < ' mir , ' tcx , Tag , Extra > {
179
173
/// Return the `SourceInfo` of the current instruction.
180
174
pub fn current_source_info ( & self ) -> Option < mir:: SourceInfo > {
181
- self . block . map ( |block | {
182
- let block = & self . body . basic_blocks ( ) [ block] ;
183
- if self . stmt < block. statements . len ( ) {
184
- block. statements [ self . stmt ] . source_info
175
+ self . loc . map ( |loc | {
176
+ let block = & self . body . basic_blocks ( ) [ loc . block ] ;
177
+ if loc . statement_index < block. statements . len ( ) {
178
+ block. statements [ loc . statement_index ] . source_info
185
179
} else {
186
180
block. terminator ( ) . source_info
187
181
}
@@ -615,14 +609,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
615
609
// first push a stack frame so we have access to the local substs
616
610
let pre_frame = Frame {
617
611
body,
618
- block : Some ( mir:: START_BLOCK ) ,
612
+ loc : Some ( mir:: Location :: START ) ,
619
613
return_to_block,
620
614
return_place,
621
615
// empty local array, we fill it in below, after we are inside the stack frame and
622
616
// all methods actually know about the frame
623
617
locals : IndexVec :: new ( ) ,
624
618
instance,
625
- stmt : 0 ,
626
619
extra : ( ) ,
627
620
} ;
628
621
let frame = M :: init_frame_extra ( self , pre_frame) ?;
@@ -666,9 +659,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
666
659
/// Jump to the given block.
667
660
#[ inline]
668
661
pub fn go_to_block ( & mut self , target : mir:: BasicBlock ) {
669
- let frame = self . frame_mut ( ) ;
670
- frame. block = Some ( target) ;
671
- frame. stmt = 0 ;
662
+ self . frame_mut ( ) . loc = Some ( mir:: Location { block : target, statement_index : 0 } ) ;
672
663
}
673
664
674
665
/// *Return* to the given `target` basic block.
@@ -690,9 +681,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
690
681
/// If `target` is `None`, that indicates the function does not need cleanup during
691
682
/// unwinding, and we will just keep propagating that upwards.
692
683
pub fn unwind_to_block ( & mut self , target : Option < mir:: BasicBlock > ) {
693
- let frame = self . frame_mut ( ) ;
694
- frame. block = target;
695
- frame. stmt = 0 ;
684
+ self . frame_mut ( ) . loc = target. map ( |block| mir:: Location { block, statement_index : 0 } ) ;
696
685
}
697
686
698
687
/// Pops the current frame from the stack, deallocating the
@@ -719,9 +708,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
719
708
// Sanity check `unwinding`.
720
709
assert_eq ! (
721
710
unwinding,
722
- match self . frame( ) . block {
711
+ match self . frame( ) . loc {
723
712
None => true ,
724
- Some ( block ) => self . body( ) . basic_blocks( ) [ block] . is_cleanup,
713
+ Some ( loc ) => self . body( ) . basic_blocks( ) [ loc . block] . is_cleanup,
725
714
}
726
715
) ;
727
716
@@ -973,13 +962,14 @@ where
973
962
Tag : HashStable < StableHashingContext < ' ctx > > ,
974
963
{
975
964
fn hash_stable ( & self , hcx : & mut StableHashingContext < ' ctx > , hasher : & mut StableHasher ) {
976
- self . body . hash_stable ( hcx, hasher) ;
977
- self . instance . hash_stable ( hcx, hasher) ;
978
- self . return_to_block . hash_stable ( hcx, hasher) ;
979
- self . return_place . as_ref ( ) . map ( |r| & * * r) . hash_stable ( hcx, hasher) ;
980
- self . locals . hash_stable ( hcx, hasher) ;
981
- self . block . hash_stable ( hcx, hasher) ;
982
- self . stmt . hash_stable ( hcx, hasher) ;
983
- self . extra . hash_stable ( hcx, hasher) ;
965
+ // Exhaustive match on fields to make sure we forget no field.
966
+ let Frame { body, instance, return_to_block, return_place, locals, loc, extra } = self ;
967
+ body. hash_stable ( hcx, hasher) ;
968
+ instance. hash_stable ( hcx, hasher) ;
969
+ return_to_block. hash_stable ( hcx, hasher) ;
970
+ return_place. as_ref ( ) . map ( |r| & * * r) . hash_stable ( hcx, hasher) ;
971
+ locals. hash_stable ( hcx, hasher) ;
972
+ loc. hash_stable ( hcx, hasher) ;
973
+ extra. hash_stable ( hcx, hasher) ;
984
974
}
985
975
}
0 commit comments