Unverified Commit 041c9413 authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

Require that `turbo_tasks::value_trait` items be annotated with `turbo-tasks::function` (#79178)

On its own this is just adding pure overhead.  The next step will be to make it _optional_ for a value_trait item to be a turbo-tasks function.

Part of PACK-4560
parent 7114fd23
...@@ -49,14 +49,19 @@ pub enum Route { ...@@ -49,14 +49,19 @@ pub enum Route {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait Endpoint { pub trait Endpoint {
#[turbo_tasks::function]
fn output(self: Vc<Self>) -> Vc<EndpointOutput>; fn output(self: Vc<Self>) -> Vc<EndpointOutput>;
// fn write_to_disk(self: Vc<Self>) -> Vc<EndpointOutputPaths>; // fn write_to_disk(self: Vc<Self>) -> Vc<EndpointOutputPaths>;
#[turbo_tasks::function]
fn server_changed(self: Vc<Self>) -> Vc<Completion>; fn server_changed(self: Vc<Self>) -> Vc<Completion>;
#[turbo_tasks::function]
fn client_changed(self: Vc<Self>) -> Vc<Completion>; fn client_changed(self: Vc<Self>) -> Vc<Completion>;
/// The entry modules for the modules graph. /// The entry modules for the modules graph.
#[turbo_tasks::function]
fn entries(self: Vc<Self>) -> Vc<GraphEntries>; fn entries(self: Vc<Self>) -> Vc<GraphEntries>;
/// Additional entry modules for the module graph. /// Additional entry modules for the module graph.
/// This may read the module graph and return additional modules. /// This may read the module graph and return additional modules.
#[turbo_tasks::function]
fn additional_entries(self: Vc<Self>, _graph: Vc<ModuleGraph>) -> Vc<GraphEntries> { fn additional_entries(self: Vc<Self>, _graph: Vc<ModuleGraph>) -> Vc<GraphEntries> {
GraphEntries::empty() GraphEntries::empty()
} }
......
...@@ -49,9 +49,11 @@ pub trait ProcessEnv { ...@@ -49,9 +49,11 @@ pub trait ProcessEnv {
// Instead we should use only `read_prefix` to read all env vars with a specific // Instead we should use only `read_prefix` to read all env vars with a specific
// prefix. // prefix.
/// Reads all env variables into a Map /// Reads all env variables into a Map
#[turbo_tasks::function]
fn read_all(self: Vc<Self>) -> Vc<EnvMap>; fn read_all(self: Vc<Self>) -> Vc<EnvMap>;
/// Reads a single env variable. Ignores casing. /// Reads a single env variable. Ignores casing.
#[turbo_tasks::function]
fn read(self: Vc<Self>, name: RcStr) -> Vc<Option<RcStr>> { fn read(self: Vc<Self>, name: RcStr) -> Vc<Option<RcStr>> {
case_insensitive_read(self.read_all(), name) case_insensitive_read(self.read_all(), name)
} }
......
...@@ -195,14 +195,21 @@ fn create_semaphore() -> tokio::sync::Semaphore { ...@@ -195,14 +195,21 @@ fn create_semaphore() -> tokio::sync::Semaphore {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait FileSystem: ValueToString { pub trait FileSystem: ValueToString {
/// Returns the path to the root of the file system. /// Returns the path to the root of the file system.
#[turbo_tasks::function]
fn root(self: Vc<Self>) -> Vc<FileSystemPath> { fn root(self: Vc<Self>) -> Vc<FileSystemPath> {
FileSystemPath::new_normalized(self, RcStr::default()) FileSystemPath::new_normalized(self, RcStr::default())
} }
#[turbo_tasks::function]
fn read(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<FileContent>; fn read(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<FileContent>;
#[turbo_tasks::function]
fn read_link(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<LinkContent>; fn read_link(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<LinkContent>;
#[turbo_tasks::function]
fn raw_read_dir(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<RawDirectoryContent>; fn raw_read_dir(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<RawDirectoryContent>;
#[turbo_tasks::function]
fn write(self: Vc<Self>, fs_path: Vc<FileSystemPath>, content: Vc<FileContent>) -> Vc<()>; fn write(self: Vc<Self>, fs_path: Vc<FileSystemPath>, content: Vc<FileContent>) -> Vc<()>;
#[turbo_tasks::function]
fn write_link(self: Vc<Self>, fs_path: Vc<FileSystemPath>, target: Vc<LinkContent>) -> Vc<()>; fn write_link(self: Vc<Self>, fs_path: Vc<FileSystemPath>, target: Vc<LinkContent>) -> Vc<()>;
#[turbo_tasks::function]
fn metadata(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<FileMeta>; fn metadata(self: Vc<Self>, fs_path: Vc<FileSystemPath>) -> Vc<FileMeta>;
} }
......
...@@ -3,3 +3,17 @@ error: unexpected token, expected one of: "fs", "network", "operation", "local" ...@@ -3,3 +3,17 @@ error: unexpected token, expected one of: "fs", "network", "operation", "local"
| |
14 | #[turbo_tasks::function(invalid_argument)] 14 | #[turbo_tasks::function(invalid_argument)]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
warning: unused import: `Vc`
--> tests/function/fail_attribute_invalid_args_inherent_impl.rs:4:31
|
4 | use turbo_tasks::{ResolvedVc, Vc};
| ^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0599]: no method named `return_contains_resolved_vc` found for struct `Vc<ExampleStruct>` in the current scope
--> tests/function/fail_attribute_invalid_args_inherent_impl.rs:23:34
|
23 | let _ = ExampleStruct.cell().return_contains_resolved_vc();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `Vc<ExampleStruct>`
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)]
use turbo_tasks::Vc;
#[turbo_tasks::value_trait]
trait MyTrait {
fn item(&self) -> bool;
#[turbo_tasks::function]
fn item2(&self) -> Vc<bool>;
#[turbo_tasks::function(operation)]
fn item3(&self) -> Vc<bool>;
}
#[turbo_tasks::value]
struct MyStruct;
#[turbo_tasks::value_impl]
impl MyTrait for MyStruct {
fn item(&self) -> bool {
true
}
#[turbo_tasks::function]
fn item2(&self) -> Vc<bool> {
Vc::cell(true)
}
#[turbo_tasks::function]
fn item3(&self) -> Vc<bool> {
Vc::cell(true)
}
}
fn expects_my_trait(_x: impl MyTrait) {}
fn main() {
expects_my_trait(MyStruct {});
}
error: trait items cannot be operations
--> tests/value_trait/fail_missing_function_annotation.rs:13:29
|
13 | #[turbo_tasks::function(operation)]
| ^^^^^^^^^
error: #[turbo_tasks::function] attribute missing
--> tests/value_trait/fail_missing_function_annotation.rs:8:5
|
8 | fn item(&self) -> bool;
| ^^^^^^^^^^^^^^^^^^^^^^^
error: #[turbo_tasks::function] attribute missing
--> tests/value_trait/fail_missing_function_annotation.rs:22:5
|
22 | / fn item(&self) -> bool {
23 | | true
24 | | }
| |_____^
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)]
use turbo_tasks::Vc;
#[turbo_tasks::value_trait]
trait MyTrait {
#[turbo_tasks::function]
fn item(&self) -> Vc<bool>;
#[turbo_tasks::function]
fn item2(&self) -> Vc<bool>;
#[turbo_tasks::function]
fn item3(&self) -> Vc<bool>;
}
#[turbo_tasks::value]
struct MyStruct;
#[turbo_tasks::value_impl]
impl MyTrait for MyStruct {
#[turbo_tasks::function]
fn item(&self) -> Vc<bool> {
Vc::cell(true)
}
#[turbo_tasks::function]
fn item2(&self) -> Vc<bool> {
Vc::cell(true)
}
#[turbo_tasks::function]
fn item3(&self) -> Vc<bool> {
Vc::cell(true)
}
}
fn expects_my_trait(_x: impl MyTrait) {}
fn main() {
expects_my_trait(MyStruct {});
}
...@@ -1195,3 +1195,48 @@ pub fn inline_inputs_identifier_filter(arg_ident: &Ident) -> bool { ...@@ -1195,3 +1195,48 @@ pub fn inline_inputs_identifier_filter(arg_ident: &Ident) -> bool {
// filter out underscore-prefixed (unused) arguments, we don't need to cache these // filter out underscore-prefixed (unused) arguments, we don't need to cache these
!arg_ident.to_string().starts_with('_') !arg_ident.to_string().starts_with('_')
} }
/// Returns true if this attribute is a turbo_tasks attribute with the given name.
fn is_attribute(attr: &Attribute, name: &str) -> bool {
let path = &attr.path();
if path.leading_colon.is_some() {
return false;
}
let mut iter = path.segments.iter();
match iter.next() {
Some(seg) if seg.arguments.is_empty() && seg.ident == "turbo_tasks" => match iter.next() {
Some(seg) if seg.arguments.is_empty() && seg.ident == name => iter.next().is_none(),
_ => false,
},
_ => false,
}
}
/// Parses a `turbo_tasks::function` attribute out of the given attributes and then returns the
/// remaining attributes.
pub fn split_function_attributes<'a>(
item: &'a impl Spanned,
attrs: &'a [Attribute],
) -> (syn::Result<FunctionArguments>, Vec<&'a Attribute>) {
let (func_attrs_vec, attrs): (Vec<_>, Vec<_>) = attrs
.iter()
// TODO(alexkirsz) Replace this with function
.partition(|attr| is_attribute(attr, "function"));
let func_args = if let Some(func_attr) = func_attrs_vec.first() {
if func_attrs_vec.len() == 1 {
parse_with_optional_parens::<FunctionArguments>(func_attr)
} else {
Err(syn::Error::new(
// Report the error on the second annotation.
func_attrs_vec[1].span(),
"Only one #[turbo_tasks::function] attribute is allowed per method",
))
}
} else {
Err(syn::Error::new(
item.span(),
"#[turbo_tasks::function] attribute missing",
))
};
(func_args, attrs)
}
...@@ -2,11 +2,10 @@ use proc_macro::TokenStream; ...@@ -2,11 +2,10 @@ use proc_macro::TokenStream;
use proc_macro2::{Ident, TokenStream as TokenStream2}; use proc_macro2::{Ident, TokenStream as TokenStream2};
use quote::{ToTokens, quote}; use quote::{ToTokens, quote};
use syn::{ use syn::{
Attribute, Error, Expr, ExprLit, Generics, ImplItem, ImplItemFn, ItemImpl, Lit, LitStr, Meta, Error, Expr, ExprLit, Generics, ImplItem, ImplItemFn, ItemImpl, Lit, LitStr, Meta,
MetaNameValue, Path, Token, Type, MetaNameValue, Path, Token, Type,
parse::{Parse, ParseStream}, parse::{Parse, ParseStream},
parse_macro_input, parse_quote, parse_macro_input, parse_quote,
spanned::Spanned,
}; };
use turbo_tasks_macros_shared::{ use turbo_tasks_macros_shared::{
get_inherent_impl_function_id_ident, get_inherent_impl_function_ident, get_path_ident, get_inherent_impl_function_id_ident, get_inherent_impl_function_ident, get_path_ident,
...@@ -15,51 +14,9 @@ use turbo_tasks_macros_shared::{ ...@@ -15,51 +14,9 @@ use turbo_tasks_macros_shared::{
}; };
use crate::func::{ use crate::func::{
DefinitionContext, FunctionArguments, NativeFn, TurboFn, filter_inline_attributes, DefinitionContext, NativeFn, TurboFn, filter_inline_attributes, split_function_attributes,
parse_with_optional_parens,
}; };
fn is_attribute(attr: &Attribute, name: &str) -> bool {
let path = &attr.path();
if path.leading_colon.is_some() {
return false;
}
let mut iter = path.segments.iter();
match iter.next() {
Some(seg) if seg.arguments.is_empty() && seg.ident == "turbo_tasks" => match iter.next() {
Some(seg) if seg.arguments.is_empty() && seg.ident == name => iter.next().is_none(),
_ => false,
},
_ => false,
}
}
fn split_function_attributes<'a>(
item: &'a ImplItem,
attrs: &'a [Attribute],
) -> (syn::Result<FunctionArguments>, Vec<&'a Attribute>) {
let (func_attrs_vec, attrs): (Vec<_>, Vec<_>) = attrs
.iter()
// TODO(alexkirsz) Replace this with function
.partition(|attr| is_attribute(attr, "function"));
let func_args = if let Some(func_attr) = func_attrs_vec.first() {
if func_attrs_vec.len() == 1 {
parse_with_optional_parens::<FunctionArguments>(func_attr)
} else {
Err(syn::Error::new(
func_attr.span(),
"Only one #[turbo_tasks::function] attribute is allowed per method",
))
}
} else {
Err(syn::Error::new(
item.span(),
"#[turbo_tasks::function] attribute missing",
))
};
(func_args, attrs)
}
struct ValueImplArguments { struct ValueImplArguments {
ident: Option<LitStr>, ident: Option<LitStr>,
} }
...@@ -121,9 +78,11 @@ pub fn value_impl(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -121,9 +78,11 @@ pub fn value_impl(args: TokenStream, input: TokenStream) -> TokenStream {
{ {
let ident = &sig.ident; let ident = &sig.ident;
let (func_args, attrs) = split_function_attributes(item, attrs); let (func_args, attrs) = split_function_attributes(item, attrs);
let func_args = func_args let Ok(func_args) =
.inspect_err(|err| errors.push(err.to_compile_error())) func_args.inspect_err(|err| errors.push(err.to_compile_error()))
.unwrap_or_default(); else {
continue;
};
let local = func_args.local.is_some(); let local = func_args.local.is_some();
let is_self_used = func_args.operation.is_some() || is_self_used(block); let is_self_used = func_args.operation.is_some() || is_self_used(block);
...@@ -225,9 +184,12 @@ pub fn value_impl(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -225,9 +184,12 @@ pub fn value_impl(args: TokenStream, input: TokenStream) -> TokenStream {
let ident = &sig.ident; let ident = &sig.ident;
let (func_args, attrs) = split_function_attributes(item, attrs); let (func_args, attrs) = split_function_attributes(item, attrs);
let func_args = func_args let Ok(func_args) =
.inspect_err(|err| errors.push(err.to_compile_error())) func_args.inspect_err(|err| errors.push(err.to_compile_error()))
.unwrap_or_default(); else {
continue;
};
let local = func_args.local.is_some(); let local = func_args.local.is_some();
let is_self_used = func_args.operation.is_some() || is_self_used(block); let is_self_used = func_args.operation.is_some() || is_self_used(block);
......
...@@ -10,6 +10,7 @@ use turbo_tasks_macros_shared::{ ...@@ -10,6 +10,7 @@ use turbo_tasks_macros_shared::{
use crate::func::{ use crate::func::{
DefinitionContext, FunctionArguments, NativeFn, TurboFn, filter_inline_attributes, DefinitionContext, FunctionArguments, NativeFn, TurboFn, filter_inline_attributes,
split_function_attributes,
}; };
pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
...@@ -68,6 +69,7 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -68,6 +69,7 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
let mut trait_methods: Vec<TokenStream2> = Vec::new(); let mut trait_methods: Vec<TokenStream2> = Vec::new();
let mut native_functions = Vec::new(); let mut native_functions = Vec::new();
let mut items = Vec::with_capacity(raw_items.len()); let mut items = Vec::with_capacity(raw_items.len());
let mut errors = Vec::new();
for item in raw_items.iter() { for item in raw_items.iter() {
let TraitItem::Fn(TraitItemFn { let TraitItem::Fn(TraitItemFn {
...@@ -85,10 +87,18 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -85,10 +87,18 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
}; };
let ident = &sig.ident; let ident = &sig.ident;
// This effectively parses and removes the function annotation ensuring that that macro
// doesn't run after us.
let (func_args, attrs) = split_function_attributes(item, attrs);
let Ok(func_args) = func_args.inspect_err(|err| errors.push(err.to_compile_error())) else {
continue;
};
if let Some(span) = func_args.operation {
span.unwrap()
.error("trait items cannot be operations")
.emit();
}
// Value trait method declarations don't have `#[turbo_tasks::function]`
// annotations on them, though their `impl`s do. It may make sense to require it
// in the future when defining a default implementation.
let Some(turbo_fn) = TurboFn::new( let Some(turbo_fn) = TurboFn::new(
sig, sig,
DefinitionContext::ValueTrait, DefinitionContext::ValueTrait,
...@@ -114,7 +124,7 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -114,7 +124,7 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
Ident::new(&format!("{trait_ident}_{ident}_inline"), ident.span()); Ident::new(&format!("{trait_ident}_{ident}_inline"), ident.span());
let (inline_signature, inline_block) = let (inline_signature, inline_block) =
turbo_fn.inline_signature_and_block(default, is_self_used); turbo_fn.inline_signature_and_block(default, is_self_used);
let inline_attrs = filter_inline_attributes(&attrs[..]); let inline_attrs = filter_inline_attributes(attrs.iter().copied());
let native_function = NativeFn { let native_function = NativeFn {
function_path_string: format!("{trait_ident}::{ident}"), function_path_string: format!("{trait_ident}::{ident}"),
...@@ -183,7 +193,7 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -183,7 +193,7 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
items.push(TraitItem::Fn(TraitItemFn { items.push(TraitItem::Fn(TraitItemFn {
sig: turbo_fn.trait_signature(), sig: turbo_fn.trait_signature(),
default, default,
attrs: attrs.clone(), attrs: attrs.iter().map(|a| (*a).clone()).collect(),
semi_token: Default::default(), semi_token: Default::default(),
})); }));
} }
...@@ -258,6 +268,8 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -258,6 +268,8 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
)* )*
#value_debug_impl #value_debug_impl
#(#errors)*
}; };
expanded.into() expanded.into()
} }
...@@ -141,7 +141,7 @@ impl MyTrait for MyStructValue { ...@@ -141,7 +141,7 @@ impl MyTrait for MyStructValue {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait MyTrait: ValueToString { trait MyTrait: ValueToString {
// TODO #[turbo_tasks::function] #[turbo_tasks::function]
async fn my_trait_function(self: Vc<Self>) -> Result<Vc<RcStr>> { async fn my_trait_function(self: Vc<Self>) -> Result<Vc<RcStr>> {
if *self.to_string().await? != "42" { if *self.to_string().await? != "42" {
bail!("my_trait_function must only be called with 42 as value") bail!("my_trait_function must only be called with 42 as value")
...@@ -150,7 +150,9 @@ trait MyTrait: ValueToString { ...@@ -150,7 +150,9 @@ trait MyTrait: ValueToString {
Ok(self.to_string()) Ok(self.to_string())
} }
#[turbo_tasks::function]
fn my_trait_function2(self: Vc<Self>) -> Vc<RcStr>; fn my_trait_function2(self: Vc<Self>) -> Vc<RcStr>;
#[turbo_tasks::function]
fn my_trait_function3(self: Vc<Self>) -> Vc<RcStr>; fn my_trait_function3(self: Vc<Self>) -> Vc<RcStr>;
} }
...@@ -170,6 +172,7 @@ async fn my_function( ...@@ -170,6 +172,7 @@ async fn my_function(
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait Add { trait Add {
#[turbo_tasks::function]
fn add(self: Vc<Self>, other: Vc<Box<dyn Add>>) -> Vc<Self>; fn add(self: Vc<Self>, other: Vc<Box<dyn Add>>) -> Vc<Self>;
} }
......
...@@ -153,19 +153,27 @@ fn wrap_trait_value(v: Vc<Box<dyn ValueTrait>>) -> Vc<Box<dyn ValueTrait>> { ...@@ -153,19 +153,27 @@ fn wrap_trait_value(v: Vc<Box<dyn ValueTrait>>) -> Vc<Box<dyn ValueTrait>> {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait ValueTrait { trait ValueTrait {
#[turbo_tasks::function]
fn static_trait_method() -> Vc<u32>; fn static_trait_method() -> Vc<u32>;
#[turbo_tasks::function]
async fn async_static_trait_method() -> Result<Vc<u32>>; async fn async_static_trait_method() -> Result<Vc<u32>>;
#[turbo_tasks::function]
fn default_static_trait_method() -> Vc<u32> { fn default_static_trait_method() -> Vc<u32> {
Vc::cell(42) Vc::cell(42)
} }
#[turbo_tasks::function]
async fn default_async_static_trait_method() -> Result<Vc<u32>> { async fn default_async_static_trait_method() -> Result<Vc<u32>> {
Ok(Vc::cell(42)) Ok(Vc::cell(42))
} }
#[turbo_tasks::function]
fn trait_method(&self) -> Vc<u32>; fn trait_method(&self) -> Vc<u32>;
#[turbo_tasks::function]
fn async_trait_method(&self) -> Result<Vc<u32>>; fn async_trait_method(&self) -> Result<Vc<u32>>;
#[turbo_tasks::function]
fn default_trait_method(self: Vc<Self>) -> Vc<u32> { fn default_trait_method(self: Vc<Self>) -> Vc<u32> {
Vc::cell(42) Vc::cell(42)
} }
#[turbo_tasks::function]
async fn default_async_trait_method(self: Vc<Self>) -> Result<Vc<u32>> { async fn default_async_trait_method(self: Vc<Self>) -> Result<Vc<u32>> {
Ok(Vc::cell(42)) Ok(Vc::cell(42))
} }
......
...@@ -37,6 +37,7 @@ async fn filtered_trait_method_args() -> Result<()> { ...@@ -37,6 +37,7 @@ async fn filtered_trait_method_args() -> Result<()> {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait ExampleTrait { trait ExampleTrait {
#[turbo_tasks::function]
fn method_with_arg(&self, number: i32) -> Vc<()>; fn method_with_arg(&self, number: i32) -> Vc<()>;
} }
......
...@@ -47,7 +47,9 @@ fn get_non_local_task_id() -> Vc<u32> { ...@@ -47,7 +47,9 @@ fn get_non_local_task_id() -> Vc<u32> {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait SomeTrait { trait SomeTrait {
#[turbo_tasks::function]
fn get_local_task_id(self: Vc<Self>) -> Vc<u32>; fn get_local_task_id(self: Vc<Self>) -> Vc<u32>;
#[turbo_tasks::function]
fn get_non_local_task_id(self: Vc<Self>) -> Vc<u32>; fn get_non_local_task_id(self: Vc<Self>) -> Vc<u32>;
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
......
...@@ -222,7 +222,9 @@ async fn wrap_vc(val: Vc<u64>) -> Result<Vc<WrappedU64>> { ...@@ -222,7 +222,9 @@ async fn wrap_vc(val: Vc<u64>) -> Result<Vc<WrappedU64>> {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait Doublable { pub trait Doublable {
#[turbo_tasks::function]
fn double(&self) -> Vc<Self>; fn double(&self) -> Vc<Self>;
#[turbo_tasks::function]
fn double_vc(self: Vc<Self>) -> Vc<Self>; fn double_vc(self: Vc<Self>) -> Vc<Self>;
} }
......
...@@ -79,6 +79,7 @@ impl Counter { ...@@ -79,6 +79,7 @@ impl Counter {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait CounterTrait { trait CounterTrait {
#[turbo_tasks::function]
fn get_value(&self) -> Vc<CounterValue>; fn get_value(&self) -> Vc<CounterValue>;
} }
...@@ -94,6 +95,7 @@ impl CounterTrait for Counter { ...@@ -94,6 +95,7 @@ impl CounterTrait for Counter {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait CounterValueTrait { trait CounterValueTrait {
#[turbo_tasks::function]
fn get_value(&self) -> Vc<CounterValue>; fn get_value(&self) -> Vc<CounterValue>;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{IntoTraitRef, State, TraitRef, Upcast, Vc}; use turbo_tasks::{IntoTraitRef, State, TraitRef, Upcast, Vc};
use turbo_tasks_testing::{register, run, Registration}; use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
...@@ -79,6 +79,7 @@ async fn test_trait_ref_new_cell_mode() { ...@@ -79,6 +79,7 @@ async fn test_trait_ref_new_cell_mode() {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait ValueTrait { trait ValueTrait {
#[turbo_tasks::function]
fn get_value(&self) -> Vc<usize>; fn get_value(&self) -> Vc<usize>;
} }
......
...@@ -57,9 +57,11 @@ impl ValueDebugString { ...@@ -57,9 +57,11 @@ impl ValueDebugString {
/// ``` /// ```
#[turbo_tasks::value_trait(no_debug)] #[turbo_tasks::value_trait(no_debug)]
pub trait ValueDebug { pub trait ValueDebug {
#[turbo_tasks::function]
fn dbg(self: Vc<Self>) -> Vc<ValueDebugString>; fn dbg(self: Vc<Self>) -> Vc<ValueDebugString>;
/// Like `dbg`, but with a depth limit. /// Like `dbg`, but with a depth limit.
#[turbo_tasks::function]
fn dbg_depth(self: Vc<Self>, depth: usize) -> Vc<ValueDebugString>; fn dbg_depth(self: Vc<Self>, depth: usize) -> Vc<ValueDebugString>;
} }
......
...@@ -5,5 +5,6 @@ use crate::{self as turbo_tasks}; ...@@ -5,5 +5,6 @@ use crate::{self as turbo_tasks};
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ValueToString { pub trait ValueToString {
#[turbo_tasks::function]
fn to_string(self: Vc<Self>) -> Vc<RcStr>; fn to_string(self: Vc<Self>) -> Vc<RcStr>;
} }
...@@ -220,6 +220,7 @@ pub(crate) mod tests { ...@@ -220,6 +220,7 @@ pub(crate) mod tests {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait MockTrait { trait MockTrait {
#[turbo_tasks::function]
fn mock_method_task() -> Vc<()>; fn mock_method_task() -> Vc<()>;
} }
......
...@@ -13,5 +13,6 @@ use crate::{self as turbo_tasks}; ...@@ -13,5 +13,6 @@ use crate::{self as turbo_tasks};
/// 2. No annotations: this will make `Vc::default()` always return a different value. /// 2. No annotations: this will make `Vc::default()` always return a different value.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ValueDefault { pub trait ValueDefault {
#[turbo_tasks::function]
fn value_default() -> Vc<Self>; fn value_default() -> Vc<Self>;
} }
...@@ -11,9 +11,11 @@ use crate::version::{VersionedAssetContent, VersionedContent}; ...@@ -11,9 +11,11 @@ use crate::version::{VersionedAssetContent, VersionedContent};
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait Asset { pub trait Asset {
/// The content of the [Asset]. /// The content of the [Asset].
#[turbo_tasks::function]
fn content(self: Vc<Self>) -> Vc<AssetContent>; fn content(self: Vc<Self>) -> Vc<AssetContent>;
/// The content of the [Asset] alongside its version. /// The content of the [Asset] alongside its version.
#[turbo_tasks::function]
async fn versioned_content(self: Vc<Self>) -> Result<Vc<Box<dyn VersionedContent>>> { async fn versioned_content(self: Vc<Self>) -> Result<Vc<Box<dyn VersionedContent>>> {
Ok(Vc::upcast(VersionedAssetContent::new(self.content()))) Ok(Vc::upcast(VersionedAssetContent::new(self.content())))
} }
......
...@@ -144,28 +144,36 @@ pub struct ChunkingConfigs(FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingCon ...@@ -144,28 +144,36 @@ pub struct ChunkingConfigs(FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingCon
/// A context for the chunking that influences the way chunks are created /// A context for the chunking that influences the way chunks are created
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ChunkingContext { pub trait ChunkingContext {
#[turbo_tasks::function]
fn name(self: Vc<Self>) -> Vc<RcStr>; fn name(self: Vc<Self>) -> Vc<RcStr>;
#[turbo_tasks::function]
fn should_use_file_source_map_uris(self: Vc<Self>) -> Vc<bool>; fn should_use_file_source_map_uris(self: Vc<Self>) -> Vc<bool>;
/// The root path of the project /// The root path of the project
#[turbo_tasks::function]
fn root_path(self: Vc<Self>) -> Vc<FileSystemPath>; fn root_path(self: Vc<Self>) -> Vc<FileSystemPath>;
/// The output root path in the output filesystem /// The output root path in the output filesystem
#[turbo_tasks::function]
fn output_root(self: Vc<Self>) -> Vc<FileSystemPath>; fn output_root(self: Vc<Self>) -> Vc<FileSystemPath>;
/// A relative path how to reach the root path from the output root. This is used to compute /// A relative path how to reach the root path from the output root. This is used to compute
/// original paths at runtime relative to the output files. e. g. import.meta.url needs that. /// original paths at runtime relative to the output files. e. g. import.meta.url needs that.
#[turbo_tasks::function]
fn output_root_to_root_path(self: Vc<Self>) -> Vc<RcStr>; fn output_root_to_root_path(self: Vc<Self>) -> Vc<RcStr>;
// TODO remove this, a chunking context should not be bound to a specific // TODO remove this, a chunking context should not be bound to a specific
// environment since this can change due to transitions in the module graph // environment since this can change due to transitions in the module graph
#[turbo_tasks::function]
fn environment(self: Vc<Self>) -> Vc<Environment>; fn environment(self: Vc<Self>) -> Vc<Environment>;
/// The path to the folder where all chunks are placed. This can be used to compute relative /// The path to the folder where all chunks are placed. This can be used to compute relative
/// paths. /// paths.
#[turbo_tasks::function]
fn chunk_root_path(self: Vc<Self>) -> Vc<FileSystemPath>; fn chunk_root_path(self: Vc<Self>) -> Vc<FileSystemPath>;
// TODO(alexkirsz) Remove this from the chunking context. This should be at the // TODO(alexkirsz) Remove this from the chunking context. This should be at the
// discretion of chunking context implementors. However, we currently use this // discretion of chunking context implementors. However, we currently use this
// in a couple of places in `turbopack-css`, so we need to remove that // in a couple of places in `turbopack-css`, so we need to remove that
// dependency first. // dependency first.
#[turbo_tasks::function]
fn chunk_path( fn chunk_path(
self: Vc<Self>, self: Vc<Self>,
asset: Option<Vc<Box<dyn Asset>>>, asset: Option<Vc<Box<dyn Asset>>>,
...@@ -174,51 +182,63 @@ pub trait ChunkingContext { ...@@ -174,51 +182,63 @@ pub trait ChunkingContext {
) -> Vc<FileSystemPath>; ) -> Vc<FileSystemPath>;
/// Reference Source Map Assets for chunks /// Reference Source Map Assets for chunks
#[turbo_tasks::function]
fn reference_chunk_source_maps(self: Vc<Self>, chunk: Vc<Box<dyn OutputAsset>>) -> Vc<bool>; fn reference_chunk_source_maps(self: Vc<Self>, chunk: Vc<Box<dyn OutputAsset>>) -> Vc<bool>;
/// Include Source Maps for modules /// Include Source Maps for modules
#[turbo_tasks::function]
fn reference_module_source_maps(self: Vc<Self>, module: Vc<Box<dyn Module>>) -> Vc<bool>; fn reference_module_source_maps(self: Vc<Self>, module: Vc<Box<dyn Module>>) -> Vc<bool>;
/// Returns a URL (relative or absolute, depending on the asset prefix) to /// Returns a URL (relative or absolute, depending on the asset prefix) to
/// the static asset based on its `ident`. /// the static asset based on its `ident`.
#[turbo_tasks::function]
fn asset_url(self: Vc<Self>, ident: Vc<FileSystemPath>) -> Result<Vc<RcStr>>; fn asset_url(self: Vc<Self>, ident: Vc<FileSystemPath>) -> Result<Vc<RcStr>>;
#[turbo_tasks::function]
fn asset_path( fn asset_path(
self: Vc<Self>, self: Vc<Self>,
content_hash: RcStr, content_hash: RcStr,
original_asset_ident: Vc<AssetIdent>, original_asset_ident: Vc<AssetIdent>,
) -> Vc<FileSystemPath>; ) -> Vc<FileSystemPath>;
#[turbo_tasks::function]
fn is_hot_module_replacement_enabled(self: Vc<Self>) -> Vc<bool> { fn is_hot_module_replacement_enabled(self: Vc<Self>) -> Vc<bool> {
Vc::cell(false) Vc::cell(false)
} }
#[turbo_tasks::function]
fn chunking_configs(self: Vc<Self>) -> Vc<ChunkingConfigs> { fn chunking_configs(self: Vc<Self>) -> Vc<ChunkingConfigs> {
Vc::cell(Default::default()) Vc::cell(Default::default())
} }
#[turbo_tasks::function]
fn batching_config(self: Vc<Self>) -> Vc<BatchingConfig> { fn batching_config(self: Vc<Self>) -> Vc<BatchingConfig> {
BatchingConfig::new(BatchingConfig { BatchingConfig::new(BatchingConfig {
..Default::default() ..Default::default()
}) })
} }
#[turbo_tasks::function]
fn is_tracing_enabled(self: Vc<Self>) -> Vc<bool> { fn is_tracing_enabled(self: Vc<Self>) -> Vc<bool> {
Vc::cell(false) Vc::cell(false)
} }
#[turbo_tasks::function]
fn minify_type(self: Vc<Self>) -> Vc<MinifyType> { fn minify_type(self: Vc<Self>) -> Vc<MinifyType> {
MinifyType::NoMinify.cell() MinifyType::NoMinify.cell()
} }
#[turbo_tasks::function]
fn async_loader_chunk_item( fn async_loader_chunk_item(
&self, &self,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn ChunkableModule>>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<Box<dyn ChunkItem>>; ) -> Vc<Box<dyn ChunkItem>>;
#[turbo_tasks::function]
fn async_loader_chunk_item_id(&self, module: Vc<Box<dyn ChunkableModule>>) -> Vc<ModuleId>; fn async_loader_chunk_item_id(&self, module: Vc<Box<dyn ChunkableModule>>) -> Vc<ModuleId>;
#[turbo_tasks::function]
fn chunk_group( fn chunk_group(
self: Vc<Self>, self: Vc<Self>,
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
...@@ -227,6 +247,7 @@ pub trait ChunkingContext { ...@@ -227,6 +247,7 @@ pub trait ChunkingContext {
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<ChunkGroupResult>; ) -> Vc<ChunkGroupResult>;
#[turbo_tasks::function]
fn evaluated_chunk_group( fn evaluated_chunk_group(
self: Vc<Self>, self: Vc<Self>,
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
...@@ -239,6 +260,7 @@ pub trait ChunkingContext { ...@@ -239,6 +260,7 @@ pub trait ChunkingContext {
/// * loads the given extra_chunks in addition to the generated chunks; and /// * loads the given extra_chunks in addition to the generated chunks; and
/// * evaluates the given assets; and /// * evaluates the given assets; and
/// * exports the result of evaluating the last module as a CommonJS default export. /// * exports the result of evaluating the last module as a CommonJS default export.
#[turbo_tasks::function]
fn entry_chunk_group( fn entry_chunk_group(
self: Vc<Self>, self: Vc<Self>,
path: Vc<FileSystemPath>, path: Vc<FileSystemPath>,
...@@ -248,14 +270,17 @@ pub trait ChunkingContext { ...@@ -248,14 +270,17 @@ pub trait ChunkingContext {
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<EntryChunkGroupResult>>; ) -> Result<Vc<EntryChunkGroupResult>>;
#[turbo_tasks::function]
async fn chunk_item_id_from_ident( async fn chunk_item_id_from_ident(
self: Vc<Self>, self: Vc<Self>,
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
) -> Result<Vc<ModuleId>>; ) -> Result<Vc<ModuleId>>;
#[turbo_tasks::function]
fn chunk_item_id(self: Vc<Self>, module: Vc<Box<dyn ChunkItem>>) -> Vc<ModuleId> { fn chunk_item_id(self: Vc<Self>, module: Vc<Box<dyn ChunkItem>>) -> Vc<ModuleId> {
self.chunk_item_id_from_ident(module.asset_ident()) self.chunk_item_id_from_ident(module.asset_ident())
} }
#[turbo_tasks::function]
fn chunk_item_id_from_module(self: Vc<Self>, module: Vc<Box<dyn Module>>) -> Vc<ModuleId> { fn chunk_item_id_from_module(self: Vc<Self>, module: Vc<Box<dyn Module>>) -> Vc<ModuleId> {
self.chunk_item_id_from_ident(module.ident()) self.chunk_item_id_from_ident(module.ident())
} }
......
...@@ -88,6 +88,7 @@ pub struct ModuleIds(Vec<ResolvedVc<ModuleId>>); ...@@ -88,6 +88,7 @@ pub struct ModuleIds(Vec<ResolvedVc<ModuleId>>);
/// A [Module] that can be converted into a [Chunk]. /// A [Module] that can be converted into a [Chunk].
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ChunkableModule: Module + Asset { pub trait ChunkableModule: Module + Asset {
#[turbo_tasks::function]
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
...@@ -123,17 +124,21 @@ impl Chunks { ...@@ -123,17 +124,21 @@ impl Chunks {
// TODO This could be simplified to and merged with [OutputChunk] // TODO This could be simplified to and merged with [OutputChunk]
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait Chunk { pub trait Chunk {
#[turbo_tasks::function]
fn ident(self: Vc<Self>) -> Vc<AssetIdent>; fn ident(self: Vc<Self>) -> Vc<AssetIdent>;
#[turbo_tasks::function]
fn chunking_context(self: Vc<Self>) -> Vc<Box<dyn ChunkingContext>>; fn chunking_context(self: Vc<Self>) -> Vc<Box<dyn ChunkingContext>>;
// fn path(self: Vc<Self>) -> Vc<FileSystemPath> { // fn path(self: Vc<Self>) -> Vc<FileSystemPath> {
// self.ident().path() // self.ident().path()
// } // }
/// Other [OutputAsset]s referenced from this [Chunk]. /// Other [OutputAsset]s referenced from this [Chunk].
#[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<OutputAssets> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
OutputAssets::empty() OutputAssets::empty()
} }
#[turbo_tasks::function]
fn chunk_items(self: Vc<Self>) -> Vc<ChunkItems> { fn chunk_items(self: Vc<Self>) -> Vc<ChunkItems> {
ChunkItems(vec![]).cell() ChunkItems(vec![]).cell()
} }
...@@ -155,6 +160,7 @@ pub struct OutputChunkRuntimeInfo { ...@@ -155,6 +160,7 @@ pub struct OutputChunkRuntimeInfo {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait OutputChunk: Asset { pub trait OutputChunk: Asset {
#[turbo_tasks::function]
fn runtime_info(self: Vc<Self>) -> Vc<OutputChunkRuntimeInfo>; fn runtime_info(self: Vc<Self>) -> Vc<OutputChunkRuntimeInfo>;
} }
...@@ -268,6 +274,7 @@ pub struct ChunkingTypeOption(Option<ChunkingType>); ...@@ -268,6 +274,7 @@ pub struct ChunkingTypeOption(Option<ChunkingType>);
/// specific interface is implemented. /// specific interface is implemented.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ChunkableModuleReference: ModuleReference + ValueToString { pub trait ChunkableModuleReference: ModuleReference + ValueToString {
#[turbo_tasks::function]
fn chunking_type(self: Vc<Self>) -> Vc<ChunkingTypeOption> { fn chunking_type(self: Vc<Self>) -> Vc<ChunkingTypeOption> {
Vc::cell(Some(ChunkingType::Parallel { Vc::cell(Some(ChunkingType::Parallel {
inherit_async: false, inherit_async: false,
...@@ -289,35 +296,43 @@ pub trait ChunkItem { ...@@ -289,35 +296,43 @@ pub trait ChunkItem {
/// The [AssetIdent] of the [Module] that this [ChunkItem] was created from. /// The [AssetIdent] of the [Module] that this [ChunkItem] was created from.
/// For most chunk types this must uniquely identify the chunk item at /// For most chunk types this must uniquely identify the chunk item at
/// runtime as it's the source of the module id used at runtime. /// runtime as it's the source of the module id used at runtime.
#[turbo_tasks::function]
fn asset_ident(self: Vc<Self>) -> Vc<AssetIdent>; fn asset_ident(self: Vc<Self>) -> Vc<AssetIdent>;
/// A [AssetIdent] that uniquely identifies the content of this [ChunkItem]. /// A [AssetIdent] that uniquely identifies the content of this [ChunkItem].
/// It is unusally identical to [ChunkItem::asset_ident] but can be /// It is unusally identical to [ChunkItem::asset_ident] but can be
/// different when the chunk item content depends on available modules e. g. /// different when the chunk item content depends on available modules e. g.
/// for chunk loaders. /// for chunk loaders.
#[turbo_tasks::function]
fn content_ident(self: Vc<Self>) -> Vc<AssetIdent> { fn content_ident(self: Vc<Self>) -> Vc<AssetIdent> {
self.asset_ident() self.asset_ident()
} }
/// A [ChunkItem] can reference OutputAssets, unlike [Module]s referencing other [Module]s. /// A [ChunkItem] can reference OutputAssets, unlike [Module]s referencing other [Module]s.
#[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<OutputAssets> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
OutputAssets::empty() OutputAssets::empty()
} }
/// The type of chunk this item should be assembled into. /// The type of chunk this item should be assembled into.
#[turbo_tasks::function]
fn ty(self: Vc<Self>) -> Vc<Box<dyn ChunkType>>; fn ty(self: Vc<Self>) -> Vc<Box<dyn ChunkType>>;
/// A temporary method to retrieve the module associated with this /// A temporary method to retrieve the module associated with this
/// ChunkItem. TODO: Remove this as part of the chunk refactoring. /// ChunkItem. TODO: Remove this as part of the chunk refactoring.
#[turbo_tasks::function]
fn module(self: Vc<Self>) -> Vc<Box<dyn Module>>; fn module(self: Vc<Self>) -> Vc<Box<dyn Module>>;
#[turbo_tasks::function]
fn chunking_context(self: Vc<Self>) -> Vc<Box<dyn ChunkingContext>>; fn chunking_context(self: Vc<Self>) -> Vc<Box<dyn ChunkingContext>>;
} }
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ChunkType: ValueToString { pub trait ChunkType: ValueToString {
/// Whether the source (reference) order of items needs to be retained during chunking. /// Whether the source (reference) order of items needs to be retained during chunking.
#[turbo_tasks::function]
fn is_style(self: Vc<Self>) -> Vc<bool>; fn is_style(self: Vc<Self>) -> Vc<bool>;
/// Create a new chunk for the given chunk items /// Create a new chunk for the given chunk items
#[turbo_tasks::function]
fn chunk( fn chunk(
&self, &self,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
...@@ -326,6 +341,7 @@ pub trait ChunkType: ValueToString { ...@@ -326,6 +341,7 @@ pub trait ChunkType: ValueToString {
referenced_output_assets: Vc<OutputAssets>, referenced_output_assets: Vc<OutputAssets>,
) -> Vc<Box<dyn Chunk>>; ) -> Vc<Box<dyn Chunk>>;
#[turbo_tasks::function]
fn chunk_item_size( fn chunk_item_size(
&self, &self,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
......
...@@ -11,6 +11,7 @@ use crate::{ ...@@ -11,6 +11,7 @@ use crate::{
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ModuleIdStrategy { pub trait ModuleIdStrategy {
#[turbo_tasks::function]
fn get_module_id(self: Vc<Self>, ident: Vc<AssetIdent>) -> Vc<ModuleId>; fn get_module_id(self: Vc<Self>, ident: Vc<AssetIdent>) -> Vc<ModuleId>;
} }
......
...@@ -60,12 +60,15 @@ impl ProcessResult { ...@@ -60,12 +60,15 @@ impl ProcessResult {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait AssetContext { pub trait AssetContext {
/// Gets the compile time info of the asset context. /// Gets the compile time info of the asset context.
#[turbo_tasks::function]
fn compile_time_info(self: Vc<Self>) -> Vc<CompileTimeInfo>; fn compile_time_info(self: Vc<Self>) -> Vc<CompileTimeInfo>;
/// Gets the layer of the asset context. /// Gets the layer of the asset context.
#[turbo_tasks::function]
fn layer(self: Vc<Self>) -> Vc<RcStr>; fn layer(self: Vc<Self>) -> Vc<RcStr>;
/// Gets the resolve options for a given path. /// Gets the resolve options for a given path.
#[turbo_tasks::function]
fn resolve_options( fn resolve_options(
self: Vc<Self>, self: Vc<Self>,
origin_path: Vc<FileSystemPath>, origin_path: Vc<FileSystemPath>,
...@@ -73,6 +76,7 @@ pub trait AssetContext { ...@@ -73,6 +76,7 @@ pub trait AssetContext {
) -> Vc<ResolveOptions>; ) -> Vc<ResolveOptions>;
/// Resolves an request to an [ModuleResolveResult]. /// Resolves an request to an [ModuleResolveResult].
#[turbo_tasks::function]
fn resolve_asset( fn resolve_asset(
self: Vc<Self>, self: Vc<Self>,
origin_path: Vc<FileSystemPath>, origin_path: Vc<FileSystemPath>,
...@@ -82,6 +86,7 @@ pub trait AssetContext { ...@@ -82,6 +86,7 @@ pub trait AssetContext {
) -> Vc<ModuleResolveResult>; ) -> Vc<ModuleResolveResult>;
/// Process a source into a module. /// Process a source into a module.
#[turbo_tasks::function]
fn process( fn process(
self: Vc<Self>, self: Vc<Self>,
asset: Vc<Box<dyn Source>>, asset: Vc<Box<dyn Source>>,
...@@ -89,6 +94,7 @@ pub trait AssetContext { ...@@ -89,6 +94,7 @@ pub trait AssetContext {
) -> Vc<ProcessResult>; ) -> Vc<ProcessResult>;
/// Process an [ResolveResult] into an [ModuleResolveResult]. /// Process an [ResolveResult] into an [ModuleResolveResult].
#[turbo_tasks::function]
fn process_resolve_result( fn process_resolve_result(
self: Vc<Self>, self: Vc<Self>,
result: Vc<ResolveResult>, result: Vc<ResolveResult>,
...@@ -96,7 +102,9 @@ pub trait AssetContext { ...@@ -96,7 +102,9 @@ pub trait AssetContext {
) -> Vc<ModuleResolveResult>; ) -> Vc<ModuleResolveResult>;
/// Gets a new AssetContext with the transition applied. /// Gets a new AssetContext with the transition applied.
#[turbo_tasks::function]
fn with_transition(self: Vc<Self>, transition: RcStr) -> Vc<Box<dyn AssetContext>>; fn with_transition(self: Vc<Self>, transition: RcStr) -> Vc<Box<dyn AssetContext>>;
#[turbo_tasks::function]
fn side_effect_free_packages(self: Vc<Self>) -> Vc<Glob>; fn side_effect_free_packages(self: Vc<Self>) -> Vc<Glob>;
} }
...@@ -57,12 +57,16 @@ pub trait Diagnostic { ...@@ -57,12 +57,16 @@ pub trait Diagnostic {
/// `slow_perf_event`, or something else. This is not strongly typed /// `slow_perf_event`, or something else. This is not strongly typed
/// though; since consumer or implementation may need to define own /// though; since consumer or implementation may need to define own
/// category. /// category.
#[turbo_tasks::function]
fn category(&self) -> Vc<RcStr>; fn category(&self) -> Vc<RcStr>;
/// Name of the specific diagnostic event. /// Name of the specific diagnostic event.
#[turbo_tasks::function]
fn name(&self) -> Vc<RcStr>; fn name(&self) -> Vc<RcStr>;
/// Arbitarary payload included in the diagnostic event. /// Arbitarary payload included in the diagnostic event.
#[turbo_tasks::function]
fn payload(&self) -> Vc<DiagnosticPayload>; fn payload(&self) -> Vc<DiagnosticPayload>;
#[turbo_tasks::function]
async fn into_plain(self: Vc<Self>) -> Result<Vc<PlainDiagnostic>> { async fn into_plain(self: Vc<Self>) -> Result<Vc<PlainDiagnostic>> {
Ok(PlainDiagnostic { Ok(PlainDiagnostic {
category: self.category().owned().await?, category: self.category().owned().await?,
......
...@@ -13,13 +13,17 @@ pub struct IntrospectableChildren(FxIndexSet<(RcStr, VcDynIntrospectable)>); ...@@ -13,13 +13,17 @@ pub struct IntrospectableChildren(FxIndexSet<(RcStr, VcDynIntrospectable)>);
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait Introspectable { pub trait Introspectable {
#[turbo_tasks::function]
fn ty(self: Vc<Self>) -> Vc<RcStr>; fn ty(self: Vc<Self>) -> Vc<RcStr>;
#[turbo_tasks::function]
fn title(self: Vc<Self>) -> Vc<RcStr> { fn title(self: Vc<Self>) -> Vc<RcStr> {
Vc::<RcStr>::default() Vc::<RcStr>::default()
} }
#[turbo_tasks::function]
fn details(self: Vc<Self>) -> Vc<RcStr> { fn details(self: Vc<Self>) -> Vc<RcStr> {
Vc::<RcStr>::default() Vc::<RcStr>::default()
} }
#[turbo_tasks::function]
fn children(self: Vc<Self>) -> Vc<IntrospectableChildren> { fn children(self: Vc<Self>) -> Vc<IntrospectableChildren> {
Vc::cell(FxIndexSet::default()) Vc::cell(FxIndexSet::default())
} }
......
...@@ -104,27 +104,32 @@ pub enum StyledString { ...@@ -104,27 +104,32 @@ pub enum StyledString {
pub trait Issue { pub trait Issue {
/// Severity allows the user to filter out unimportant issues, with Bug /// Severity allows the user to filter out unimportant issues, with Bug
/// being the highest priority and Info being the lowest. /// being the highest priority and Info being the lowest.
#[turbo_tasks::function]
fn severity(self: Vc<Self>) -> Vc<IssueSeverity> { fn severity(self: Vc<Self>) -> Vc<IssueSeverity> {
IssueSeverity::Error.into() IssueSeverity::Error.into()
} }
/// The file path that generated the issue, displayed to the user as message /// The file path that generated the issue, displayed to the user as message
/// header. /// header.
#[turbo_tasks::function]
fn file_path(self: Vc<Self>) -> Vc<FileSystemPath>; fn file_path(self: Vc<Self>) -> Vc<FileSystemPath>;
/// The stage of the compilation process at which the issue occurred. This /// The stage of the compilation process at which the issue occurred. This
/// is used to sort issues. /// is used to sort issues.
#[turbo_tasks::function]
fn stage(self: Vc<Self>) -> Vc<IssueStage>; fn stage(self: Vc<Self>) -> Vc<IssueStage>;
/// The issue title should be descriptive of the issue, but should be a /// The issue title should be descriptive of the issue, but should be a
/// single line. This is displayed to the user directly under the issue /// single line. This is displayed to the user directly under the issue
/// header. /// header.
// TODO add Vc<StyledString> // TODO add Vc<StyledString>
#[turbo_tasks::function]
fn title(self: Vc<Self>) -> Vc<StyledString>; fn title(self: Vc<Self>) -> Vc<StyledString>;
/// A more verbose message of the issue, appropriate for providing multiline /// A more verbose message of the issue, appropriate for providing multiline
/// information of the issue. /// information of the issue.
// TODO add Vc<StyledString> // TODO add Vc<StyledString>
#[turbo_tasks::function]
fn description(self: Vc<Self>) -> Vc<OptionStyledString> { fn description(self: Vc<Self>) -> Vc<OptionStyledString> {
Vc::cell(None) Vc::cell(None)
} }
...@@ -132,12 +137,14 @@ pub trait Issue { ...@@ -132,12 +137,14 @@ pub trait Issue {
/// Full details of the issue, appropriate for providing debug level /// Full details of the issue, appropriate for providing debug level
/// information. Only displayed if the user explicitly asks for detailed /// information. Only displayed if the user explicitly asks for detailed
/// messages (not to be confused with severity). /// messages (not to be confused with severity).
#[turbo_tasks::function]
fn detail(self: Vc<Self>) -> Vc<OptionStyledString> { fn detail(self: Vc<Self>) -> Vc<OptionStyledString> {
Vc::cell(None) Vc::cell(None)
} }
/// A link to relevant documentation of the issue. Only displayed in console /// A link to relevant documentation of the issue. Only displayed in console
/// if the user explicitly asks for detailed messages. /// if the user explicitly asks for detailed messages.
#[turbo_tasks::function]
fn documentation_link(self: Vc<Self>) -> Vc<RcStr> { fn documentation_link(self: Vc<Self>) -> Vc<RcStr> {
Vc::<RcStr>::default() Vc::<RcStr>::default()
} }
...@@ -145,6 +152,7 @@ pub trait Issue { ...@@ -145,6 +152,7 @@ pub trait Issue {
/// The source location that caused the issue. Eg, for a parsing error it /// The source location that caused the issue. Eg, for a parsing error it
/// should point at the offending character. Displayed to the user alongside /// should point at the offending character. Displayed to the user alongside
/// the title/description. /// the title/description.
#[turbo_tasks::function]
fn source(self: Vc<Self>) -> Vc<OptionIssueSource> { fn source(self: Vc<Self>) -> Vc<OptionIssueSource> {
Vc::cell(None) Vc::cell(None)
} }
...@@ -153,6 +161,7 @@ pub trait Issue { ...@@ -153,6 +161,7 @@ pub trait Issue {
// A collectible trait that allows traces to be computed for a given module. // A collectible trait that allows traces to be computed for a given module.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ImportTracer { pub trait ImportTracer {
#[turbo_tasks::function]
fn get_traces(self: Vc<Self>, path: ResolvedVc<FileSystemPath>) -> Vc<ImportTraces>; fn get_traces(self: Vc<Self>, path: ResolvedVc<FileSystemPath>) -> Vc<ImportTraces>;
} }
...@@ -191,6 +200,7 @@ impl ValueDefault for ImportTraces { ...@@ -191,6 +200,7 @@ impl ValueDefault for ImportTraces {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait IssueProcessingPath { trait IssueProcessingPath {
#[turbo_tasks::function]
fn shortest_path( fn shortest_path(
self: Vc<Self>, self: Vc<Self>,
issue: Vc<Box<dyn Issue>>, issue: Vc<Box<dyn Issue>>,
...@@ -959,6 +969,7 @@ pub trait IssueReporter { ...@@ -959,6 +969,7 @@ pub trait IssueReporter {
/// determine which issues are new. /// determine which issues are new.
/// * `min_failing_severity` - The minimum Vc<[IssueSeverity]> /// * `min_failing_severity` - The minimum Vc<[IssueSeverity]>
/// The minimum issue severity level considered to fatally end the program. /// The minimum issue severity level considered to fatally end the program.
#[turbo_tasks::function]
fn report_issues( fn report_issues(
self: Vc<Self>, self: Vc<Self>,
issues: TransientInstance<CapturedIssues>, issues: TransientInstance<CapturedIssues>,
......
...@@ -18,20 +18,24 @@ pub struct OptionStyleType(Option<StyleType>); ...@@ -18,20 +18,24 @@ pub struct OptionStyleType(Option<StyleType>);
pub trait Module: Asset { pub trait Module: Asset {
/// The identifier of the [Module]. It's expected to be unique and capture /// The identifier of the [Module]. It's expected to be unique and capture
/// all properties of the [Module]. /// all properties of the [Module].
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent>; fn ident(&self) -> Vc<AssetIdent>;
/// Other [Module]s or [OutputAsset]s referenced from this [Module]. /// Other [Module]s or [OutputAsset]s referenced from this [Module].
// TODO refactor to avoid returning [OutputAsset]s here // TODO refactor to avoid returning [OutputAsset]s here
#[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<ModuleReferences> { fn references(self: Vc<Self>) -> Vc<ModuleReferences> {
ModuleReferences::empty() ModuleReferences::empty()
} }
/// Signifies the module itself is async, e.g. it uses top-level await, is a wasm module, etc. /// Signifies the module itself is async, e.g. it uses top-level await, is a wasm module, etc.
#[turbo_tasks::function]
fn is_self_async(self: Vc<Self>) -> Vc<bool> { fn is_self_async(self: Vc<Self>) -> Vc<bool> {
Vc::cell(false) Vc::cell(false)
} }
/// The style type of the module. /// The style type of the module.
#[turbo_tasks::function]
fn style_type(self: Vc<Self>) -> Vc<OptionStyleType> { fn style_type(self: Vc<Self>) -> Vc<OptionStyleType> {
Vc::cell(None) Vc::cell(None)
} }
......
...@@ -13,13 +13,16 @@ pub struct OptionOutputAsset(Option<ResolvedVc<Box<dyn OutputAsset>>>); ...@@ -13,13 +13,16 @@ pub struct OptionOutputAsset(Option<ResolvedVc<Box<dyn OutputAsset>>>);
pub trait OutputAsset: Asset { pub trait OutputAsset: Asset {
/// The identifier of the [OutputAsset]. It's expected to be unique and /// The identifier of the [OutputAsset]. It's expected to be unique and
/// capture all properties of the [OutputAsset]. /// capture all properties of the [OutputAsset].
#[turbo_tasks::function]
fn path(&self) -> Vc<FileSystemPath>; fn path(&self) -> Vc<FileSystemPath>;
/// Other references [OutputAsset]s from this [OutputAsset]. /// Other references [OutputAsset]s from this [OutputAsset].
#[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<OutputAssets> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
OutputAssets::empty() OutputAssets::empty()
} }
#[turbo_tasks::function]
fn size_bytes(self: Vc<Self>) -> Vc<Option<u64>> { fn size_bytes(self: Vc<Self>) -> Vc<Option<u64>> {
Vc::cell(None) Vc::cell(None)
} }
......
...@@ -27,6 +27,7 @@ pub use source_map::SourceMapReference; ...@@ -27,6 +27,7 @@ pub use source_map::SourceMapReference;
/// [ChunkableModuleReference]: crate::chunk::ChunkableModuleReference /// [ChunkableModuleReference]: crate::chunk::ChunkableModuleReference
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ModuleReference: ValueToString { pub trait ModuleReference: ValueToString {
#[turbo_tasks::function]
fn resolve_reference(self: Vc<Self>) -> Vc<ModuleResolveResult>; fn resolve_reference(self: Vc<Self>) -> Vc<ModuleResolveResult>;
// TODO think about different types // TODO think about different types
// fn kind(&self) -> Vc<AssetReferenceType>; // fn kind(&self) -> Vc<AssetReferenceType>;
......
...@@ -690,7 +690,9 @@ pub async fn resolve_modules_options( ...@@ -690,7 +690,9 @@ pub async fn resolve_modules_options(
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ImportMappingReplacement { pub trait ImportMappingReplacement {
#[turbo_tasks::function]
fn replace(self: Vc<Self>, capture: Vc<Pattern>) -> Vc<ReplacedImportMapping>; fn replace(self: Vc<Self>, capture: Vc<Pattern>) -> Vc<ReplacedImportMapping>;
#[turbo_tasks::function]
fn result( fn result(
self: Vc<Self>, self: Vc<Self>,
lookup_path: Vc<FileSystemPath>, lookup_path: Vc<FileSystemPath>,
......
...@@ -16,14 +16,17 @@ pub trait ResolveOrigin { ...@@ -16,14 +16,17 @@ pub trait ResolveOrigin {
/// since that might be needed to infer custom resolving options for that /// since that might be needed to infer custom resolving options for that
/// specific file. But usually only the directory is relevant for the real /// specific file. But usually only the directory is relevant for the real
/// resolving. /// resolving.
#[turbo_tasks::function]
fn origin_path(self: Vc<Self>) -> Vc<FileSystemPath>; fn origin_path(self: Vc<Self>) -> Vc<FileSystemPath>;
/// The AssetContext that carries the configuration for building that /// The AssetContext that carries the configuration for building that
/// subgraph. /// subgraph.
#[turbo_tasks::function]
fn asset_context(self: Vc<Self>) -> Vc<Box<dyn AssetContext>>; fn asset_context(self: Vc<Self>) -> Vc<Box<dyn AssetContext>>;
/// Get an inner asset form this origin that doesn't require resolving but /// Get an inner asset form this origin that doesn't require resolving but
/// is directly attached /// is directly attached
#[turbo_tasks::function]
fn get_inner_asset(self: Vc<Self>, request: Vc<Request>) -> Vc<OptionModule> { fn get_inner_asset(self: Vc<Self>, request: Vc<Request>) -> Vc<OptionModule> {
let _ = request; let _ = request;
Vc::cell(None) Vc::cell(None)
......
...@@ -82,8 +82,10 @@ impl BeforeResolvePluginCondition { ...@@ -82,8 +82,10 @@ impl BeforeResolvePluginCondition {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait BeforeResolvePlugin { pub trait BeforeResolvePlugin {
#[turbo_tasks::function]
fn before_resolve_condition(self: Vc<Self>) -> Vc<BeforeResolvePluginCondition>; fn before_resolve_condition(self: Vc<Self>) -> Vc<BeforeResolvePluginCondition>;
#[turbo_tasks::function]
fn before_resolve( fn before_resolve(
self: Vc<Self>, self: Vc<Self>,
lookup_path: Vc<FileSystemPath>, lookup_path: Vc<FileSystemPath>,
...@@ -95,11 +97,13 @@ pub trait BeforeResolvePlugin { ...@@ -95,11 +97,13 @@ pub trait BeforeResolvePlugin {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait AfterResolvePlugin { pub trait AfterResolvePlugin {
/// A condition which determines if the hooks gets called. /// A condition which determines if the hooks gets called.
#[turbo_tasks::function]
fn after_resolve_condition(self: Vc<Self>) -> Vc<AfterResolvePluginCondition>; fn after_resolve_condition(self: Vc<Self>) -> Vc<AfterResolvePluginCondition>;
/// This hook gets called when a full filepath has been resolved and the /// This hook gets called when a full filepath has been resolved and the
/// condition matches. If a value is returned it replaces the resolve /// condition matches. If a value is returned it replaces the resolve
/// result. /// result.
#[turbo_tasks::function]
fn after_resolve( fn after_resolve(
self: Vc<Self>, self: Vc<Self>,
fs_path: Vc<FileSystemPath>, fs_path: Vc<FileSystemPath>,
......
...@@ -8,6 +8,7 @@ use crate::{asset::Asset, ident::AssetIdent}; ...@@ -8,6 +8,7 @@ use crate::{asset::Asset, ident::AssetIdent};
pub trait Source: Asset { pub trait Source: Asset {
/// The identifier of the [Source]. It's expected to be unique and capture /// The identifier of the [Source]. It's expected to be unique and capture
/// all properties of the [Source]. /// all properties of the [Source].
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent>; fn ident(&self) -> Vc<AssetIdent>;
} }
......
...@@ -43,9 +43,11 @@ impl OptionStringifiedSourceMap { ...@@ -43,9 +43,11 @@ impl OptionStringifiedSourceMap {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait GenerateSourceMap { pub trait GenerateSourceMap {
/// Generates a usable source map, capable of both tracing and stringifying. /// Generates a usable source map, capable of both tracing and stringifying.
#[turbo_tasks::function]
fn generate_source_map(self: Vc<Self>) -> Vc<OptionStringifiedSourceMap>; fn generate_source_map(self: Vc<Self>) -> Vc<OptionStringifiedSourceMap>;
/// Returns an individual section of the larger source map, if found. /// Returns an individual section of the larger source map, if found.
#[turbo_tasks::function]
fn by_section(self: Vc<Self>, _section: RcStr) -> Vc<OptionStringifiedSourceMap> { fn by_section(self: Vc<Self>, _section: RcStr) -> Vc<OptionStringifiedSourceMap> {
Vc::cell(None) Vc::cell(None)
} }
......
...@@ -4,6 +4,7 @@ use crate::source::Source; ...@@ -4,6 +4,7 @@ use crate::source::Source;
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait SourceTransform { pub trait SourceTransform {
#[turbo_tasks::function]
fn transform(self: Vc<Self>, source: Vc<Box<dyn Source>>) -> Vc<Box<dyn Source>>; fn transform(self: Vc<Self>, source: Vc<Box<dyn Source>>) -> Vc<Box<dyn Source>>;
} }
......
...@@ -18,14 +18,17 @@ pub struct OptionVersionedContent(Option<ResolvedVc<Box<dyn VersionedContent>>>) ...@@ -18,14 +18,17 @@ pub struct OptionVersionedContent(Option<ResolvedVc<Box<dyn VersionedContent>>>)
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait VersionedContent { pub trait VersionedContent {
/// The content of the [Asset]. /// The content of the [Asset].
#[turbo_tasks::function]
fn content(self: Vc<Self>) -> Vc<AssetContent>; fn content(self: Vc<Self>) -> Vc<AssetContent>;
/// Get a [`Version`] implementor that contains enough information to /// Get a [`Version`] implementor that contains enough information to
/// identify and diff a future [`VersionedContent`] against it. /// identify and diff a future [`VersionedContent`] against it.
#[turbo_tasks::function]
fn version(self: Vc<Self>) -> Vc<Box<dyn Version>>; fn version(self: Vc<Self>) -> Vc<Box<dyn Version>>;
/// Describes how to update the content from an earlier version to the /// Describes how to update the content from an earlier version to the
/// latest available one. /// latest available one.
#[turbo_tasks::function]
async fn update(self: Vc<Self>, from: Vc<Box<dyn Version>>) -> Result<Vc<Update>> { async fn update(self: Vc<Self>, from: Vc<Box<dyn Version>>) -> Result<Vc<Update>> {
// By default, since we can't make any assumptions about the versioning // By default, since we can't make any assumptions about the versioning
// scheme of the content, we ask for a full invalidation, except in the // scheme of the content, we ask for a full invalidation, except in the
...@@ -128,6 +131,7 @@ pub trait Version { ...@@ -128,6 +131,7 @@ pub trait Version {
/// Get a unique identifier of the version as a string. There is no way /// Get a unique identifier of the version as a string. There is no way
/// to convert an id back to its original `Version`, so the original object /// to convert an id back to its original `Version`, so the original object
/// needs to be stored somewhere. /// needs to be stored somewhere.
#[turbo_tasks::function]
fn id(self: Vc<Self>) -> Vc<RcStr>; fn id(self: Vc<Self>) -> Vc<RcStr>;
} }
...@@ -138,6 +142,7 @@ pub trait Version { ...@@ -138,6 +142,7 @@ pub trait Version {
/// together. /// together.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait MergeableVersionedContent: VersionedContent { pub trait MergeableVersionedContent: VersionedContent {
#[turbo_tasks::function]
fn get_merger(self: Vc<Self>) -> Vc<Box<dyn VersionedContentMerger>>; fn get_merger(self: Vc<Self>) -> Vc<Box<dyn VersionedContentMerger>>;
} }
...@@ -145,6 +150,7 @@ pub trait MergeableVersionedContent: VersionedContent { ...@@ -145,6 +150,7 @@ pub trait MergeableVersionedContent: VersionedContent {
/// single one. /// single one.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait VersionedContentMerger { pub trait VersionedContentMerger {
#[turbo_tasks::function]
fn merge(self: Vc<Self>, contents: Vc<VersionedContents>) -> Vc<Box<dyn VersionedContent>>; fn merge(self: Vc<Self>, contents: Vc<VersionedContents>) -> Vc<Box<dyn VersionedContent>>;
} }
......
...@@ -407,6 +407,7 @@ pub struct CssChunkItemContent { ...@@ -407,6 +407,7 @@ pub struct CssChunkItemContent {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait CssChunkItem: ChunkItem { pub trait CssChunkItem: ChunkItem {
#[turbo_tasks::function]
fn content(self: Vc<Self>) -> Vc<CssChunkItemContent>; fn content(self: Vc<Self>) -> Vc<CssChunkItemContent>;
} }
......
...@@ -19,6 +19,7 @@ pub struct CodeGeneration { ...@@ -19,6 +19,7 @@ pub struct CodeGeneration {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait CodeGenerateable { pub trait CodeGenerateable {
#[turbo_tasks::function]
fn code_generation( fn code_generation(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
......
...@@ -3,6 +3,7 @@ use turbopack_core::{asset::Asset, chunk::ChunkingContext, module::Module, outpu ...@@ -3,6 +3,7 @@ use turbopack_core::{asset::Asset, chunk::ChunkingContext, module::Module, outpu
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait CssEmbed: Module + Asset { pub trait CssEmbed: Module + Asset {
#[turbo_tasks::function]
fn embedded_asset( fn embedded_asset(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
......
...@@ -289,13 +289,16 @@ pub async fn finalize_css( ...@@ -289,13 +289,16 @@ pub async fn finalize_css(
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ParseCss { pub trait ParseCss {
#[turbo_tasks::function]
async fn parse_css(self: Vc<Self>) -> Result<Vc<ParseCssResult>>; async fn parse_css(self: Vc<Self>) -> Result<Vc<ParseCssResult>>;
} }
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ProcessCss: ParseCss { pub trait ProcessCss: ParseCss {
#[turbo_tasks::function]
async fn get_css_with_placeholder(self: Vc<Self>) -> Result<Vc<CssWithPlaceholderResult>>; async fn get_css_with_placeholder(self: Vc<Self>) -> Result<Vc<CssWithPlaceholderResult>>;
#[turbo_tasks::function]
async fn finalize_css( async fn finalize_css(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
......
...@@ -10,6 +10,7 @@ use super::{ContentSource, route_tree::RouteTree}; ...@@ -10,6 +10,7 @@ use super::{ContentSource, route_tree::RouteTree};
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait GetContentSource { pub trait GetContentSource {
/// Returns the [ContentSource] /// Returns the [ContentSource]
#[turbo_tasks::function]
fn content_source(self: Vc<Self>) -> Vc<Box<dyn ContentSource>>; fn content_source(self: Vc<Self>) -> Vc<Box<dyn ContentSource>>;
} }
......
...@@ -67,11 +67,13 @@ impl Version for ProxyResult { ...@@ -67,11 +67,13 @@ impl Version for ProxyResult {
pub trait GetContentSourceContent { pub trait GetContentSourceContent {
/// Specifies data requirements for the get function. Restricting data /// Specifies data requirements for the get function. Restricting data
/// passed allows to cache the get method. /// passed allows to cache the get method.
#[turbo_tasks::function]
fn vary(self: Vc<Self>) -> Vc<ContentSourceDataVary> { fn vary(self: Vc<Self>) -> Vc<ContentSourceDataVary> {
ContentSourceDataVary::default().cell() ContentSourceDataVary::default().cell()
} }
/// Get the content /// Get the content
#[turbo_tasks::function]
fn get(self: Vc<Self>, path: RcStr, data: ContentSourceData) -> Vc<ContentSourceContent>; fn get(self: Vc<Self>, path: RcStr, data: ContentSourceData) -> Vc<ContentSourceContent>;
} }
...@@ -102,6 +104,7 @@ pub enum ContentSourceContent { ...@@ -102,6 +104,7 @@ pub enum ContentSourceContent {
/// is handled. /// is handled.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ContentSourceSideEffect { pub trait ContentSourceSideEffect {
#[turbo_tasks::function]
fn apply(self: Vc<Self>) -> Vc<Completion>; fn apply(self: Vc<Self>) -> Vc<Completion>;
} }
...@@ -417,9 +420,11 @@ impl ContentSourceDataVary { ...@@ -417,9 +420,11 @@ impl ContentSourceDataVary {
/// A source of content that the dev server uses to respond to http requests. /// A source of content that the dev server uses to respond to http requests.
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ContentSource { pub trait ContentSource {
#[turbo_tasks::function]
fn get_routes(self: Vc<Self>) -> Vc<RouteTree>; fn get_routes(self: Vc<Self>) -> Vc<RouteTree>;
/// Gets any content sources wrapped in this content source. /// Gets any content sources wrapped in this content source.
#[turbo_tasks::function]
fn get_children(self: Vc<Self>) -> Vc<ContentSources> { fn get_children(self: Vc<Self>) -> Vc<ContentSources> {
ContentSources::empty() ContentSources::empty()
} }
......
...@@ -399,6 +399,7 @@ impl RouteTree { ...@@ -399,6 +399,7 @@ impl RouteTree {
/// Transformation functor /// Transformation functor
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait MapGetContentSourceContent { pub trait MapGetContentSourceContent {
#[turbo_tasks::function]
fn map_get_content( fn map_get_content(
self: Vc<Self>, self: Vc<Self>,
get_content: Vc<Box<dyn GetContentSourceContent>>, get_content: Vc<Box<dyn GetContentSourceContent>>,
......
...@@ -16,6 +16,7 @@ use super::{ ...@@ -16,6 +16,7 @@ use super::{
/// [ContentSourceContent]. /// [ContentSourceContent].
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait ContentSourceProcessor { pub trait ContentSourceProcessor {
#[turbo_tasks::function]
fn process(self: Vc<Self>, content: Vc<ContentSourceContent>) -> Vc<ContentSourceContent>; fn process(self: Vc<Self>, content: Vc<ContentSourceContent>) -> Vc<ContentSourceContent>;
} }
......
...@@ -214,7 +214,9 @@ impl EcmascriptChunkItemWithAsyncInfo { ...@@ -214,7 +214,9 @@ impl EcmascriptChunkItemWithAsyncInfo {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait EcmascriptChunkItem: ChunkItem { pub trait EcmascriptChunkItem: ChunkItem {
#[turbo_tasks::function]
fn content(self: Vc<Self>) -> Vc<EcmascriptChunkItemContent>; fn content(self: Vc<Self>) -> Vc<EcmascriptChunkItemContent>;
#[turbo_tasks::function]
fn content_with_async_module_info( fn content_with_async_module_info(
self: Vc<Self>, self: Vc<Self>,
_async_module_info: Option<Vc<AsyncModuleInfo>>, _async_module_info: Option<Vc<AsyncModuleInfo>>,
...@@ -224,6 +226,7 @@ pub trait EcmascriptChunkItem: ChunkItem { ...@@ -224,6 +226,7 @@ pub trait EcmascriptChunkItem: ChunkItem {
/// Specifies which availablility information the chunk item needs for code /// Specifies which availablility information the chunk item needs for code
/// generation /// generation
#[turbo_tasks::function]
fn need_async_module_info(self: Vc<Self>) -> Vc<bool> { fn need_async_module_info(self: Vc<Self>) -> Vc<bool> {
Vc::cell(false) Vc::cell(false)
} }
......
...@@ -18,10 +18,13 @@ use crate::references::{ ...@@ -18,10 +18,13 @@ use crate::references::{
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset {
#[turbo_tasks::function]
fn get_exports(self: Vc<Self>) -> Vc<EcmascriptExports>; fn get_exports(self: Vc<Self>) -> Vc<EcmascriptExports>;
#[turbo_tasks::function]
fn get_async_module(self: Vc<Self>) -> Vc<OptionAsyncModule> { fn get_async_module(self: Vc<Self>) -> Vc<OptionAsyncModule> {
Vc::cell(None) Vc::cell(None)
} }
#[turbo_tasks::function]
fn is_marked_as_side_effect_free( fn is_marked_as_side_effect_free(
self: Vc<Self>, self: Vc<Self>,
side_effect_free_packages: Vc<Glob>, side_effect_free_packages: Vc<Glob>,
......
...@@ -294,24 +294,30 @@ impl core::fmt::Debug for EcmascriptModuleAsset { ...@@ -294,24 +294,30 @@ impl core::fmt::Debug for EcmascriptModuleAsset {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait EcmascriptParsable { pub trait EcmascriptParsable {
#[turbo_tasks::function]
fn failsafe_parse(self: Vc<Self>) -> Result<Vc<ParseResult>>; fn failsafe_parse(self: Vc<Self>) -> Result<Vc<ParseResult>>;
#[turbo_tasks::function]
fn parse_original(self: Vc<Self>) -> Result<Vc<ParseResult>>; fn parse_original(self: Vc<Self>) -> Result<Vc<ParseResult>>;
#[turbo_tasks::function]
fn ty(self: Vc<Self>) -> Result<Vc<EcmascriptModuleAssetType>>; fn ty(self: Vc<Self>) -> Result<Vc<EcmascriptModuleAssetType>>;
} }
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait EcmascriptAnalyzable: Module + Asset { pub trait EcmascriptAnalyzable: Module + Asset {
#[turbo_tasks::function]
fn analyze(self: Vc<Self>) -> Vc<AnalyzeEcmascriptModuleResult>; fn analyze(self: Vc<Self>) -> Vc<AnalyzeEcmascriptModuleResult>;
/// Generates module contents without an analysis pass. This is useful for /// Generates module contents without an analysis pass. This is useful for
/// transforming code that is not a module, e.g. runtime code. /// transforming code that is not a module, e.g. runtime code.
#[turbo_tasks::function]
async fn module_content_without_analysis( async fn module_content_without_analysis(
self: Vc<Self>, self: Vc<Self>,
generate_source_map: bool, generate_source_map: bool,
) -> Result<Vc<EcmascriptModuleContent>>; ) -> Result<Vc<EcmascriptModuleContent>>;
#[turbo_tasks::function]
async fn module_content_options( async fn module_content_options(
self: Vc<Self>, self: Vc<Self>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
...@@ -319,6 +325,7 @@ pub trait EcmascriptAnalyzable: Module + Asset { ...@@ -319,6 +325,7 @@ pub trait EcmascriptAnalyzable: Module + Asset {
async_module_info: Option<Vc<AsyncModuleInfo>>, async_module_info: Option<Vc<AsyncModuleInfo>>,
) -> Result<Vc<EcmascriptModuleContentOptions>>; ) -> Result<Vc<EcmascriptModuleContentOptions>>;
#[turbo_tasks::function]
async fn module_content( async fn module_content(
self: Vc<Self>, self: Vc<Self>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
......
...@@ -20,7 +20,10 @@ pub struct NodeRenderingEntries(Vec<ResolvedVc<NodeRenderingEntry>>); ...@@ -20,7 +20,10 @@ pub struct NodeRenderingEntries(Vec<ResolvedVc<NodeRenderingEntry>>);
/// Trait that allows to get the entry module for rendering something in Node.js /// Trait that allows to get the entry module for rendering something in Node.js
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait NodeEntry { pub trait NodeEntry {
#[turbo_tasks::function]
fn entry(self: Vc<Self>, data: ContentSourceData) -> Vc<NodeRenderingEntry>; fn entry(self: Vc<Self>, data: ContentSourceData) -> Vc<NodeRenderingEntry>;
#[turbo_tasks::function]
async fn entries(self: Vc<Self>) -> Result<Vc<NodeRenderingEntries>> { async fn entries(self: Vc<Self>) -> Result<Vc<NodeRenderingEntries>> {
Ok(Vc::cell(vec![ Ok(Vc::cell(vec![
self.entry(Default::default()).to_resolved().await?, self.entry(Default::default()).to_resolved().await?,
......
...@@ -26,8 +26,10 @@ pub trait RouteMatcherRef { ...@@ -26,8 +26,10 @@ pub trait RouteMatcherRef {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait RouteMatcher { pub trait RouteMatcher {
/// Returns whether the given path is a match for the route. /// Returns whether the given path is a match for the route.
#[turbo_tasks::function]
fn matches(self: Vc<Self>, path: RcStr) -> Vc<bool>; fn matches(self: Vc<Self>, path: RcStr) -> Vc<bool>;
/// Returns the parameters extracted from the given path. /// Returns the parameters extracted from the given path.
#[turbo_tasks::function]
fn params(self: Vc<Self>, path: RcStr) -> Vc<Params>; fn params(self: Vc<Self>, path: RcStr) -> Vc<Params>;
} }
...@@ -5,6 +5,7 @@ use crate::ModuleAssetContext; ...@@ -5,6 +5,7 @@ use crate::ModuleAssetContext;
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait CustomModuleType { pub trait CustomModuleType {
#[turbo_tasks::function]
fn create_module( fn create_module(
self: Vc<Self>, self: Vc<Self>,
source: Vc<Box<dyn Source>>, source: Vc<Box<dyn Source>>,
......
...@@ -22,11 +22,13 @@ use crate::{ ...@@ -22,11 +22,13 @@ use crate::{
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
pub trait Transition { pub trait Transition {
/// Apply modifications/wrapping to the source asset /// Apply modifications/wrapping to the source asset
#[turbo_tasks::function]
fn process_source(self: Vc<Self>, asset: Vc<Box<dyn Source>>) -> Vc<Box<dyn Source>> { fn process_source(self: Vc<Self>, asset: Vc<Box<dyn Source>>) -> Vc<Box<dyn Source>> {
asset asset
} }
/// Apply modifications to the compile-time information /// Apply modifications to the compile-time information
#[turbo_tasks::function]
fn process_compile_time_info( fn process_compile_time_info(
self: Vc<Self>, self: Vc<Self>,
compile_time_info: Vc<CompileTimeInfo>, compile_time_info: Vc<CompileTimeInfo>,
...@@ -35,6 +37,7 @@ pub trait Transition { ...@@ -35,6 +37,7 @@ pub trait Transition {
} }
/// Apply modifications/wrapping to the module options context /// Apply modifications/wrapping to the module options context
#[turbo_tasks::function]
fn process_module_options_context( fn process_module_options_context(
self: Vc<Self>, self: Vc<Self>,
module_options_context: Vc<ModuleOptionsContext>, module_options_context: Vc<ModuleOptionsContext>,
...@@ -43,6 +46,7 @@ pub trait Transition { ...@@ -43,6 +46,7 @@ pub trait Transition {
} }
/// Apply modifications/wrapping to the resolve options context /// Apply modifications/wrapping to the resolve options context
#[turbo_tasks::function]
fn process_resolve_options_context( fn process_resolve_options_context(
self: Vc<Self>, self: Vc<Self>,
resolve_options_context: Vc<ResolveOptionsContext>, resolve_options_context: Vc<ResolveOptionsContext>,
...@@ -51,6 +55,7 @@ pub trait Transition { ...@@ -51,6 +55,7 @@ pub trait Transition {
} }
/// Apply modifications/wrapping to the transition options /// Apply modifications/wrapping to the transition options
#[turbo_tasks::function]
fn process_transition_options( fn process_transition_options(
self: Vc<Self>, self: Vc<Self>,
transition_options: Vc<TransitionOptions>, transition_options: Vc<TransitionOptions>,
...@@ -59,6 +64,7 @@ pub trait Transition { ...@@ -59,6 +64,7 @@ pub trait Transition {
} }
/// Apply modifications/wrapping to the final asset /// Apply modifications/wrapping to the final asset
#[turbo_tasks::function]
fn process_module( fn process_module(
self: Vc<Self>, self: Vc<Self>,
module: Vc<Box<dyn Module>>, module: Vc<Box<dyn Module>>,
...@@ -68,6 +74,7 @@ pub trait Transition { ...@@ -68,6 +74,7 @@ pub trait Transition {
} }
/// Apply modifications to the context /// Apply modifications to the context
#[turbo_tasks::function]
async fn process_context( async fn process_context(
self: Vc<Self>, self: Vc<Self>,
module_asset_context: Vc<ModuleAssetContext>, module_asset_context: Vc<ModuleAssetContext>,
...@@ -92,6 +99,7 @@ pub trait Transition { ...@@ -92,6 +99,7 @@ pub trait Transition {
} }
/// Apply modification on the processing of the asset /// Apply modification on the processing of the asset
#[turbo_tasks::function]
async fn process( async fn process(
self: Vc<Self>, self: Vc<Self>,
asset: Vc<Box<dyn Source>>, asset: Vc<Box<dyn Source>>,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment