@@ -40,11 +40,8 @@ pub struct StableHashingContext<'a> {
4040#[ derive( Clone , Copy ) ]
4141pub ( super ) enum BodyResolver < ' tcx > {
4242 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 > > } ,
4845}
4946
5047impl < ' a > StableHashingContext < ' a > {
@@ -98,32 +95,20 @@ impl<'a> StableHashingContext<'a> {
9895 Self :: new_with_or_without_spans ( sess, definitions, cstore, source_span, always_ignore_spans)
9996 }
10097
101- /// Allow hashing
10298 #[ 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 ( ) } ) ;
115101 }
116102
117103 #[ inline]
118104 pub fn with_hir_bodies (
119105 & mut self ,
120- hash_bodies : bool ,
121106 owner : LocalDefId ,
122107 bodies : & SortedMap < hir:: ItemLocalId , & hir:: Body < ' _ > > ,
123108 f : impl FnOnce ( & mut StableHashingContext < ' _ > ) ,
124109 ) {
125110 f ( & mut StableHashingContext {
126- body_resolver : BodyResolver :: Traverse { hash_bodies , owner, bodies } ,
111+ body_resolver : BodyResolver :: Traverse { owner, bodies } ,
127112 ..self . clone ( )
128113 } ) ;
129114 }
0 commit comments