@@ -31,7 +31,7 @@ pub struct TurboFn<'a> {
3131 /// Should we return `OperationVc` and require that all arguments are `NonLocalValue`s?
3232 operation : bool ,
3333 /// Should this function use `TaskPersistence::LocalCells`?
34- local_cells : bool ,
34+ local : bool ,
3535}
3636
3737#[ derive( Debug ) ]
@@ -274,7 +274,7 @@ impl TurboFn<'_> {
274274 this,
275275 inputs,
276276 operation : args. operation . is_some ( ) ,
277- local_cells : args. local_cells . is_some ( ) ,
277+ local : args. local . is_some ( ) ,
278278 inline_ident,
279279 } )
280280 }
@@ -479,9 +479,9 @@ impl TurboFn<'_> {
479479 }
480480
481481 pub fn persistence ( & self ) -> impl ToTokens {
482- if self . local_cells {
482+ if self . local {
483483 quote ! {
484- turbo_tasks:: TaskPersistence :: LocalCells
484+ turbo_tasks:: TaskPersistence :: Local
485485 }
486486 } else {
487487 quote ! {
@@ -491,9 +491,9 @@ impl TurboFn<'_> {
491491 }
492492
493493 pub fn persistence_with_this ( & self ) -> impl ToTokens {
494- if self . local_cells {
494+ if self . local {
495495 quote ! {
496- turbo_tasks:: TaskPersistence :: LocalCells
496+ turbo_tasks:: TaskPersistence :: Local
497497 }
498498 } else {
499499 quote ! {
@@ -703,6 +703,10 @@ pub struct FunctionArguments {
703703 ///
704704 /// If there is an error due to this option being set, it should be reported to this span.
705705 operation : Option < Span > ,
706+ /// Does not run the function as a real task, and instead runs it inside the parent task using
707+ /// task-local state. The function call itself will not be cached, but cells will be created on
708+ /// the parent task.
709+ pub local : Option < Span > ,
706710 /// Changes the behavior of `Vc::cell` to create local cells that are not cached across task
707711 /// executions. Cells can be converted to their non-local versions by calling `Vc::resolve`.
708712 ///
@@ -732,23 +736,29 @@ impl Parse for FunctionArguments {
732736 ( "operation" , Meta :: Path ( _) ) => {
733737 parsed_args. operation = Some ( meta. span ( ) ) ;
734738 }
739+ ( "local" , Meta :: Path ( _) ) => {
740+ parsed_args. local = Some ( meta. span ( ) ) ;
741+ }
735742 ( "local_cells" , Meta :: Path ( _) ) => {
736- let span = Some ( meta. span ( ) ) ;
737- parsed_args. local_cells = span;
743+ parsed_args. local_cells = Some ( meta. span ( ) ) ;
738744 }
739745 ( _, meta) => {
740746 return Err ( syn:: Error :: new_spanned (
741747 meta,
742748 "unexpected token, expected one of: \" fs\" , \" network\" , \" operation\" , \
743- or \" local_cells\" ",
749+ \" local \" , or \" local_cells\" ",
744750 ) )
745751 }
746752 }
747753 }
748- if let ( Some ( _) , Some ( span) ) = ( parsed_args. local_cells , parsed_args. operation ) {
754+ if let ( Some ( _) , Some ( span) ) = (
755+ parsed_args. local . or ( parsed_args. local_cells ) ,
756+ parsed_args. operation ,
757+ ) {
749758 return Err ( syn:: Error :: new (
750759 span,
751- "\" operation\" is mutually exclusive with the \" local_cells\" option" ,
760+ "\" operation\" is mutually exclusive with the \" local\" and \" local_cells\" \
761+ options",
752762 ) ) ;
753763 }
754764 Ok ( parsed_args)
@@ -1023,27 +1033,14 @@ impl DefinitionContext {
10231033
10241034#[ derive( Debug ) ]
10251035pub struct NativeFn {
1026- function_path_string : String ,
1027- function_path : ExprPath ,
1028- is_method : bool ,
1029- local_cells : bool ,
1036+ pub function_path_string : String ,
1037+ pub function_path : ExprPath ,
1038+ pub is_method : bool ,
1039+ pub local : bool ,
1040+ pub local_cells : bool ,
10301041}
10311042
10321043impl NativeFn {
1033- pub fn new (
1034- function_path_string : & str ,
1035- function_path : & ExprPath ,
1036- is_method : bool ,
1037- local_cells : bool ,
1038- ) -> NativeFn {
1039- NativeFn {
1040- function_path_string : function_path_string. to_owned ( ) ,
1041- function_path : function_path. clone ( ) ,
1042- is_method,
1043- local_cells,
1044- }
1045- }
1046-
10471044 pub fn ty ( & self ) -> Type {
10481045 parse_quote ! { turbo_tasks:: NativeFunction }
10491046 }
@@ -1053,6 +1050,7 @@ impl NativeFn {
10531050 function_path_string,
10541051 function_path,
10551052 is_method,
1053+ local,
10561054 local_cells,
10571055 } = self ;
10581056
@@ -1068,6 +1066,7 @@ impl NativeFn {
10681066 turbo_tasks:: NativeFunction :: #constructor(
10691067 #function_path_string. to_owned( ) ,
10701068 turbo_tasks:: FunctionMeta {
1069+ local: #local,
10711070 local_cells: #local_cells,
10721071 } ,
10731072 #function_path,
0 commit comments