@@ -28,6 +28,7 @@ use super::{DepKind, DepNode, WorkProductId, read_deps, with_deps};
2828use crate :: dep_graph:: edges:: EdgesVec ;
2929use crate :: ich:: StableHashingContext ;
3030use crate :: ty:: TyCtxt ;
31+ use crate :: ty:: tls:: is_sandbox;
3132use crate :: verify_ich:: incremental_verify_ich;
3233
3334/// Tracks 'side effects' for a particular query.
@@ -187,23 +188,23 @@ impl DepGraph {
187188
188189 #[ inline]
189190 pub fn data ( & self ) -> Option < & DepGraphData > {
190- self . data . as_deref ( )
191+ self . data . as_deref ( ) . filter ( |_| ! is_sandbox ( ) )
191192 }
192193
193194 /// Returns `true` if we are actually building the full dep-graph, and `false` otherwise.
194195 #[ inline]
195196 pub fn is_fully_enabled ( & self ) -> bool {
196- self . data . is_some ( )
197+ self . data ( ) . is_some ( )
197198 }
198199
199200 pub fn with_retained_dep_graph ( & self , f : impl Fn ( & RetainedDepGraph ) ) {
200- if let Some ( data) = & self . data {
201+ if let Some ( data) = self . data ( ) {
201202 data. current . encoder . with_retained_dep_graph ( f)
202203 }
203204 }
204205
205206 pub fn assert_ignored ( & self ) {
206- if let Some ( ..) = self . data {
207+ if let Some ( ..) = self . data ( ) {
207208 read_deps ( |task_deps| {
208209 assert_matches ! (
209210 task_deps,
@@ -450,7 +451,7 @@ impl DepGraphData {
450451impl DepGraph {
451452 #[ inline]
452453 pub fn read_index ( & self , dep_node_index : DepNodeIndex ) {
453- if let Some ( ref data) = self . data {
454+ if let Some ( ref data) = self . data ( ) {
454455 read_deps ( |task_deps| {
455456 let mut task_deps = match task_deps {
456457 TaskDepsRef :: Allow ( deps) => deps. lock ( ) ,
@@ -507,7 +508,7 @@ impl DepGraph {
507508 /// it with the node, for use in the next session.
508509 #[ inline]
509510 pub fn record_diagnostic < ' tcx > ( & self , tcx : TyCtxt < ' tcx > , diagnostic : & DiagInner ) {
510- if let Some ( ref data) = self . data {
511+ if let Some ( ref data) = self . data ( ) {
511512 read_deps ( |task_deps| match task_deps {
512513 TaskDepsRef :: EvalAlways | TaskDepsRef :: Ignore => return ,
513514 TaskDepsRef :: Forbid | TaskDepsRef :: Allow ( ..) => {
@@ -522,7 +523,7 @@ impl DepGraph {
522523 /// refer to a node created used `encode_side_effect` in the previous session.
523524 #[ inline]
524525 pub fn force_side_effect < ' tcx > ( & self , tcx : TyCtxt < ' tcx > , prev_index : SerializedDepNodeIndex ) {
525- if let Some ( ref data) = self . data {
526+ if let Some ( ref data) = self . data ( ) {
526527 data. force_side_effect ( tcx, prev_index) ;
527528 }
528529 }
@@ -533,7 +534,7 @@ impl DepGraph {
533534 tcx : TyCtxt < ' tcx > ,
534535 side_effect : QuerySideEffect ,
535536 ) -> DepNodeIndex {
536- if let Some ( ref data) = self . data {
537+ if let Some ( ref data) = self . data ( ) {
537538 data. encode_side_effect ( tcx, side_effect)
538539 } else {
539540 self . next_virtual_depnode_index ( )
@@ -563,7 +564,7 @@ impl DepGraph {
563564 hash_result : Option < fn ( & mut StableHashingContext < ' _ > , & R ) -> Fingerprint > ,
564565 format_value_fn : fn ( & R ) -> String ,
565566 ) -> DepNodeIndex {
566- if let Some ( data) = self . data . as_ref ( ) {
567+ if let Some ( data) = self . data ( ) . as_ref ( ) {
567568 // The caller query has more dependencies than the node we are creating. We may
568569 // encounter a case where this created node is marked as green, but the caller query is
569570 // subsequently marked as red or recomputed. In this case, we will end up feeding a
@@ -808,23 +809,23 @@ impl DepGraph {
808809 /// Checks whether a previous work product exists for `v` and, if
809810 /// so, return the path that leads to it. Used to skip doing work.
810811 pub fn previous_work_product ( & self , v : & WorkProductId ) -> Option < WorkProduct > {
811- self . data . as_ref ( ) . and_then ( |data| data. previous_work_products . get ( v) . cloned ( ) )
812+ self . data ( ) . as_ref ( ) . and_then ( |data| data. previous_work_products . get ( v) . cloned ( ) )
812813 }
813814
814815 /// Access the map of work-products created during the cached run. Only
815816 /// used during saving of the dep-graph.
816817 pub fn previous_work_products ( & self ) -> & WorkProductMap {
817- & self . data . as_ref ( ) . unwrap ( ) . previous_work_products
818+ & self . data ( ) . as_ref ( ) . unwrap ( ) . previous_work_products
818819 }
819820
820821 pub fn debug_was_loaded_from_disk ( & self , dep_node : DepNode ) -> bool {
821- self . data . as_ref ( ) . unwrap ( ) . debug_loaded_from_disk . lock ( ) . contains ( & dep_node)
822+ self . data ( ) . as_ref ( ) . unwrap ( ) . debug_loaded_from_disk . lock ( ) . contains ( & dep_node)
822823 }
823824
824825 pub fn debug_dep_kind_was_loaded_from_disk ( & self , dep_kind : DepKind ) -> bool {
825826 // We only check if we have a dep node corresponding to the given dep kind.
826827 #[ allow( rustc:: potential_query_instability) ]
827- self . data
828+ self . data ( )
828829 . as_ref ( )
829830 . unwrap ( )
830831 . debug_loaded_from_disk
@@ -834,7 +835,7 @@ impl DepGraph {
834835 }
835836
836837 fn node_color ( & self , dep_node : & DepNode ) -> DepNodeColor {
837- if let Some ( ref data) = self . data {
838+ if let Some ( ref data) = self . data ( ) {
838839 return data. node_color ( dep_node) ;
839840 }
840841
@@ -980,7 +981,7 @@ impl DepGraph {
980981 dep_node : & DepNode ,
981982 msg : impl FnOnce ( ) -> S ,
982983 ) {
983- if let Some ( data) = & self . data {
984+ if let Some ( data) = & self . data ( ) {
984985 data. assert_dep_node_not_yet_allocated_in_current_session ( sess, dep_node, msg)
985986 }
986987 }
@@ -996,7 +997,7 @@ impl DepGraph {
996997 pub fn exec_cache_promotions < ' tcx > ( & self , tcx : TyCtxt < ' tcx > ) {
997998 let _prof_timer = tcx. prof . generic_activity ( "incr_comp_query_cache_promotion" ) ;
998999
999- let data = self . data . as_ref ( ) . unwrap ( ) ;
1000+ let data = self . data ( ) . unwrap ( ) ;
10001001 for prev_index in data. colors . values . indices ( ) {
10011002 match data. colors . get ( prev_index) {
10021003 DepNodeColor :: Green ( _) => {
@@ -1017,11 +1018,15 @@ impl DepGraph {
10171018 }
10181019
10191020 pub ( crate ) fn finish_encoding ( & self ) -> FileEncodeResult {
1020- if let Some ( data) = & self . data { data. current . encoder . finish ( & data. current ) } else { Ok ( 0 ) }
1021+ if let Some ( data) = & self . data ( ) {
1022+ data. current . encoder . finish ( & data. current )
1023+ } else {
1024+ Ok ( 0 )
1025+ }
10211026 }
10221027
10231028 pub fn next_virtual_depnode_index ( & self ) -> DepNodeIndex {
1024- debug_assert ! ( self . data. is_none( ) ) ;
1029+ debug_assert ! ( self . data( ) . is_none( ) || is_sandbox ( ) ) ;
10251030 let index = self . virtual_dep_node_index . fetch_add ( 1 , Ordering :: Relaxed ) ;
10261031 DepNodeIndex :: from_u32 ( index)
10271032 }
@@ -1396,7 +1401,7 @@ pub(super) enum TrySetColorResult {
13961401#[ inline( never) ]
13971402#[ cold]
13981403pub ( crate ) fn print_markframe_trace ( graph : & DepGraph , frame : & MarkFrame < ' _ > ) {
1399- let data = graph. data . as_ref ( ) . unwrap ( ) ;
1404+ let data = graph. data ( ) . unwrap ( ) ;
14001405
14011406 eprintln ! ( "there was a panic while trying to force a dep node" ) ;
14021407 eprintln ! ( "try_mark_green dep node stack:" ) ;
0 commit comments