6
6
// it is not used by the general miri engine, just by CTFE.
7
7
8
8
use std:: hash:: { Hash , Hasher } ;
9
- use std:: mem;
10
9
11
- use rustc:: ich:: { StableHashingContext , StableHashingContextProvider } ;
10
+ use rustc:: ich:: StableHashingContextProvider ;
12
11
use rustc:: mir;
13
12
use rustc:: mir:: interpret:: {
14
13
AllocId , Pointer , Scalar ,
@@ -20,7 +19,7 @@ use rustc::ty::{self, TyCtxt};
20
19
use rustc:: ty:: layout:: Align ;
21
20
use rustc_data_structures:: fx:: FxHashSet ;
22
21
use rustc_data_structures:: indexed_vec:: IndexVec ;
23
- use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher , StableHasherResult } ;
22
+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
24
23
use syntax:: ast:: Mutability ;
25
24
use syntax:: source_map:: Span ;
26
25
@@ -217,23 +216,10 @@ impl_snapshot_for!(struct MemPlace {
217
216
align -> * align, // just copy alignment verbatim
218
217
} ) ;
219
218
220
- // Can't use the macro here because that does not support named enum fields.
221
- impl < ' a > HashStable < StableHashingContext < ' a > > for Place {
222
- fn hash_stable < W : StableHasherResult > (
223
- & self , hcx : & mut StableHashingContext < ' a > ,
224
- hasher : & mut StableHasher < W > )
225
- {
226
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
227
- match self {
228
- Place :: Ptr ( mem_place) => mem_place. hash_stable ( hcx, hasher) ,
229
-
230
- Place :: Local { frame, local } => {
231
- frame. hash_stable ( hcx, hasher) ;
232
- local. hash_stable ( hcx, hasher) ;
233
- } ,
234
- }
235
- }
236
- }
219
+ impl_stable_hash_for ! ( enum :: interpret:: Place {
220
+ Ptr ( mem_place) ,
221
+ Local { frame, local } ,
222
+ } ) ;
237
223
impl < ' a , Ctx > Snapshot < ' a , Ctx > for Place
238
224
where Ctx : SnapshotContext < ' a > ,
239
225
{
@@ -317,20 +303,10 @@ impl<'a, Ctx> Snapshot<'a, Ctx> for &'a Allocation
317
303
}
318
304
}
319
305
320
- // Can't use the macro here because that does not support named enum fields.
321
- impl < ' a > HashStable < StableHashingContext < ' a > > for StackPopCleanup {
322
- fn hash_stable < W : StableHasherResult > (
323
- & self ,
324
- hcx : & mut StableHashingContext < ' a > ,
325
- hasher : & mut StableHasher < W > )
326
- {
327
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
328
- match self {
329
- StackPopCleanup :: Goto ( ref block) => block. hash_stable ( hcx, hasher) ,
330
- StackPopCleanup :: None { cleanup } => cleanup. hash_stable ( hcx, hasher) ,
331
- }
332
- }
333
- }
306
+ impl_stable_hash_for ! ( enum :: interpret:: eval_context:: StackPopCleanup {
307
+ Goto ( block) ,
308
+ None { cleanup } ,
309
+ } ) ;
334
310
335
311
#[ derive( Eq , PartialEq ) ]
336
312
struct FrameSnapshot < ' a , ' tcx : ' a > {
@@ -343,28 +319,17 @@ struct FrameSnapshot<'a, 'tcx: 'a> {
343
319
stmt : usize ,
344
320
}
345
321
346
- // Not using the macro because that does not support types depending on two lifetimes
347
- impl < ' a , ' mir , ' tcx : ' mir > HashStable < StableHashingContext < ' a > > for Frame < ' mir , ' tcx > {
348
- fn hash_stable < W : StableHasherResult > (
349
- & self ,
350
- hcx : & mut StableHashingContext < ' a > ,
351
- hasher : & mut StableHasher < W > ) {
352
-
353
- let Frame {
354
- mir,
355
- instance,
356
- span,
357
- return_to_block,
358
- return_place,
359
- locals,
360
- block,
361
- stmt,
362
- } = self ;
322
+ impl_stable_hash_for ! ( impl <' tcx, ' mir: ' tcx> for struct Frame <' mir, ' tcx> {
323
+ mir,
324
+ instance,
325
+ span,
326
+ return_to_block,
327
+ return_place -> ( return_place. as_ref( ) . map( |r| & * * r) ) ,
328
+ locals,
329
+ block,
330
+ stmt,
331
+ } ) ;
363
332
364
- ( mir, instance, span, return_to_block) . hash_stable ( hcx, hasher) ;
365
- ( return_place. as_ref ( ) . map ( |r| & * * r) , locals, block, stmt) . hash_stable ( hcx, hasher) ;
366
- }
367
- }
368
333
impl < ' a , ' mir , ' tcx , Ctx > Snapshot < ' a , Ctx > for & ' a Frame < ' mir , ' tcx >
369
334
where Ctx : SnapshotContext < ' a > ,
370
335
{
@@ -443,21 +408,11 @@ impl<'a, 'mir, 'tcx> Hash for EvalSnapshot<'a, 'mir, 'tcx>
443
408
}
444
409
}
445
410
446
- // Not using the macro because we need special handling for `memory`, which the macro
447
- // does not support at the same time as the extra bounds on the type.
448
- impl < ' a , ' b , ' mir , ' tcx > HashStable < StableHashingContext < ' b > >
449
- for EvalSnapshot < ' a , ' mir , ' tcx >
450
- {
451
- fn hash_stable < W : StableHasherResult > (
452
- & self ,
453
- hcx : & mut StableHashingContext < ' b > ,
454
- hasher : & mut StableHasher < W > )
455
- {
456
- // Not hashing memory: Avoid hashing memory all the time during execution
457
- let EvalSnapshot { memory : _, stack } = self ;
458
- stack. hash_stable ( hcx, hasher) ;
459
- }
460
- }
411
+ impl_stable_hash_for ! ( impl <' tcx, ' b, ' mir> for struct EvalSnapshot <' b, ' mir, ' tcx> {
412
+ // Not hashing memory: Avoid hashing memory all the time during execution
413
+ memory -> _,
414
+ stack,
415
+ } ) ;
461
416
462
417
impl < ' a , ' mir , ' tcx > Eq for EvalSnapshot < ' a , ' mir , ' tcx >
463
418
{ }
0 commit comments