Unverified Commit a5d24dc7 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

chore(turbo-tasks): Delete `non_local_return` support from `#[turbo_tasks::function]` (#75209)

This code was left over from when we thought that we could perform the `ResolvedVc` migration on a per-function basis by inspecting the return value of the function.

*Oh, to be so naïve! The innocence we've lost!*

Every `VcValueType` and `VcValueTrait` is a `NonLocalValue` now, so this macro option is no longer useful.
parent dae2f036
error: unexpected token, expected one of: "fs", "network", "non_local_return", "operation", or "local_cells" error: unexpected token, expected one of: "fs", "network", "operation", or "local_cells"
--> tests/function/fail_attribute_invalid_args.rs:9:25 --> tests/function/fail_attribute_invalid_args.rs:9:25
| |
9 | #[turbo_tasks::function(invalid_argument)] 9 | #[turbo_tasks::function(invalid_argument)]
......
error: unexpected token, expected one of: "fs", "network", "non_local_return", "operation", or "local_cells" error: unexpected token, expected one of: "fs", "network", "operation", or "local_cells"
--> tests/function/fail_attribute_invalid_args_inherent_impl.rs:14:29 --> tests/function/fail_attribute_invalid_args_inherent_impl.rs:14:29
| |
14 | #[turbo_tasks::function(invalid_argument)] 14 | #[turbo_tasks::function(invalid_argument)]
......
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)]
#![allow(dead_code)]
use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value]
struct ExampleStruct;
#[turbo_tasks::value(transparent)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_impl]
impl ExampleStruct {
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
}
fn main() {}
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)]
#![allow(dead_code)]
use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value(transparent)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc() -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc_result() -> anyhow::Result<Vc<IntegersVec>> {
Ok(Vc::cell(Vec::new()))
}
fn main() {}
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)]
#![allow(dead_code)]
use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value]
struct ExampleStruct;
#[turbo_tasks::value(transparent)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_trait]
trait ExampleTrait {
fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec>;
}
#[turbo_tasks::value_impl]
impl ExampleTrait for ExampleStruct {
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
}
fn main() {}
...@@ -28,8 +28,6 @@ pub struct TurboFn<'a> { ...@@ -28,8 +28,6 @@ pub struct TurboFn<'a> {
output: Type, output: Type,
this: Option<Input>, this: Option<Input>,
inputs: Vec<Input>, inputs: Vec<Input>,
/// Should we check that the return type contains a `NonLocalValue`?
non_local: Option<Span>,
/// Should we return `OperationVc` and require that all arguments are `NonLocalValue`s? /// Should we return `OperationVc` and require that all arguments are `NonLocalValue`s?
operation: bool, operation: bool,
/// Should this function use `TaskPersistence::LocalCells`? /// Should this function use `TaskPersistence::LocalCells`?
...@@ -275,7 +273,6 @@ impl TurboFn<'_> { ...@@ -275,7 +273,6 @@ impl TurboFn<'_> {
output, output,
this, this,
inputs, inputs,
non_local: args.non_local_return,
operation: args.operation.is_some(), operation: args.operation.is_some(),
local_cells: args.local_cells.is_some(), local_cells: args.local_cells.is_some(),
inline_ident, inline_ident,
...@@ -514,13 +511,7 @@ impl TurboFn<'_> { ...@@ -514,13 +511,7 @@ impl TurboFn<'_> {
} }
fn get_assertions(&self) -> TokenStream { fn get_assertions(&self) -> TokenStream {
if let Some(span) = self.non_local { if self.operation {
let return_type = &self.output;
quote_spanned! {
span =>
turbo_tasks::macro_helpers::assert_returns_non_local_value::<#return_type, _>();
}
} else if self.operation {
let mut assertions = Vec::new(); let mut assertions = Vec::new();
// theoretically we could support methods by rewriting the exposed self argument, but // theoretically we could support methods by rewriting the exposed self argument, but
// it's not worth it, given the rarity of operations. // it's not worth it, given the rarity of operations.
...@@ -706,15 +697,8 @@ pub struct FunctionArguments { ...@@ -706,15 +697,8 @@ pub struct FunctionArguments {
/// This should only be used by the task that directly performs the IO. Tasks that transitively /// This should only be used by the task that directly performs the IO. Tasks that transitively
/// perform IO should not be manually annotated. /// perform IO should not be manually annotated.
io_markers: HashSet<IoMarker>, io_markers: HashSet<IoMarker>,
/// Should we check that the return type contains a `NonLocalValue`?
///
/// If there is an error due to this option being set, it should be reported to this span.
///
/// If [`Self::local_cells`] is set, this will also be set to the same span.
non_local_return: Option<Span>,
/// Should the function return an `OperationVc` instead of a `Vc`? Also ensures that all /// Should the function return an `OperationVc` instead of a `Vc`? Also ensures that all
/// arguments are `OperationValue`s. Mutually exclusive with the `non_local_return` and /// arguments are `OperationValue`s. Mutually exclusive with the `local_cells` flag.
/// `local_cells` flags.
/// ///
/// If there is an error due to this option being set, it should be reported to this span. /// If there is an error due to this option being set, it should be reported to this span.
operation: Option<Span>, operation: Option<Span>,
...@@ -722,8 +706,6 @@ pub struct FunctionArguments { ...@@ -722,8 +706,6 @@ pub struct FunctionArguments {
/// executions. Cells can be converted to their non-local versions by calling `Vc::resolve`. /// executions. Cells can be converted to their non-local versions by calling `Vc::resolve`.
/// ///
/// If there is an error due to this option being set, it should be reported to this span. /// If there is an error due to this option being set, it should be reported to this span.
///
/// Setting this option will also set [`Self::non_local`] to the same span.
pub local_cells: Option<Span>, pub local_cells: Option<Span>,
} }
...@@ -746,31 +728,26 @@ impl Parse for FunctionArguments { ...@@ -746,31 +728,26 @@ impl Parse for FunctionArguments {
("network", Meta::Path(_)) => { ("network", Meta::Path(_)) => {
parsed_args.io_markers.insert(IoMarker::Network); parsed_args.io_markers.insert(IoMarker::Network);
} }
("non_local_return", Meta::Path(_)) => {
parsed_args.non_local_return = Some(meta.span());
}
("operation", Meta::Path(_)) => { ("operation", Meta::Path(_)) => {
parsed_args.operation = Some(meta.span()); parsed_args.operation = Some(meta.span());
} }
("local_cells", Meta::Path(_)) => { ("local_cells", Meta::Path(_)) => {
let span = Some(meta.span()); let span = Some(meta.span());
parsed_args.local_cells = span; parsed_args.local_cells = span;
parsed_args.non_local_return = span;
} }
(_, meta) => { (_, meta) => {
return Err(syn::Error::new_spanned( return Err(syn::Error::new_spanned(
meta, meta,
"unexpected token, expected one of: \"fs\", \"network\", \ "unexpected token, expected one of: \"fs\", \"network\", \"operation\", \
\"non_local_return\", \"operation\", or \"local_cells\"", or \"local_cells\"",
)) ))
} }
} }
} }
if let (Some(_), Some(span)) = (parsed_args.non_local_return, parsed_args.operation) { if let (Some(_), Some(span)) = (parsed_args.local_cells, parsed_args.operation) {
return Err(syn::Error::new( return Err(syn::Error::new(
span, span,
"\"operation\" is mutually exclusive with \"non_local_return\" and \ "\"operation\" is mutually exclusive with the \"local_cells\" option",
\"local_cells\" options",
)); ));
} }
Ok(parsed_args) Ok(parsed_args)
......
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