@@ -224,20 +224,10 @@ impl_stable_hash_for!(enum ty::BorrowKind {
224
224
MutBorrow
225
225
} ) ;
226
226
227
- impl < ' a , ' gcx > HashStable < StableHashingContext < ' a > >
228
- for ty:: UpvarCapture < ' gcx > {
229
- fn hash_stable < W : StableHasherResult > ( & self ,
230
- hcx : & mut StableHashingContext < ' a > ,
231
- hasher : & mut StableHasher < W > ) {
232
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
233
- match * self {
234
- ty:: UpvarCapture :: ByValue => { }
235
- ty:: UpvarCapture :: ByRef ( ref up_var_borrow) => {
236
- up_var_borrow. hash_stable ( hcx, hasher) ;
237
- }
238
- }
239
- }
240
- }
227
+ impl_stable_hash_for ! ( impl <' gcx> for enum ty:: UpvarCapture <' gcx> [ ty:: UpvarCapture ] {
228
+ ByValue ,
229
+ ByRef ( up_var_borrow) ,
230
+ } ) ;
241
231
242
232
impl_stable_hash_for ! ( struct ty:: GenSig <' tcx> {
243
233
yield_ty,
@@ -272,64 +262,23 @@ impl_stable_hash_for!(enum ty::Visibility {
272
262
impl_stable_hash_for ! ( struct ty:: TraitRef <' tcx> { def_id, substs } ) ;
273
263
impl_stable_hash_for ! ( struct ty:: TraitPredicate <' tcx> { trait_ref } ) ;
274
264
impl_stable_hash_for ! ( struct ty:: SubtypePredicate <' tcx> { a_is_expected, a, b } ) ;
275
-
276
- impl < ' a , ' gcx , A , B > HashStable < StableHashingContext < ' a > >
277
- for ty:: OutlivesPredicate < A , B >
278
- where A : HashStable < StableHashingContext < ' a > > ,
279
- B : HashStable < StableHashingContext < ' a > > ,
280
- {
281
- fn hash_stable < W : StableHasherResult > ( & self ,
282
- hcx : & mut StableHashingContext < ' a > ,
283
- hasher : & mut StableHasher < W > ) {
284
- let ty:: OutlivesPredicate ( ref a, ref b) = * self ;
285
- a. hash_stable ( hcx, hasher) ;
286
- b. hash_stable ( hcx, hasher) ;
287
- }
288
- }
289
-
265
+ impl_stable_hash_for ! ( impl <A , B > for tuple_struct ty:: OutlivesPredicate <A , B > { a, b } ) ;
290
266
impl_stable_hash_for ! ( struct ty:: ProjectionPredicate <' tcx> { projection_ty, ty } ) ;
291
267
impl_stable_hash_for ! ( struct ty:: ProjectionTy <' tcx> { substs, item_def_id } ) ;
292
268
293
-
294
- impl < ' a , ' gcx > HashStable < StableHashingContext < ' a > > for ty:: Predicate < ' gcx > {
295
- fn hash_stable < W : StableHasherResult > ( & self ,
296
- hcx : & mut StableHashingContext < ' a > ,
297
- hasher : & mut StableHasher < W > ) {
298
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
299
- match * self {
300
- ty:: Predicate :: Trait ( ref pred) => {
301
- pred. hash_stable ( hcx, hasher) ;
302
- }
303
- ty:: Predicate :: Subtype ( ref pred) => {
304
- pred. hash_stable ( hcx, hasher) ;
305
- }
306
- ty:: Predicate :: RegionOutlives ( ref pred) => {
307
- pred. hash_stable ( hcx, hasher) ;
308
- }
309
- ty:: Predicate :: TypeOutlives ( ref pred) => {
310
- pred. hash_stable ( hcx, hasher) ;
311
- }
312
- ty:: Predicate :: Projection ( ref pred) => {
313
- pred. hash_stable ( hcx, hasher) ;
314
- }
315
- ty:: Predicate :: WellFormed ( ty) => {
316
- ty. hash_stable ( hcx, hasher) ;
317
- }
318
- ty:: Predicate :: ObjectSafe ( def_id) => {
319
- def_id. hash_stable ( hcx, hasher) ;
320
- }
321
- ty:: Predicate :: ClosureKind ( def_id, closure_substs, closure_kind) => {
322
- def_id. hash_stable ( hcx, hasher) ;
323
- closure_substs. hash_stable ( hcx, hasher) ;
324
- closure_kind. hash_stable ( hcx, hasher) ;
325
- }
326
- ty:: Predicate :: ConstEvaluatable ( def_id, substs) => {
327
- def_id. hash_stable ( hcx, hasher) ;
328
- substs. hash_stable ( hcx, hasher) ;
329
- }
330
- }
269
+ impl_stable_hash_for ! (
270
+ impl <' tcx> for enum ty:: Predicate <' tcx> [ ty:: Predicate ] {
271
+ Trait ( pred) ,
272
+ Subtype ( pred) ,
273
+ RegionOutlives ( pred) ,
274
+ TypeOutlives ( pred) ,
275
+ Projection ( pred) ,
276
+ WellFormed ( ty) ,
277
+ ObjectSafe ( def_id) ,
278
+ ClosureKind ( def_id, closure_substs, closure_kind) ,
279
+ ConstEvaluatable ( def_id, substs) ,
331
280
}
332
- }
281
+ ) ;
333
282
334
283
impl < ' a > HashStable < StableHashingContext < ' a > > for ty:: AdtFlags {
335
284
fn hash_stable < W : StableHasherResult > ( & self ,
@@ -358,70 +307,39 @@ impl_stable_hash_for!(struct ty::FieldDef {
358
307
vis,
359
308
} ) ;
360
309
361
- impl < ' a , ' gcx > HashStable < StableHashingContext < ' a > >
362
- for :: mir:: interpret:: ConstValue < ' gcx > {
363
- fn hash_stable < W : StableHasherResult > ( & self ,
364
- hcx : & mut StableHashingContext < ' a > ,
365
- hasher : & mut StableHasher < W > ) {
366
- use mir:: interpret:: ConstValue :: * ;
367
-
368
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
369
-
370
- match * self {
371
- Unevaluated ( def_id, substs) => {
372
- def_id. hash_stable ( hcx, hasher) ;
373
- substs. hash_stable ( hcx, hasher) ;
374
- }
375
- Scalar ( val) => {
376
- val. hash_stable ( hcx, hasher) ;
377
- }
378
- ScalarPair ( a, b) => {
379
- a. hash_stable ( hcx, hasher) ;
380
- b. hash_stable ( hcx, hasher) ;
381
- }
382
- ByRef ( id, alloc, offset) => {
383
- id. hash_stable ( hcx, hasher) ;
384
- alloc. hash_stable ( hcx, hasher) ;
385
- offset. hash_stable ( hcx, hasher) ;
386
- }
387
- }
310
+ impl_stable_hash_for ! (
311
+ impl <' tcx> for enum mir:: interpret:: ConstValue <' tcx> [ mir:: interpret:: ConstValue ] {
312
+ Unevaluated ( def_id, substs) ,
313
+ Scalar ( val) ,
314
+ ScalarPair ( a, b) ,
315
+ ByRef ( id, alloc, offset) ,
388
316
}
389
- }
317
+ ) ;
390
318
391
- impl < ' a , Tag > HashStable < StableHashingContext < ' a > >
392
- for :: mir:: interpret:: Pointer < Tag >
393
- where Tag : HashStable < StableHashingContext < ' a > >
394
- {
395
- fn hash_stable < W : StableHasherResult > ( & self ,
396
- hcx : & mut StableHashingContext < ' a > ,
397
- hasher : & mut StableHasher < W > ) {
398
- let :: mir:: interpret:: Pointer { alloc_id, offset, tag } = self ;
399
- alloc_id. hash_stable ( hcx, hasher) ;
400
- offset. hash_stable ( hcx, hasher) ;
401
- tag. hash_stable ( hcx, hasher) ;
319
+ impl_stable_hash_for ! {
320
+ impl <Tag > for struct mir:: interpret:: Pointer <Tag > {
321
+ alloc_id,
322
+ offset,
323
+ tag,
402
324
}
403
325
}
404
326
405
- impl < ' a , Tag > HashStable < StableHashingContext < ' a > >
406
- for :: mir:: interpret:: Scalar < Tag >
407
- where Tag : HashStable < StableHashingContext < ' a > >
408
- {
409
- fn hash_stable < W : StableHasherResult > ( & self ,
410
- hcx : & mut StableHashingContext < ' a > ,
411
- hasher : & mut StableHasher < W > ) {
412
- use mir:: interpret:: Scalar :: * ;
327
+ impl_stable_hash_for ! (
328
+ impl <Tag > for enum mir:: interpret:: Scalar <Tag > [ mir:: interpret:: Scalar ] {
329
+ Bits { bits, size } ,
330
+ Ptr ( ptr) ,
331
+ }
332
+ ) ;
413
333
414
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
415
- match self {
416
- Bits { bits, size } => {
417
- bits. hash_stable ( hcx, hasher) ;
418
- size. hash_stable ( hcx, hasher) ;
419
- } ,
420
- Ptr ( ptr) => ptr. hash_stable ( hcx, hasher) ,
421
- }
334
+ impl_stable_hash_for ! (
335
+ impl <' tcx, M > for enum mir:: interpret:: AllocType <' tcx, M > [ mir:: interpret:: AllocType ] {
336
+ Function ( instance) ,
337
+ Static ( def_id) ,
338
+ Memory ( mem) ,
422
339
}
423
- }
340
+ ) ;
424
341
342
+ // AllocIds get resolved to whatever they point to (to be stable)
425
343
impl < ' a > HashStable < StableHashingContext < ' a > > for mir:: interpret:: AllocId {
426
344
fn hash_stable < W : StableHasherResult > (
427
345
& self ,
@@ -437,23 +355,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
437
355
}
438
356
}
439
357
440
- impl < ' a , ' gcx , M : HashStable < StableHashingContext < ' a > > > HashStable < StableHashingContext < ' a > >
441
- for mir:: interpret:: AllocType < ' gcx , M > {
442
- fn hash_stable < W : StableHasherResult > ( & self ,
443
- hcx : & mut StableHashingContext < ' a > ,
444
- hasher : & mut StableHasher < W > ) {
445
- use mir:: interpret:: AllocType :: * ;
446
-
447
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
448
-
449
- match * self {
450
- Function ( instance) => instance. hash_stable ( hcx, hasher) ,
451
- Static ( def_id) => def_id. hash_stable ( hcx, hasher) ,
452
- Memory ( ref mem) => mem. hash_stable ( hcx, hasher) ,
453
- }
454
- }
455
- }
456
-
358
+ // Allocations treat their relocations specially
457
359
impl < ' a > HashStable < StableHashingContext < ' a > > for mir:: interpret:: Allocation {
458
360
fn hash_stable < W : StableHasherResult > (
459
361
& self ,
@@ -485,7 +387,7 @@ impl_stable_hash_for!(enum mir::interpret::ErrorHandled {
485
387
TooGeneric
486
388
} ) ;
487
389
488
- impl_stable_hash_for ! ( struct :: mir:: interpret:: FrameInfo {
390
+ impl_stable_hash_for ! ( struct mir:: interpret:: FrameInfo {
489
391
span,
490
392
lint_root,
491
393
location
@@ -499,124 +401,75 @@ impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
499
401
predicates
500
402
} ) ;
501
403
502
- impl < ' a , ' gcx , O : HashStable < StableHashingContext < ' a > > > HashStable < StableHashingContext < ' a > >
503
- for :: mir:: interpret:: EvalErrorKind < ' gcx , O > {
504
- fn hash_stable < W : StableHasherResult > ( & self ,
505
- hcx : & mut StableHashingContext < ' a > ,
506
- hasher : & mut StableHasher < W > ) {
507
- use mir:: interpret:: EvalErrorKind :: * ;
508
-
509
- mem:: discriminant ( & self ) . hash_stable ( hcx, hasher) ;
510
-
511
- match * self {
512
- FunctionArgCountMismatch |
513
- DanglingPointerDeref |
514
- DoubleFree |
515
- InvalidMemoryAccess |
516
- InvalidFunctionPointer |
517
- InvalidBool |
518
- InvalidNullPointerUsage |
519
- ReadPointerAsBytes |
520
- ReadBytesAsPointer |
521
- ReadForeignStatic |
522
- InvalidPointerMath |
523
- DeadLocal |
524
- StackFrameLimitReached |
525
- OutOfTls |
526
- TlsOutOfBounds |
527
- CalledClosureAsFunction |
528
- VtableForArgumentlessMethod |
529
- ModifiedConstantMemory |
530
- AssumptionNotHeld |
531
- InlineAsm |
532
- ReallocateNonBasePtr |
533
- DeallocateNonBasePtr |
534
- HeapAllocZeroBytes |
535
- Unreachable |
536
- ReadFromReturnPointer |
537
- UnimplementedTraitSelection |
538
- TypeckError |
539
- TooGeneric |
540
- DerefFunctionPointer |
541
- ExecuteMemory |
542
- OverflowNeg |
543
- RemainderByZero |
544
- DivisionByZero |
545
- GeneratorResumedAfterReturn |
546
- GeneratorResumedAfterPanic |
547
- ReferencedConstant |
548
- InfiniteLoop => { }
549
- ReadUndefBytes ( offset) => offset. hash_stable ( hcx, hasher) ,
550
- InvalidDiscriminant ( val) => val. hash_stable ( hcx, hasher) ,
551
- Panic { ref msg, ref file, line, col } => {
552
- msg. hash_stable ( hcx, hasher) ;
553
- file. hash_stable ( hcx, hasher) ;
554
- line. hash_stable ( hcx, hasher) ;
555
- col. hash_stable ( hcx, hasher) ;
556
- } ,
557
- MachineError ( ref err) => err. hash_stable ( hcx, hasher) ,
558
- FunctionAbiMismatch ( a, b) => {
559
- a. hash_stable ( hcx, hasher) ;
560
- b. hash_stable ( hcx, hasher)
561
- } ,
562
- FunctionArgMismatch ( a, b) => {
563
- a. hash_stable ( hcx, hasher) ;
564
- b. hash_stable ( hcx, hasher)
565
- } ,
566
- FunctionRetMismatch ( a, b) => {
567
- a. hash_stable ( hcx, hasher) ;
568
- b. hash_stable ( hcx, hasher)
569
- } ,
570
- NoMirFor ( ref s) => s. hash_stable ( hcx, hasher) ,
571
- UnterminatedCString ( ptr) => ptr. hash_stable ( hcx, hasher) ,
572
- PointerOutOfBounds {
573
- ptr,
574
- access,
575
- allocation_size,
576
- } => {
577
- ptr. hash_stable ( hcx, hasher) ;
578
- access. hash_stable ( hcx, hasher) ;
579
- allocation_size. hash_stable ( hcx, hasher)
580
- } ,
581
- InvalidBoolOp ( bop) => bop. hash_stable ( hcx, hasher) ,
582
- Unimplemented ( ref s) => s. hash_stable ( hcx, hasher) ,
583
- BoundsCheck { ref len, ref index } => {
584
- len. hash_stable ( hcx, hasher) ;
585
- index. hash_stable ( hcx, hasher)
586
- } ,
587
- Intrinsic ( ref s) => s. hash_stable ( hcx, hasher) ,
588
- InvalidChar ( c) => c. hash_stable ( hcx, hasher) ,
589
- AbiViolation ( ref s) => s. hash_stable ( hcx, hasher) ,
590
- AlignmentCheckFailed {
591
- required,
592
- has,
593
- } => {
594
- required. hash_stable ( hcx, hasher) ;
595
- has. hash_stable ( hcx, hasher)
596
- } ,
597
- ValidationFailure ( ref s) => s. hash_stable ( hcx, hasher) ,
598
- TypeNotPrimitive ( ty) => ty. hash_stable ( hcx, hasher) ,
599
- ReallocatedWrongMemoryKind ( ref a, ref b) => {
600
- a. hash_stable ( hcx, hasher) ;
601
- b. hash_stable ( hcx, hasher)
602
- } ,
603
- DeallocatedWrongMemoryKind ( ref a, ref b) => {
604
- a. hash_stable ( hcx, hasher) ;
605
- b. hash_stable ( hcx, hasher)
606
- } ,
607
- IncorrectAllocationInformation ( a, b, c, d) => {
608
- a. hash_stable ( hcx, hasher) ;
609
- b. hash_stable ( hcx, hasher) ;
610
- c. hash_stable ( hcx, hasher) ;
611
- d. hash_stable ( hcx, hasher)
612
- } ,
613
- Layout ( lay) => lay. hash_stable ( hcx, hasher) ,
614
- HeapAllocNonPowerOfTwoAlignment ( n) => n. hash_stable ( hcx, hasher) ,
615
- PathNotFound ( ref v) => v. hash_stable ( hcx, hasher) ,
616
- Overflow ( op) => op. hash_stable ( hcx, hasher) ,
617
- }
404
+ impl_stable_hash_for ! (
405
+ impl <' tcx, O > for enum mir:: interpret:: EvalErrorKind <' tcx, O >
406
+ [ mir:: interpret:: EvalErrorKind ]
407
+ {
408
+ FunctionArgCountMismatch ,
409
+ DanglingPointerDeref ,
410
+ DoubleFree ,
411
+ InvalidMemoryAccess ,
412
+ InvalidFunctionPointer ,
413
+ InvalidBool ,
414
+ InvalidNullPointerUsage ,
415
+ ReadPointerAsBytes ,
416
+ ReadBytesAsPointer ,
417
+ ReadForeignStatic ,
418
+ InvalidPointerMath ,
419
+ DeadLocal ,
420
+ StackFrameLimitReached ,
421
+ OutOfTls ,
422
+ TlsOutOfBounds ,
423
+ CalledClosureAsFunction ,
424
+ VtableForArgumentlessMethod ,
425
+ ModifiedConstantMemory ,
426
+ AssumptionNotHeld ,
427
+ InlineAsm ,
428
+ ReallocateNonBasePtr ,
429
+ DeallocateNonBasePtr ,
430
+ HeapAllocZeroBytes ,
431
+ Unreachable ,
432
+ ReadFromReturnPointer ,
433
+ UnimplementedTraitSelection ,
434
+ TypeckError ,
435
+ TooGeneric ,
436
+ DerefFunctionPointer ,
437
+ ExecuteMemory ,
438
+ OverflowNeg ,
439
+ RemainderByZero ,
440
+ DivisionByZero ,
441
+ GeneratorResumedAfterReturn ,
442
+ GeneratorResumedAfterPanic ,
443
+ ReferencedConstant ,
444
+ InfiniteLoop ,
445
+ ReadUndefBytes ( offset) ,
446
+ InvalidDiscriminant ( val) ,
447
+ Panic { msg, file, line, col } ,
448
+ MachineError ( err) ,
449
+ FunctionAbiMismatch ( a, b) ,
450
+ FunctionArgMismatch ( a, b) ,
451
+ FunctionRetMismatch ( a, b) ,
452
+ NoMirFor ( s) ,
453
+ UnterminatedCString ( ptr) ,
454
+ PointerOutOfBounds { ptr, access, allocation_size } ,
455
+ InvalidBoolOp ( bop) ,
456
+ Unimplemented ( s) ,
457
+ BoundsCheck { len, index } ,
458
+ Intrinsic ( s) ,
459
+ InvalidChar ( c) ,
460
+ AbiViolation ( s) ,
461
+ AlignmentCheckFailed { required, has } ,
462
+ ValidationFailure ( s) ,
463
+ TypeNotPrimitive ( ty) ,
464
+ ReallocatedWrongMemoryKind ( a, b) ,
465
+ DeallocatedWrongMemoryKind ( a, b) ,
466
+ IncorrectAllocationInformation ( a, b, c, d) ,
467
+ Layout ( lay) ,
468
+ HeapAllocNonPowerOfTwoAlignment ( n) ,
469
+ PathNotFound ( v) ,
470
+ Overflow ( op) ,
618
471
}
619
- }
472
+ ) ;
620
473
621
474
impl_stable_hash_for ! ( enum mir:: interpret:: Lock {
622
475
NoLock ,
@@ -663,47 +516,18 @@ impl_stable_hash_for!(struct ty::GenericParamDef {
663
516
kind
664
517
} ) ;
665
518
666
- impl < ' a > HashStable < StableHashingContext < ' a > > for ty:: GenericParamDefKind {
667
- fn hash_stable < W : StableHasherResult > ( & self ,
668
- hcx : & mut StableHashingContext < ' a > ,
669
- hasher : & mut StableHasher < W > ) {
670
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
671
- match * self {
672
- ty:: GenericParamDefKind :: Lifetime => { }
673
- ty:: GenericParamDefKind :: Type {
674
- has_default,
675
- ref object_lifetime_default,
676
- ref synthetic,
677
- } => {
678
- has_default. hash_stable ( hcx, hasher) ;
679
- object_lifetime_default. hash_stable ( hcx, hasher) ;
680
- synthetic. hash_stable ( hcx, hasher) ;
681
- }
682
- }
683
- }
684
- }
685
-
686
- impl < ' a , ' gcx , T > HashStable < StableHashingContext < ' a > >
687
- for :: middle:: resolve_lifetime:: Set1 < T >
688
- where T : HashStable < StableHashingContext < ' a > >
689
- {
690
- fn hash_stable < W : StableHasherResult > ( & self ,
691
- hcx : & mut StableHashingContext < ' a > ,
692
- hasher : & mut StableHasher < W > ) {
693
- use middle:: resolve_lifetime:: Set1 ;
519
+ impl_stable_hash_for ! ( enum ty:: GenericParamDefKind {
520
+ Lifetime ,
521
+ Type { has_default, object_lifetime_default, synthetic } ,
522
+ } ) ;
694
523
695
- mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
696
- match * self {
697
- Set1 :: Empty |
698
- Set1 :: Many => {
699
- // Nothing to do.
700
- }
701
- Set1 :: One ( ref value) => {
702
- value. hash_stable ( hcx, hasher) ;
703
- }
704
- }
524
+ impl_stable_hash_for ! (
525
+ impl <T > for enum :: middle:: resolve_lifetime:: Set1 <T > [ :: middle:: resolve_lifetime:: Set1 ] {
526
+ Empty ,
527
+ Many ,
528
+ One ( value) ,
705
529
}
706
- }
530
+ ) ;
707
531
708
532
impl_stable_hash_for ! ( enum :: middle:: resolve_lifetime:: LifetimeDefOrigin {
709
533
ExplicitOrElided ,
@@ -1250,7 +1074,7 @@ impl_stable_hash_for!(
1250
1074
) ;
1251
1075
1252
1076
impl_stable_hash_for ! (
1253
- impl < ' tcx> for struct infer:: canonical:: CanonicalVarValues <' tcx> {
1077
+ struct infer:: canonical:: CanonicalVarValues <' tcx> {
1254
1078
var_values
1255
1079
}
1256
1080
) ;
@@ -1369,7 +1193,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::Goal<'tcx> {
1369
1193
}
1370
1194
1371
1195
impl_stable_hash_for ! (
1372
- impl < ' tcx> for struct traits:: ProgramClause <' tcx> {
1196
+ struct traits:: ProgramClause <' tcx> {
1373
1197
goal, hypotheses, category
1374
1198
}
1375
1199
) ;
@@ -1404,7 +1228,7 @@ impl_stable_hash_for!(struct ty::subst::UserSubsts<'tcx> { substs, user_self_ty
1404
1228
impl_stable_hash_for ! ( struct ty:: subst:: UserSelfTy <' tcx> { impl_def_id, self_ty } ) ;
1405
1229
1406
1230
impl_stable_hash_for ! (
1407
- impl < ' tcx> for struct traits:: Environment <' tcx> {
1231
+ struct traits:: Environment <' tcx> {
1408
1232
clauses,
1409
1233
}
1410
1234
) ;
0 commit comments