@@ -40,11 +40,8 @@ pub struct StableHashingContext<'a> {
40
40
#[ derive( Clone , Copy ) ]
41
41
pub ( super ) enum BodyResolver < ' tcx > {
42
42
Forbidden ,
43
- Traverse {
44
- hash_bodies : bool ,
45
- owner : LocalDefId ,
46
- bodies : & ' tcx SortedMap < hir:: ItemLocalId , & ' tcx hir:: Body < ' tcx > > ,
47
- } ,
43
+ Ignore ,
44
+ Traverse { owner : LocalDefId , bodies : & ' tcx SortedMap < hir:: ItemLocalId , & ' tcx hir:: Body < ' tcx > > } ,
48
45
}
49
46
50
47
impl < ' a > StableHashingContext < ' a > {
@@ -98,32 +95,20 @@ impl<'a> StableHashingContext<'a> {
98
95
Self :: new_with_or_without_spans ( sess, definitions, cstore, source_span, always_ignore_spans)
99
96
}
100
97
101
- /// Allow hashing
102
98
#[ inline]
103
- pub fn while_hashing_hir_bodies ( & mut self , hb : bool , f : impl FnOnce ( & mut Self ) ) {
104
- let prev = match & mut self . body_resolver {
105
- BodyResolver :: Forbidden => panic ! ( "Hashing HIR bodies is forbidden." ) ,
106
- BodyResolver :: Traverse { ref mut hash_bodies, .. } => {
107
- std:: mem:: replace ( hash_bodies, hb)
108
- }
109
- } ;
110
- f ( self ) ;
111
- match & mut self . body_resolver {
112
- BodyResolver :: Forbidden => unreachable ! ( ) ,
113
- BodyResolver :: Traverse { ref mut hash_bodies, .. } => * hash_bodies = prev,
114
- }
99
+ pub fn without_hir_bodies ( & mut self , f : impl FnOnce ( & mut StableHashingContext < ' _ > ) ) {
100
+ f ( & mut StableHashingContext { body_resolver : BodyResolver :: Ignore , ..self . clone ( ) } ) ;
115
101
}
116
102
117
103
#[ inline]
118
104
pub fn with_hir_bodies (
119
105
& mut self ,
120
- hash_bodies : bool ,
121
106
owner : LocalDefId ,
122
107
bodies : & SortedMap < hir:: ItemLocalId , & hir:: Body < ' _ > > ,
123
108
f : impl FnOnce ( & mut StableHashingContext < ' _ > ) ,
124
109
) {
125
110
f ( & mut StableHashingContext {
126
- body_resolver : BodyResolver :: Traverse { hash_bodies , owner, bodies } ,
111
+ body_resolver : BodyResolver :: Traverse { owner, bodies } ,
127
112
..self . clone ( )
128
113
} ) ;
129
114
}
0 commit comments