@@ -878,7 +878,12 @@ impl<'tcx> TyCtxt<'tcx> {
878
878
// If this is a DefPathHash from the local crate, we can look up the
879
879
// DefId in the tcx's `Definitions`.
880
880
if stable_crate_id == self . stable_crate_id ( LOCAL_CRATE ) {
881
- self . untracked . definitions . read ( ) . local_def_path_hash_to_def_id ( hash, err) . to_def_id ( )
881
+ self . untracked
882
+ . definitions
883
+ . read ( )
884
+ . unwrap ( )
885
+ . local_def_path_hash_to_def_id ( hash, err)
886
+ . to_def_id ( )
882
887
} else {
883
888
// If this is a DefPathHash from an upstream crate, let the CrateStore map
884
889
// it to a DefId.
@@ -938,7 +943,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
938
943
// This is fine because:
939
944
// - those queries are `eval_always` so we won't miss their result changing;
940
945
// - this write will have happened before these queries are called.
941
- let key = self . untracked . definitions . write ( ) . create_def ( parent, data) ;
946
+ let key = self . untracked . definitions . write ( ) . unwrap ( ) . create_def ( parent, data) ;
942
947
943
948
let feed = TyCtxtFeed { tcx : self . tcx , key } ;
944
949
feed. def_span ( self . span ) ;
@@ -958,14 +963,14 @@ impl<'tcx> TyCtxt<'tcx> {
958
963
959
964
// Recompute the number of definitions each time, because our caller may be creating
960
965
// new ones.
961
- while i < { definitions. read ( ) . num_definitions ( ) } {
966
+ while i < { definitions. read ( ) . unwrap ( ) . num_definitions ( ) } {
962
967
let local_def_index = rustc_span:: def_id:: DefIndex :: from_usize ( i) ;
963
968
yield LocalDefId { local_def_index } ;
964
969
i += 1 ;
965
970
}
966
971
967
972
// Leak a read lock once we finish iterating on definitions, to prevent adding new ones.
968
- definitions. leak ( ) ;
973
+ std :: mem :: forget ( definitions. read ( ) ) ;
969
974
} )
970
975
}
971
976
@@ -976,8 +981,9 @@ impl<'tcx> TyCtxt<'tcx> {
976
981
977
982
// Leak a read lock once we start iterating on definitions, to prevent adding new ones
978
983
// while iterating. If some query needs to add definitions, it should be `ensure`d above.
979
- let definitions = self . untracked . definitions . leak ( ) ;
980
- definitions. def_path_table ( )
984
+ std:: mem:: forget ( self . untracked . definitions . read ( ) ) ;
985
+ let definitions = self . untracked . definitions . read ( ) . unwrap ( ) ;
986
+ unsafe { & * ( definitions. def_path_table ( ) as * const rustc_hir:: definitions:: DefPathTable ) }
981
987
}
982
988
983
989
pub fn def_path_hash_to_def_index_map (
@@ -988,8 +994,12 @@ impl<'tcx> TyCtxt<'tcx> {
988
994
self . ensure ( ) . hir_crate ( ( ) ) ;
989
995
// Leak a read lock once we start iterating on definitions, to prevent adding new ones
990
996
// while iterating. If some query needs to add definitions, it should be `ensure`d above.
991
- let definitions = self . untracked . definitions . leak ( ) ;
992
- definitions. def_path_hash_to_def_index_map ( )
997
+ std:: mem:: forget ( self . untracked . definitions . read ( ) ) ;
998
+ let definitions = self . untracked . definitions . read ( ) . unwrap ( ) ;
999
+ unsafe {
1000
+ & * ( definitions. def_path_hash_to_def_index_map ( )
1001
+ as * const rustc_hir:: def_path_hash_map:: DefPathHashMap )
1002
+ }
993
1003
}
994
1004
995
1005
/// Note that this is *untracked* and should only be used within the query
@@ -1006,8 +1016,8 @@ impl<'tcx> TyCtxt<'tcx> {
1006
1016
/// Note that this is *untracked* and should only be used within the query
1007
1017
/// system if the result is otherwise tracked through queries
1008
1018
#[ inline]
1009
- pub fn definitions_untracked ( self ) -> ReadGuard < ' tcx , Definitions > {
1010
- self . untracked . definitions . read ( )
1019
+ pub fn definitions_untracked ( self ) -> std :: sync :: RwLockReadGuard < ' tcx , Definitions > {
1020
+ self . untracked . definitions . read ( ) . unwrap ( )
1011
1021
}
1012
1022
1013
1023
/// Note that this is *untracked* and should only be used within the query
0 commit comments