@@ -196,8 +196,24 @@ impl<'tcx> LocalValue {
196196}
197197
198198/// The virtual machine state during const-evaluation at a given point in time.
199- type EvalSnapshot < ' a , ' mir , ' tcx , M >
200- = ( M , Vec < Frame < ' mir , ' tcx > > , Memory < ' a , ' mir , ' tcx , M > ) ;
199+ #[ derive( Eq , PartialEq , Hash ) ]
200+ pub ( crate ) struct EvalSnapshot < ' a , ' mir , ' tcx : ' a + ' mir , M : Machine < ' mir , ' tcx > > {
201+ machine : M ,
202+ memory : Memory < ' a , ' mir , ' tcx , M > ,
203+ stack : Vec < Frame < ' mir , ' tcx > > ,
204+ }
205+
206+ impl < ' a , ' mir , ' tcx , M > EvalSnapshot < ' a , ' mir , ' tcx , M >
207+ where M : Machine < ' mir , ' tcx > ,
208+ {
209+ fn new < ' b > ( machine : & M , memory : & Memory < ' a , ' mir , ' tcx , M > , stack : & [ Frame < ' mir , ' tcx > ] ) -> Self {
210+ EvalSnapshot {
211+ machine : machine. clone ( ) ,
212+ memory : memory. clone ( ) ,
213+ stack : stack. into ( ) ,
214+ }
215+ }
216+ }
201217
202218pub ( super ) struct InfiniteLoopDetector < ' a , ' mir , ' tcx : ' a + ' mir , M : Machine < ' mir , ' tcx > > {
203219 /// The set of all `EvalSnapshot` *hashes* observed by this detector.
@@ -238,21 +254,20 @@ impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M>
238254 pub fn observe_and_analyze (
239255 & mut self ,
240256 machine : & M ,
241- stack : & Vec < Frame < ' mir , ' tcx > > ,
242257 memory : & Memory < ' a , ' mir , ' tcx , M > ,
258+ stack : & [ Frame < ' mir , ' tcx > ] ,
243259 ) -> EvalResult < ' tcx , ( ) > {
244- let snapshot = ( machine, stack, memory) ;
245260
246261 let mut fx = FxHasher :: default ( ) ;
247- snapshot . hash ( & mut fx) ;
262+ ( machine , memory , stack ) . hash ( & mut fx) ;
248263 let hash = fx. finish ( ) ;
249264
250265 if self . hashes . insert ( hash) {
251266 // No collision
252267 return Ok ( ( ) )
253268 }
254269
255- if self . snapshots . insert ( ( machine. clone ( ) , stack . clone ( ) , memory . clone ( ) ) ) {
270+ if self . snapshots . insert ( EvalSnapshot :: new ( machine, memory , stack ) ) {
256271 // Spurious collision or first cycle
257272 return Ok ( ( ) )
258273 }
0 commit comments