diff --git a/crates/turbo-tasks-fetch/src/lib.rs b/crates/turbo-tasks-fetch/src/lib.rs index 7cb59d1039b37..c4f3e12e0f164 100644 --- a/crates/turbo-tasks-fetch/src/lib.rs +++ b/crates/turbo-tasks-fetch/src/lib.rs @@ -46,7 +46,7 @@ pub enum ProxyConfig { #[turbo_tasks::value(transparent)] pub struct OptionProxyConfig(Option); -#[turbo_tasks::function] +#[turbo_tasks::function(network)] pub async fn fetch( url: Vc, user_agent: Vc>, diff --git a/crates/turbo-tasks-fs/src/attach.rs b/crates/turbo-tasks-fs/src/attach.rs index f9b70352f660d..7705aad035361 100644 --- a/crates/turbo-tasks-fs/src/attach.rs +++ b/crates/turbo-tasks-fs/src/attach.rs @@ -121,17 +121,17 @@ impl AttachedFileSystem { #[turbo_tasks::value_impl] impl FileSystem for AttachedFileSystem { - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] fn read(self: Vc, path: Vc) -> Vc { self.get_inner_fs_path(path).read() } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] fn read_link(self: Vc, path: Vc) -> Vc { self.get_inner_fs_path(path).read_link() } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn read_dir(self: Vc, path: Vc) -> Result> { let dir_content = self.get_inner_fs_path(path).read_dir().await?; let entries = match &*dir_content { @@ -157,17 +157,17 @@ impl FileSystem for AttachedFileSystem { Ok(DirectoryContent::new(converted_entries)) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] fn track(self: Vc, path: Vc) -> Vc { self.get_inner_fs_path(path).track() } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] fn write(self: Vc, path: Vc, content: Vc) -> Vc { self.get_inner_fs_path(path).write(content) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] fn write_link( self: Vc, path: Vc, diff --git a/crates/turbo-tasks-fs/src/lib.rs b/crates/turbo-tasks-fs/src/lib.rs index 75409f6ee39d5..ce8bac1752816 100644 --- a/crates/turbo-tasks-fs/src/lib.rs +++ b/crates/turbo-tasks-fs/src/lib.rs @@ -317,7 +317,7 @@ impl Debug for DiskFileSystem { #[turbo_tasks::value_impl] impl FileSystem for DiskFileSystem { - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn read(&self, fs_path: Vc) -> Result> { let full_path = self.to_sys_path(fs_path).await?; self.register_invalidator(&full_path)?; @@ -341,7 +341,7 @@ impl FileSystem for DiskFileSystem { Ok(content.cell()) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn read_dir(&self, fs_path: Vc) -> Result> { let full_path = self.to_sys_path(fs_path).await?; self.register_dir_invalidator(&full_path)?; @@ -400,7 +400,7 @@ impl FileSystem for DiskFileSystem { Ok(DirectoryContent::new(entries)) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn read_link(&self, fs_path: Vc) -> Result> { let full_path = self.to_sys_path(fs_path).await?; self.register_invalidator(&full_path)?; @@ -484,14 +484,14 @@ impl FileSystem for DiskFileSystem { .cell()) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn track(&self, fs_path: Vc) -> Result> { let full_path = self.to_sys_path(fs_path).await?; self.register_invalidator(&full_path)?; Ok(Completion::new()) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn write( &self, fs_path: Vc, @@ -605,7 +605,7 @@ impl FileSystem for DiskFileSystem { Ok(Completion::new()) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn write_link( &self, fs_path: Vc, @@ -692,7 +692,7 @@ impl FileSystem for DiskFileSystem { Ok(Completion::new()) } - #[turbo_tasks::function] + #[turbo_tasks::function(fs)] async fn metadata(&self, fs_path: Vc) -> Result> { let full_path = self.to_sys_path(fs_path).await?; self.register_invalidator(&full_path)?; diff --git a/crates/turbo-tasks-fs/src/read_glob.rs b/crates/turbo-tasks-fs/src/read_glob.rs index f026d23bca269..829ae206bf6b5 100644 --- a/crates/turbo-tasks-fs/src/read_glob.rs +++ b/crates/turbo-tasks-fs/src/read_glob.rs @@ -16,7 +16,7 @@ pub struct ReadGlobResult { /// /// DETERMINISM: Result is in random order. Either sort result or do not depend /// on the order. -#[turbo_tasks::function] +#[turbo_tasks::function(fs)] pub async fn read_glob( directory: Vc, glob: Vc, @@ -25,7 +25,7 @@ pub async fn read_glob( read_glob_internal("", directory, glob, include_dot_files).await } -#[turbo_tasks::function] +#[turbo_tasks::function(fs)] async fn read_glob_inner( prefix: RcStr, directory: Vc, diff --git a/crates/turbo-tasks-macros/src/function_macro.rs b/crates/turbo-tasks-macros/src/function_macro.rs index 4c047d0e067a5..519abdb8f4ebe 100644 --- a/crates/turbo-tasks-macros/src/function_macro.rs +++ b/crates/turbo-tasks-macros/src/function_macro.rs @@ -6,6 +6,25 @@ use turbo_tasks_macros_shared::{get_native_function_id_ident, get_native_functio use crate::func::{DefinitionContext, NativeFn, TurboFn}; +/// This macro generates the virtual function that powers turbo tasks. +/// An annotated task is replaced with a stub function that returns a +/// lazy completion (Vc), and stamps out the concrete implementation +/// of the task alongside that the Vc uses to resolve itself. +/// +/// Functions support being tagged for informational purposes. This +/// is currently only used in turbo-static for doing static analysis +/// of tasks. +/// +/// # Examples +/// +/// ```rust +/// use turbo_tasks::{Vc}; +/// +/// #[turbo_tasks::function(fs)] +/// async fn my_task() -> Vc { +/// // access filesystem +/// } +/// ``` pub fn function(_args: TokenStream, input: TokenStream) -> TokenStream { let item = parse_macro_input!(input as ItemFn);