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
|
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
|
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> {
output: Type,
this: Option<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?
operation: bool,
/// Should this function use `TaskPersistence::LocalCells`?
......@@ -275,7 +273,6 @@ impl TurboFn<'_> {
output,
this,
inputs,
non_local: args.non_local_return,
operation: args.operation.is_some(),
local_cells: args.local_cells.is_some(),
inline_ident,
......@@ -514,13 +511,7 @@ impl TurboFn<'_> {
}
fn get_assertions(&self) -> TokenStream {
if let Some(span) = self.non_local {
let return_type = &self.output;
quote_spanned! {
span =>
turbo_tasks::macro_helpers::assert_returns_non_local_value::<#return_type, _>();
}
} else if self.operation {
if self.operation {
let mut assertions = Vec::new();
// theoretically we could support methods by rewriting the exposed self argument, but
// it's not worth it, given the rarity of operations.
......@@ -706,15 +697,8 @@ pub struct FunctionArguments {
/// This should only be used by the task that directly performs the IO. Tasks that transitively
/// perform IO should not be manually annotated.
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
/// arguments are `OperationValue`s. Mutually exclusive with the `non_local_return` and
/// `local_cells` flags.
/// arguments are `OperationValue`s. Mutually exclusive with the `local_cells` flag.
///
/// If there is an error due to this option being set, it should be reported to this span.
operation: Option<Span>,
......@@ -722,8 +706,6 @@ pub struct FunctionArguments {
/// 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.
///
/// Setting this option will also set [`Self::non_local`] to the same span.
pub local_cells: Option<Span>,
}
......@@ -746,31 +728,26 @@ impl Parse for FunctionArguments {
("network", Meta::Path(_)) => {
parsed_args.io_markers.insert(IoMarker::Network);
}
("non_local_return", Meta::Path(_)) => {
parsed_args.non_local_return = Some(meta.span());
}
("operation", Meta::Path(_)) => {
parsed_args.operation = Some(meta.span());
}
("local_cells", Meta::Path(_)) => {
let span = Some(meta.span());
parsed_args.local_cells = span;
parsed_args.non_local_return = span;
}
(_, meta) => {
return Err(syn::Error::new_spanned(
meta,
"unexpected token, expected one of: \"fs\", \"network\", \
\"non_local_return\", \"operation\", or \"local_cells\"",
"unexpected token, expected one of: \"fs\", \"network\", \"operation\", \
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(
span,
"\"operation\" is mutually exclusive with \"non_local_return\" and \
\"local_cells\" options",
"\"operation\" is mutually exclusive with the \"local_cells\" option",
));
}
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