11use crate :: ich;
22
33use rustc_ast as ast;
4- use rustc_data_structures:: sorted_map:: SortedMap ;
54use rustc_data_structures:: stable_hasher:: { HashStable , HashingControls , StableHasher } ;
65use rustc_data_structures:: sync:: Lrc ;
7- use rustc_hir as hir;
86use rustc_hir:: def_id:: { DefId , LocalDefId } ;
97use rustc_hir:: definitions:: DefPathHash ;
108use rustc_session:: cstore:: Untracked ;
@@ -23,34 +21,19 @@ pub struct StableHashingContext<'a> {
2321 // The value of `-Z incremental-ignore-spans`.
2422 // This field should only be used by `unstable_opts_incremental_ignore_span`
2523 incremental_ignore_spans : bool ,
26- pub ( super ) body_resolver : BodyResolver < ' a > ,
2724 // Very often, we are hashing something that does not need the
2825 // `CachingSourceMapView`, so we initialize it lazily.
2926 raw_source_map : & ' a SourceMap ,
3027 caching_source_map : Option < CachingSourceMapView < ' a > > ,
3128 hashing_controls : HashingControls ,
3229}
3330
34- /// The `BodyResolver` allows mapping a `BodyId` to the corresponding `hir::Body`.
35- /// We could also just store a plain reference to the `hir::Crate` but we want
36- /// to avoid that the crate is used to get untracked access to all of the HIR.
37- #[ derive( Clone , Copy ) ]
38- pub ( super ) enum BodyResolver < ' tcx > {
39- Forbidden ,
40- Ignore ,
41- Traverse {
42- owner : hir:: OwnerId ,
43- bodies : & ' tcx SortedMap < hir:: ItemLocalId , & ' tcx hir:: Body < ' tcx > > ,
44- } ,
45- }
46-
4731impl < ' a > StableHashingContext < ' a > {
4832 #[ inline]
4933 pub fn new ( sess : & ' a Session , untracked : & ' a Untracked ) -> Self {
5034 let hash_spans_initial = !sess. opts . unstable_opts . incremental_ignore_spans ;
5135
5236 StableHashingContext {
53- body_resolver : BodyResolver :: Forbidden ,
5437 untracked,
5538 incremental_ignore_spans : sess. opts . unstable_opts . incremental_ignore_spans ,
5639 caching_source_map : None ,
@@ -59,24 +42,6 @@ impl<'a> StableHashingContext<'a> {
5942 }
6043 }
6144
62- #[ inline]
63- pub fn without_hir_bodies ( & mut self , f : impl FnOnce ( & mut StableHashingContext < ' _ > ) ) {
64- f ( & mut StableHashingContext { body_resolver : BodyResolver :: Ignore , ..self . clone ( ) } ) ;
65- }
66-
67- #[ inline]
68- pub fn with_hir_bodies (
69- & mut self ,
70- owner : hir:: OwnerId ,
71- bodies : & SortedMap < hir:: ItemLocalId , & hir:: Body < ' _ > > ,
72- f : impl FnOnce ( & mut StableHashingContext < ' _ > ) ,
73- ) {
74- f ( & mut StableHashingContext {
75- body_resolver : BodyResolver :: Traverse { owner, bodies } ,
76- ..self . clone ( )
77- } ) ;
78- }
79-
8045 #[ inline]
8146 pub fn while_hashing_spans < F : FnOnce ( & mut Self ) > ( & mut self , hash_spans : bool , f : F ) {
8247 let prev_hash_spans = self . hashing_controls . hash_spans ;
0 commit comments