1
1
use crate :: ich;
2
2
3
3
use rustc_ast as ast;
4
- use rustc_data_structures:: sorted_map:: SortedMap ;
5
4
use rustc_data_structures:: stable_hasher:: { HashStable , HashingControls , StableHasher } ;
6
5
use rustc_data_structures:: sync:: Lrc ;
7
- use rustc_hir as hir;
8
6
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
9
7
use rustc_hir:: definitions:: DefPathHash ;
10
8
use rustc_session:: cstore:: Untracked ;
@@ -23,34 +21,19 @@ pub struct StableHashingContext<'a> {
23
21
// The value of `-Z incremental-ignore-spans`.
24
22
// This field should only be used by `unstable_opts_incremental_ignore_span`
25
23
incremental_ignore_spans : bool ,
26
- pub ( super ) body_resolver : BodyResolver < ' a > ,
27
24
// Very often, we are hashing something that does not need the
28
25
// `CachingSourceMapView`, so we initialize it lazily.
29
26
raw_source_map : & ' a SourceMap ,
30
27
caching_source_map : Option < CachingSourceMapView < ' a > > ,
31
28
hashing_controls : HashingControls ,
32
29
}
33
30
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
-
47
31
impl < ' a > StableHashingContext < ' a > {
48
32
#[ inline]
49
33
pub fn new ( sess : & ' a Session , untracked : & ' a Untracked ) -> Self {
50
34
let hash_spans_initial = !sess. opts . unstable_opts . incremental_ignore_spans ;
51
35
52
36
StableHashingContext {
53
- body_resolver : BodyResolver :: Forbidden ,
54
37
untracked,
55
38
incremental_ignore_spans : sess. opts . unstable_opts . incremental_ignore_spans ,
56
39
caching_source_map : None ,
@@ -59,24 +42,6 @@ impl<'a> StableHashingContext<'a> {
59
42
}
60
43
}
61
44
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
-
80
45
#[ inline]
81
46
pub fn while_hashing_spans < F : FnOnce ( & mut Self ) > ( & mut self , hash_spans : bool , f : F ) {
82
47
let prev_hash_spans = self . hashing_controls . hash_spans ;
0 commit comments