@@ -8,19 +8,21 @@ pub mod place;
88
99use std:: sync:: Arc ;
1010
11+ //use rustc_hir::def_id::LOCAL_CRATE;
1112use rustc_ast:: { self as ast} ;
1213use rustc_data_structures:: fingerprint:: Fingerprint ;
1314use rustc_data_structures:: fx:: FxIndexSet ;
1415use rustc_data_structures:: sorted_map:: SortedMap ;
1516use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1617use rustc_data_structures:: steal:: Steal ;
18+ use rustc_data_structures:: svh:: Svh ;
1719use rustc_data_structures:: sync:: { DynSend , DynSync , try_par_for_each_in} ;
1820use rustc_hir:: def:: { DefKind , Res } ;
1921use rustc_hir:: def_id:: { DefId , LocalDefId , LocalModDefId } ;
2022use rustc_hir:: * ;
2123use rustc_index:: IndexVec ;
2224use rustc_macros:: { Decodable , Encodable , HashStable } ;
23- use rustc_span:: { ErrorGuaranteed , ExpnId , HashStableContext , Span } ;
25+ use rustc_span:: { ErrorGuaranteed , ExpnId , Span } ;
2426
2527use crate :: query:: Providers ;
2628use crate :: ty:: { ResolverAstLowering , TyCtxt } ;
@@ -31,8 +33,8 @@ use crate::ty::{ResolverAstLowering, TyCtxt};
3133/// For more details, see the [rustc dev guide].
3234///
3335/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
34- #[ derive( Debug ) ]
3536pub struct Crate < ' hir > {
37+ // tcx: TyCtxt<'hir>,
3638 // This field is private by intention, access it through `owner` method.
3739 owners : IndexVec < LocalDefId , MaybeOwner < ' hir > > ,
3840 // Ids of delayed AST owners which are lowered through `lower_delayed_owner` query.
@@ -41,17 +43,27 @@ pub struct Crate<'hir> {
4143 // and then stolen and dropped in `force_delayed_owners_lowering`.
4244 pub delayed_resolver : Steal < ( ResolverAstLowering < ' hir > , Arc < ast:: Crate > ) > ,
4345 // Only present when incr. comp. is enabled.
44- pub opt_hir_hash : Option < Fingerprint > ,
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+ }
4557}
4658
4759impl < ' hir > Crate < ' hir > {
4860 pub fn new (
4961 owners : IndexVec < LocalDefId , MaybeOwner < ' hir > > ,
5062 delayed_ids : FxIndexSet < LocalDefId > ,
5163 delayed_resolver : Steal < ( ResolverAstLowering < ' hir > , Arc < ast:: Crate > ) > ,
52- opt_hir_hash : Option < Fingerprint > ,
64+ opt_hash : Option < Svh > ,
5365 ) -> Crate < ' hir > {
54- Crate { owners, delayed_ids, delayed_resolver, opt_hir_hash }
66+ Crate { owners, delayed_ids, delayed_resolver, opt_hash }
5567 }
5668
5769 /// Serves as an entry point for getting `MaybeOwner`. As owner can either be in
@@ -76,12 +88,11 @@ impl<'hir> Crate<'hir> {
7688 }
7789}
7890
79- impl < Hcx : HashStableContext > HashStable < Hcx > for Crate < ' _ > {
91+ /* impl<Hcx: HashStableContext> HashStable<Hcx> for Crate<'_> {
8092 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
81- let Crate { opt_hir_hash, .. } = self ;
82- opt_hir_hash. unwrap ( ) . hash_stable ( hcx, hasher)
93+ self.tcx.crate_hash(LOCAL_CRATE).hash_stable(hcx, hasher)
8394 }
84- }
95+ }*/
8596
8697/// Gather the LocalDefId for each item-like within a module, including items contained within
8798/// bodies. The Ids are in visitor order. This is used to partition a pass between modules.
0 commit comments