@@ -8,21 +8,19 @@ pub mod place;
88
99use std:: sync:: Arc ;
1010
11- //use rustc_hir::def_id::LOCAL_CRATE;
1211use rustc_ast:: { self as ast} ;
1312use rustc_data_structures:: fingerprint:: Fingerprint ;
1413use rustc_data_structures:: fx:: FxIndexSet ;
1514use rustc_data_structures:: sorted_map:: SortedMap ;
1615use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1716use rustc_data_structures:: steal:: Steal ;
18- use rustc_data_structures:: svh:: Svh ;
1917use rustc_data_structures:: sync:: { DynSend , DynSync , try_par_for_each_in} ;
2018use rustc_hir:: def:: { DefKind , Res } ;
2119use rustc_hir:: def_id:: { DefId , LocalDefId , LocalModDefId } ;
2220use rustc_hir:: * ;
2321use rustc_index:: IndexVec ;
2422use rustc_macros:: { Decodable , Encodable , HashStable } ;
25- use rustc_span:: { ErrorGuaranteed , ExpnId , Span } ;
23+ use rustc_span:: { ErrorGuaranteed , ExpnId , HashStableContext , Span } ;
2624
2725use crate :: query:: Providers ;
2826use crate :: ty:: { ResolverAstLowering , TyCtxt } ;
@@ -33,8 +31,8 @@ use crate::ty::{ResolverAstLowering, TyCtxt};
3331/// For more details, see the [rustc dev guide].
3432///
3533/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
34+ #[ derive( Debug ) ]
3635pub struct Crate < ' hir > {
37- // tcx: TyCtxt<'hir>,
3836 // This field is private by intention, access it through `owner` method.
3937 owners : IndexVec < LocalDefId , MaybeOwner < ' hir > > ,
4038 // Ids of delayed AST owners which are lowered through `lower_delayed_owner` query.
@@ -43,27 +41,17 @@ pub struct Crate<'hir> {
4341 // and then stolen and dropped in `force_delayed_owners_lowering`.
4442 pub delayed_resolver : Steal < ( ResolverAstLowering < ' hir > , Arc < ast:: Crate > ) > ,
4543 // Only present when incr. comp. is enabled.
46- pub opt_hash : Option < Svh > ,
47- }
48-
49- impl std:: fmt:: Debug for Crate < ' _ > {
50- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
51- f. debug_struct ( "Crate" )
52- . field ( "owners" , & self . owners )
53- . field ( "delayed_ids" , & self . delayed_ids )
54- . field ( "delayed_resolver" , & self . delayed_resolver )
55- . finish ( )
56- }
44+ pub opt_hir_hash : Option < Fingerprint > ,
5745}
5846
5947impl < ' hir > Crate < ' hir > {
6048 pub fn new (
6149 owners : IndexVec < LocalDefId , MaybeOwner < ' hir > > ,
6250 delayed_ids : FxIndexSet < LocalDefId > ,
6351 delayed_resolver : Steal < ( ResolverAstLowering < ' hir > , Arc < ast:: Crate > ) > ,
64- opt_hash : Option < Svh > ,
52+ opt_hir_hash : Option < Fingerprint > ,
6553 ) -> Crate < ' hir > {
66- Crate { owners, delayed_ids, delayed_resolver, opt_hash }
54+ Crate { owners, delayed_ids, delayed_resolver, opt_hir_hash }
6755 }
6856
6957 /// Serves as an entry point for getting `MaybeOwner`. As owner can either be in
@@ -88,11 +76,12 @@ impl<'hir> Crate<'hir> {
8876 }
8977}
9078
91- /* impl<Hcx: HashStableContext> HashStable<Hcx> for Crate<'_> {
79+ impl < Hcx : HashStableContext > HashStable < Hcx > for Crate < ' _ > {
9280 fn hash_stable ( & self , hcx : & mut Hcx , hasher : & mut StableHasher ) {
93- self.tcx.crate_hash(LOCAL_CRATE).hash_stable(hcx, hasher)
81+ let Crate { opt_hir_hash, .. } = self ;
82+ opt_hir_hash. unwrap ( ) . hash_stable ( hcx, hasher)
9483 }
95- }*/
84+ }
9685
9786/// Gather the LocalDefId for each item-like within a module, including items contained within
9887/// bodies. The Ids are in visitor order. This is used to partition a pass between modules.
0 commit comments