@@ -424,6 +424,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
424
424
consistency : ReadConsistency ,
425
425
turbo_tasks : & dyn TurboTasksBackendApi < TurboTasksBackend < B > > ,
426
426
) -> Result < Result < RawVc , EventListener > > {
427
+ if let Some ( reader) = reader {
428
+ self . assert_not_persistent_calling_transient ( reader, task_id) ;
429
+ }
430
+
427
431
let mut ctx = self . execute_context ( turbo_tasks) ;
428
432
let mut task = ctx. task ( task_id, TaskDataCategory :: All ) ;
429
433
@@ -620,6 +624,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
620
624
options : ReadCellOptions ,
621
625
turbo_tasks : & dyn TurboTasksBackendApi < TurboTasksBackend < B > > ,
622
626
) -> Result < Result < TypedCellContent , EventListener > > {
627
+ if let Some ( reader) = reader {
628
+ self . assert_not_persistent_calling_transient ( reader, task_id) ;
629
+ }
630
+
623
631
fn add_cell_dependency < B : BackingStorage > (
624
632
backend : & TurboTasksBackendInner < B > ,
625
633
mut task : impl TaskGuard ,
@@ -977,11 +985,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
977
985
turbo_tasks : & dyn TurboTasksBackendApi < TurboTasksBackend < B > > ,
978
986
) -> TaskId {
979
987
if !parent_task. is_transient ( ) {
980
- let parent_task_type = self . lookup_task_type ( parent_task) ;
981
- panic ! (
982
- "Calling transient function {} from persistent function {} is not allowed" ,
983
- task_type. get_name( ) ,
984
- parent_task_type. map_or( "unknown" , |t| t. get_name( ) )
988
+ panic_persistent_calling_transient (
989
+ self . lookup_task_type ( parent_task) . as_deref ( ) ,
990
+ Some ( & task_type) ,
985
991
) ;
986
992
}
987
993
if let Some ( task_id) = self . task_cache . lookup_forward ( & task_type) {
@@ -1980,6 +1986,15 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1980
1986
root_state. all_clean_event . notify ( usize:: MAX ) ;
1981
1987
}
1982
1988
}
1989
+
1990
+ fn assert_not_persistent_calling_transient ( & self , parent_id : TaskId , child_id : TaskId ) {
1991
+ if !parent_id. is_transient ( ) && child_id. is_transient ( ) {
1992
+ panic_persistent_calling_transient (
1993
+ self . lookup_task_type ( parent_id) . as_deref ( ) ,
1994
+ self . lookup_task_type ( child_id) . as_deref ( ) ,
1995
+ ) ;
1996
+ }
1997
+ }
1983
1998
}
1984
1999
1985
2000
impl < B : BackingStorage > Backend for TurboTasksBackend < B > {
@@ -2257,6 +2272,17 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
2257
2272
}
2258
2273
}
2259
2274
2275
+ fn panic_persistent_calling_transient (
2276
+ parent : Option < & CachedTaskType > ,
2277
+ child : Option < & CachedTaskType > ,
2278
+ ) {
2279
+ panic ! (
2280
+ "Persistent task {} is not allowed to call or read transient tasks {}" ,
2281
+ parent. map_or( "unknown" , |t| t. get_name( ) ) ,
2282
+ child. map_or( "unknown" , |t| t. get_name( ) ) ,
2283
+ ) ;
2284
+ }
2285
+
2260
2286
// from https://github.com/tokio-rs/tokio/blob/29cd6ec1ec6f90a7ee1ad641c03e0e00badbcb0e/tokio/src/time/instant.rs#L57-L63
2261
2287
fn far_future ( ) -> Instant {
2262
2288
// Roughly 30 years from now.
0 commit comments