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

refactor(turbo-tasks): Rename ResolvedValue trait to NonLocalValue (#73191)

I want to allow `OperationVc` to be used in all the places that `ResolvedVc` is allowed. The real restriction we care about is that the `Vc`s we have aren't task-local.

- Rename `ResolvedValue` to `NonLocalValue`. Move it into a different `vc/local.rs` module.
- Rename arguments used in macros to `non_local` (for `turbo_tasks::value` and `turbo_tasks::value_trait`) and `non_local_return` (for `turbo_tasks::function`).
- Implement `NonLocalValue` for `OperationVc`.

![Screenshot 2024-11-25 at 16-43-56 NonLocalValue in turbo_tasks - Rust.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HAZVitxRNnZz8QMiPn4a/effbb437-1a20-4973-bd83-e93b987f0e89.png)
parent 3c1f2d6a
......@@ -12,10 +12,10 @@ pub struct ValueTraitArguments {
/// Whether the macro should generate a `ValueDebug`-like `dbg()`
/// implementation on the trait's `Vc`.
pub debug: bool,
/// Should the trait have a `turbo_tasks::ResolvedValue` constraint?
/// Should the trait have a `turbo_tasks::NonLocalValue` constraint?
///
/// `Some(...)` if enabled, containing the span that enabled the constraint.
pub resolved: Option<Span>,
pub non_local: Option<Span>,
/// Should the trait have a `turbo_tasks::OperationValue` constraint?
pub operation: Option<Span>,
}
......@@ -24,7 +24,7 @@ impl Default for ValueTraitArguments {
fn default() -> Self {
Self {
debug: true,
resolved: None,
non_local: None,
operation: None,
}
}
......@@ -43,8 +43,8 @@ impl Parse for ValueTraitArguments {
Some("no_debug") => {
result.debug = false;
}
Some("resolved") => {
result.resolved = Some(meta.span());
Some("non_local") => {
result.non_local = Some(meta.span());
}
Some("operation") => {
result.operation = Some(meta.span());
......
#![allow(dead_code)]
use turbo_tasks::{ResolvedValue, Vc};
use turbo_tasks::{NonLocalValue, Vc};
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsOnlyVc {
a: Vc<i32>,
}
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_contains_only_vc.rs:7:8
error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_contains_only_vc.rs:7:8
|
7 | a: Vc<i32>,
| ^^^^^^^ the trait `ResolvedValue` is not implemented for `Vc<i32>`
| ^^^^^^^ the trait `NonLocalValue` is not implemented for `Vc<i32>`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,9 +14,9 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_contains_only_vc.rs:5:10
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_contains_only_vc.rs:5:10
|
5 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
5 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)]
use turbo_tasks::{ResolvedValue, ResolvedVc, Vc};
use turbo_tasks::{NonLocalValue, ResolvedVc, Vc};
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsResolvedVcAndVc {
a: ResolvedVc<i32>,
b: Vc<i32>,
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_contains_resolved_vc_and_vc.rs:8:8
error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_contains_resolved_vc_and_vc.rs:8:8
|
8 | b: Vc<i32>,
| ^^^^^^^ the trait `ResolvedValue` is not implemented for `Vc<i32>`
| ^^^^^^^ the trait `NonLocalValue` is not implemented for `Vc<i32>`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,9 +14,9 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_contains_resolved_vc_and_vc.rs:5:10
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_contains_resolved_vc_and_vc.rs:5:10
|
5 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
5 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)]
use turbo_tasks::{ResolvedValue, Vc};
use turbo_tasks::{NonLocalValue, Vc};
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsVcInsideGeneric {
a: Option<Box<[Vc<i32>; 4]>>,
}
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_contains_vc_inside_generic.rs:7:8
error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_contains_vc_inside_generic.rs:7:8
|
7 | a: Option<Box<[Vc<i32>; 4]>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ResolvedValue` is not implemented for `Vc<i32>`, which is required by `std::option::Option<Box<[Vc<i32>; 4]>>: ResolvedValue`
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `Vc<i32>`, which is required by `std::option::Option<Box<[Vc<i32>; 4]>>: NonLocalValue`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,12 +14,12 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
= note: required for `[Vc<i32>; 4]` to implement `ResolvedValue`
= note: required for `[Vc<i32>; 4]` to implement `NonLocalValue`
= note: 2 redundant requirements hidden
= note: required for `std::option::Option<Box<[Vc<i32>; 4]>>` to implement `ResolvedValue`
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_contains_vc_inside_generic.rs:5:10
= note: required for `std::option::Option<Box<[Vc<i32>; 4]>>` to implement `NonLocalValue`
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_contains_vc_inside_generic.rs:5:10
|
5 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
5 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)]
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
struct UnresolvedValue;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
enum ContainsUnresolvedValue {
Unit,
Unnamed(UnresolvedValue),
......
error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_enum.rs:10:13
error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_simple_enum.rs:10:13
|
10 | Unnamed(UnresolvedValue),
| ^^^^^^^^^^^^^^^ the trait `ResolvedValue` is not implemented for `UnresolvedValue`
| ^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `UnresolvedValue`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,20 +14,20 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_simple_enum.rs:7:10
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_simple_enum.rs:7:10
|
7 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_enum.rs:11:16
error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_simple_enum.rs:11:16
|
11 | Named { a: UnresolvedValue },
| ^^^^^^^^^^^^^^^ the trait `ResolvedValue` is not implemented for `UnresolvedValue`
| ^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `UnresolvedValue`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -37,9 +37,9 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_simple_enum.rs:7:10
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_simple_enum.rs:7:10
|
7 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)]
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
struct UnresolvedValue;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsUnresolvedValueNamed {
a: UnresolvedValue,
}
......
error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_named_struct.rs:9:8
error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_simple_named_struct.rs:9:8
|
9 | a: UnresolvedValue,
| ^^^^^^^^^^^^^^^ the trait `ResolvedValue` is not implemented for `UnresolvedValue`
| ^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `UnresolvedValue`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,9 +14,9 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_simple_named_struct.rs:7:10
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_simple_named_struct.rs:7:10
|
7 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)]
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
struct UnresolvedValue;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsUnresolvedValueUnnamed(UnresolvedValue);
fn main() {}
error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_unnamed_struct.rs:8:39
error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_simple_unnamed_struct.rs:8:39
|
8 | struct ContainsUnresolvedValueUnnamed(UnresolvedValue);
| ^^^^^^^^^^^^^^^ the trait `ResolvedValue` is not implemented for `UnresolvedValue`
| ^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `UnresolvedValue`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,9 +14,9 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_simple_unnamed_struct.rs:7:10
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_simple_unnamed_struct.rs:7:10
|
7 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)]
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsUnderconstrainedGeneric<T> {
value: T,
}
......
error[E0277]: the trait bound `T: NonLocalValue` is not satisfied
--> tests/derive_non_local_value/fail_underconstrained_generic.rs:7:12
|
7 | value: T,
| ^ the trait `NonLocalValue` is not implemented for `T`
|
note: required by a bound in `DeriveNonLocalValueAssertion::<T>::assert_impl_NonLocalValue`
--> tests/derive_non_local_value/fail_underconstrained_generic.rs:5:10
|
5 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::<T>::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `T`
|
6 | struct ContainsUnderconstrainedGeneric<T: turbo_tasks::NonLocalValue> {
| ++++++++++++++++++++++++++++
#![allow(dead_code)]
use turbo_tasks::{ResolvedValue, ResolvedVc};
use turbo_tasks::{NonLocalValue, ResolvedVc};
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsResolvedVcNamedStruct {
a: ResolvedVc<i32>,
}
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsResolvedVcUnnamedStruct(ResolvedVc<i32>);
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
enum ContainsResolvedVcEnum {
Unit,
Unnamed(ResolvedVc<i32>),
Named { a: ResolvedVc<i32> },
}
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsResolvedAlongWithOtherValues {
a: i32,
b: ResolvedVc<i32>,
......
use std::marker::PhantomData;
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
struct UnannotatedValue<T>(PhantomData<T>);
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsIgnore<T> {
#[turbo_tasks(trace_ignore)]
a: UnannotatedValue<T>,
......
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsBorrowedData<'a> {
borrowed: &'a Option<&'a [&'a str]>,
}
......
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
// use an inline type constraint here
struct LinkedList<T: ResolvedValue> {
// LinkedListNode is also a ResolvedValue
struct LinkedList<T: NonLocalValue> {
// LinkedListNode is also a NonLocalValue
head: Option<Box<LinkedListNode<T>>>,
}
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct LinkedListNode<T>
where
T: ResolvedValue, // use a where type constraint here
T: NonLocalValue, // use a where type constraint here
{
current: T,
// A self-recursive type
......
......@@ -2,11 +2,11 @@
use std::marker::PhantomData;
use turbo_tasks::{ResolvedValue, Vc};
use turbo_tasks::{NonLocalValue, Vc};
struct Unresolved;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct PhantomDataCanContainAnything<T: Send>(
PhantomData<Vc<T>>,
PhantomData<Unresolved>,
......
#![allow(dead_code)]
use turbo_tasks::{ResolvedValue, ResolvedVc};
use turbo_tasks::{NonLocalValue, ResolvedVc};
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
enum EnumI32 {
Unit,
Unnamed(i32),
Named { a: i32 },
}
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
enum EnumResolvedVc {
Unit,
Unnamed(ResolvedVc<i32>),
......
......@@ -2,12 +2,12 @@
use std::marker::PhantomData;
use turbo_tasks::ResolvedValue;
use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct UnitStruct;
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsSimpleValuesNamed {
a: i32,
b: String,
......@@ -17,7 +17,7 @@ struct ContainsSimpleValuesNamed {
f: PhantomData<u8>,
}
#[derive(ResolvedValue)]
#[derive(NonLocalValue)]
struct ContainsSimpleValuesUnnamed(i32, String, ());
fn main() {}
error[E0277]: the trait bound `T: ResolvedValue` is not satisfied
--> tests/derive_resolved_value/fail_underconstrained_generic.rs:7:12
|
7 | value: T,
| ^ the trait `ResolvedValue` is not implemented for `T`
|
note: required by a bound in `DeriveResolvedValueAssertion::<T>::assert_impl_ResolvedValue`
--> tests/derive_resolved_value/fail_underconstrained_generic.rs:5:10
|
5 | #[derive(ResolvedValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::<T>::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `T`
|
6 | struct ContainsUnderconstrainedGeneric<T: turbo_tasks::ResolvedValue> {
| ++++++++++++++++++++++++++++
......@@ -3,7 +3,7 @@
use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value(transparent, resolved)]
#[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::function(invalid_argument)]
......
error: unexpected token, expected one of: "fs", "network", "resolved", "local_cells"
error: unexpected token, expected one of: "fs", "network", "non_local_return", "local_cells"
--> tests/function/fail_attribute_invalid_args.rs:9:25
|
9 | #[turbo_tasks::function(invalid_argument)]
......
......@@ -6,7 +6,7 @@ use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value]
struct ExampleStruct;
#[turbo_tasks::value(transparent, resolved)]
#[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_impl]
......
error: unexpected token, expected one of: "fs", "network", "resolved", "local_cells"
error: unexpected token, expected one of: "fs", "network", "non_local_return", "local_cells"
--> tests/function/fail_attribute_invalid_args_inherent_impl.rs:14:29
|
14 | #[turbo_tasks::function(invalid_argument)]
......
......@@ -12,7 +12,7 @@ struct IntegersVec(Vec<Vc<u32>>);
#[turbo_tasks::value_impl]
impl ExampleStruct {
#[turbo_tasks::function(resolved)]
#[turbo_tasks::function(non_local_return)]
fn return_contains_unresolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
......
error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied
--> tests/function/fail_resolved_trait_impl.rs:20:29
error[E0277]: the trait bound `IntegersVec: NonLocalValue` is not satisfied
--> tests/function/fail_non_local_inherent_impl.rs:15:29
|
20 | #[turbo_tasks::function(resolved)]
| ^^^^^^^^ the trait `ResolvedValue` is not implemented for `IntegersVec`
15 | #[turbo_tasks::function(non_local_return)]
| ^^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `IntegersVec`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,11 +14,11 @@ error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `assert_returns_resolved_value`
note: required by a bound in `assert_returns_non_local_value`
--> $WORKSPACE/turbopack/crates/turbo-tasks/src/macro_helpers.rs
|
| pub fn assert_returns_resolved_value<ReturnType, Rv>()
| ----------------------------- required by a bound in this function
| pub fn assert_returns_non_local_value<ReturnType, Rv>()
| ------------------------------ required by a bound in this function
...
| Rv: ResolvedValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_resolved_value`
| Rv: NonLocalValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_non_local_value`
......@@ -7,7 +7,7 @@ use turbo_tasks::Vc;
#[turbo_tasks::value(transparent)]
struct IntegersVec(Vec<Vc<u32>>);
#[turbo_tasks::function(resolved)]
#[turbo_tasks::function(non_local_return)]
fn return_contains_unresolved_vc() -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
......
error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied
--> tests/function/fail_resolved_inherent_impl.rs:15:29
error[E0277]: the trait bound `IntegersVec: NonLocalValue` is not satisfied
--> tests/function/fail_non_local_static.rs:10:25
|
15 | #[turbo_tasks::function(resolved)]
| ^^^^^^^^ the trait `ResolvedValue` is not implemented for `IntegersVec`
10 | #[turbo_tasks::function(non_local_return)]
| ^^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `IntegersVec`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,11 +14,11 @@ error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `assert_returns_resolved_value`
note: required by a bound in `assert_returns_non_local_value`
--> $WORKSPACE/turbopack/crates/turbo-tasks/src/macro_helpers.rs
|
| pub fn assert_returns_resolved_value<ReturnType, Rv>()
| ----------------------------- required by a bound in this function
| pub fn assert_returns_non_local_value<ReturnType, Rv>()
| ------------------------------ required by a bound in this function
...
| Rv: ResolvedValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_resolved_value`
| Rv: NonLocalValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_non_local_value`
......@@ -17,7 +17,7 @@ trait ExampleTrait {
#[turbo_tasks::value_impl]
impl ExampleTrait for ExampleStruct {
#[turbo_tasks::function(resolved)]
#[turbo_tasks::function(non_local_return)]
fn return_contains_unresolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
......
error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied
--> tests/function/fail_resolved_static.rs:10:25
error[E0277]: the trait bound `IntegersVec: NonLocalValue` is not satisfied
--> tests/function/fail_non_local_trait_impl.rs:20:29
|
10 | #[turbo_tasks::function(resolved)]
| ^^^^^^^^ the trait `ResolvedValue` is not implemented for `IntegersVec`
20 | #[turbo_tasks::function(non_local_return)]
| ^^^^^^^^^^^^^^^^ the trait `NonLocalValue` is not implemented for `IntegersVec`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,11 +14,11 @@ error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `assert_returns_resolved_value`
note: required by a bound in `assert_returns_non_local_value`
--> $WORKSPACE/turbopack/crates/turbo-tasks/src/macro_helpers.rs
|
| pub fn assert_returns_resolved_value<ReturnType, Rv>()
| ----------------------------- required by a bound in this function
| pub fn assert_returns_non_local_value<ReturnType, Rv>()
| ------------------------------ required by a bound in this function
...
| Rv: ResolvedValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_resolved_value`
| Rv: NonLocalValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_non_local_value`
......@@ -7,12 +7,12 @@ use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value]
struct ExampleStruct;
#[turbo_tasks::value(transparent, resolved)]
#[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_impl]
impl ExampleStruct {
#[turbo_tasks::function(resolved)]
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
......
......@@ -4,15 +4,15 @@
use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value(transparent, resolved)]
#[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::function(resolved)]
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc() -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
#[turbo_tasks::function(resolved)]
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc_result() -> anyhow::Result<Vc<IntegersVec>> {
Ok(Vc::cell(Vec::new()))
}
......
......@@ -7,7 +7,7 @@ use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value]
struct ExampleStruct;
#[turbo_tasks::value(transparent, resolved)]
#[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_trait]
......@@ -17,7 +17,7 @@ trait ExampleTrait {
#[turbo_tasks::value_impl]
impl ExampleTrait for ExampleStruct {
#[turbo_tasks::function(resolved)]
#[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new())
}
......
......@@ -6,7 +6,7 @@ use anyhow::Result;
use turbo_tasks::{ResolvedVc, Vc};
#[derive(Clone)]
#[turbo_tasks::value(resolved)]
#[turbo_tasks::value(non_local)]
struct ExampleStruct {
items: Vec<ResolvedVc<u32>>,
}
......@@ -41,7 +41,7 @@ impl ExampleStruct {
fn non_turbo_method_with_resolved_vc_self(self: ResolvedVc<Self>) {}
}
#[turbo_tasks::value(resolved, transparent)]
#[turbo_tasks::value(non_local, transparent)]
struct MaybeExampleStruct(Option<ExampleStruct>);
#[turbo_tasks::function]
......
......@@ -6,10 +6,10 @@ fn derive_operation_value() {
}
#[test]
fn derive_resolved_value() {
fn derive_non_local_value() {
let t = trybuild::TestCases::new();
t.pass("tests/derive_resolved_value/pass_*.rs");
t.compile_fail("tests/derive_resolved_value/fail_*.rs");
t.pass("tests/derive_non_local_value/pass_*.rs");
t.compile_fail("tests/derive_non_local_value/fail_*.rs");
}
#[test]
......
......@@ -3,7 +3,7 @@
use turbo_tasks::Vc;
#[turbo_tasks::value(resolved)]
#[turbo_tasks::value(non_local)]
struct MyValue {
value: Vc<i32>,
}
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
--> tests/value/fail_resolved.rs:8:12
error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/value/fail_non_local.rs:8:12
|
8 | value: Vc<i32>,
| ^^^^^^^ the trait `ResolvedValue` is not implemented for `Vc<i32>`
| ^^^^^^^ the trait `NonLocalValue` is not implemented for `Vc<i32>`
|
= help: the following other types implement trait `ResolvedValue`:
= help: the following other types implement trait `NonLocalValue`:
&T
&mut T
()
......@@ -14,9 +14,9 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied
(D, C, B, A, Z, Y, X, W, V, U, T)
(E, D, C, B, A, Z, Y, X, W, V, U, T)
and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
--> tests/value/fail_resolved.rs:6:22
note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/value/fail_non_local.rs:6:22
|
6 | #[turbo_tasks::value(resolved)]
| ^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue`
= note: this error originates in the derive macro `turbo_tasks::ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info)
6 | #[turbo_tasks::value(non_local)]
| ^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `turbo_tasks::NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)]
#[turbo_tasks::value(resolved)]
#[turbo_tasks::value(non_local)]
struct MyValue {
value: i32,
}
fn expects_resolved<T: turbo_tasks::ResolvedValue>(_value: T) {}
fn expects_non_local<T: turbo_tasks::NonLocalValue>(_value: T) {}
fn main() {
let v = MyValue { value: 0 };
expects_resolved(v);
expects_non_local(v);
let _ = v.value;
}
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)]
#[turbo_tasks::value_trait(resolved)]
#[turbo_tasks::value_trait(non_local)]
trait MyTrait {}
fn expects_resolved<T: turbo_tasks::ResolvedValue + ?Sized>() {}
fn expects_non_local<T: turbo_tasks::NonLocalValue + ?Sized>() {}
fn main() {
expects_resolved::<&dyn MyTrait>();
expects_non_local::<&dyn MyTrait>();
}
......@@ -35,7 +35,7 @@ pub fn assert_fields_impl_trait(
quote_spanned! {
// attribute type assertion errors to the line where the field is defined
ty.span() =>
// this call is only valid if ty is a ResolvedValue
// this call is only valid if ty is a NonLocalValue
Self::#assertion_fn_ident::<#ty>();
}
});
......
mod deterministic_hash_macro;
mod key_value_pair_macro;
mod non_local_value_macro;
mod operation_value_macro;
mod resolved_value_macro;
mod shrink_to_fit_macro;
mod task_input_macro;
mod trace_raw_vcs_macro;
......@@ -10,8 +10,8 @@ mod value_debug_macro;
pub use deterministic_hash_macro::derive_deterministic_hash;
pub use key_value_pair_macro::derive_key_value_pair;
pub use non_local_value_macro::derive_non_local_value;
pub use operation_value_macro::derive_operation_value;
pub use resolved_value_macro::derive_resolved_value;
pub use shrink_to_fit_macro::derive_shrink_to_fit;
use syn::{spanned::Spanned, Attribute, Meta, MetaList, NestedMeta};
pub use task_input_macro::derive_task_input;
......
......@@ -4,12 +4,12 @@ use syn::{parse_macro_input, parse_quote, DeriveInput};
use crate::{assert_fields::assert_fields_impl_trait, derive::trace_raw_vcs_macro::filter_field};
pub fn derive_resolved_value(input: TokenStream) -> TokenStream {
pub fn derive_non_local_value(input: TokenStream) -> TokenStream {
let derive_input = parse_macro_input!(input as DeriveInput);
let ident = &derive_input.ident;
let assertions = assert_fields_impl_trait(
&parse_quote!(turbo_tasks::ResolvedValue),
&parse_quote!(turbo_tasks::NonLocalValue),
&derive_input.generics,
&derive_input.data,
filter_field,
......@@ -17,7 +17,7 @@ pub fn derive_resolved_value(input: TokenStream) -> TokenStream {
let (impl_generics, ty_generics, where_clause) = derive_input.generics.split_for_impl();
quote! {
unsafe impl #impl_generics turbo_tasks::ResolvedValue
unsafe impl #impl_generics turbo_tasks::NonLocalValue
for #ident #ty_generics #where_clause {}
#assertions
}
......
......@@ -28,8 +28,8 @@ pub struct TurboFn<'a> {
output: Type,
this: Option<Input>,
inputs: Vec<Input>,
/// Should we check that the return type contains a `ResolvedValue`?
resolved: Option<Span>,
/// Should we check that the return type contains a `NonLocalValue`?
non_local: Option<Span>,
/// Should this function use `TaskPersistence::LocalCells`?
local_cells: bool,
}
......@@ -273,7 +273,7 @@ impl TurboFn<'_> {
output,
this,
inputs,
resolved: args.resolved,
non_local: args.non_local_return,
local_cells: args.local_cells.is_some(),
inline_ident,
})
......@@ -496,12 +496,12 @@ impl TurboFn<'_> {
}
fn get_assertions(&self) -> TokenStream {
if let Some(span) = self.resolved {
if let Some(span) = self.non_local {
let return_type = &self.output;
quote_spanned! {
span =>
{
turbo_tasks::macro_helpers::assert_returns_resolved_value::<#return_type, _>()
turbo_tasks::macro_helpers::assert_returns_non_local_value::<#return_type, _>()
}
}
} else {
......@@ -649,18 +649,18 @@ 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 `ResolvedValue`?
/// 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.
resolved: Option<Span>,
non_local_return: Option<Span>,
/// Changes the behavior of `Vc::cell` to create local cells that are not cached across task
/// 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::resolved`] to the same span.
/// Setting this option will also set [`Self::non_local`] to the same span.
pub local_cells: Option<Span>,
}
......@@ -683,19 +683,19 @@ impl Parse for FunctionArguments {
("network", Meta::Path(_)) => {
parsed_args.io_markers.insert(IoMarker::Network);
}
("resolved", Meta::Path(_)) => {
parsed_args.resolved = Some(meta.span());
("non_local_return", Meta::Path(_)) => {
parsed_args.non_local_return = Some(meta.span());
}
("local_cells", Meta::Path(_)) => {
let span = Some(meta.span());
parsed_args.local_cells = span;
parsed_args.resolved = span;
parsed_args.non_local_return = span;
}
(_, meta) => {
return Err(syn::Error::new_spanned(
meta,
"unexpected token, expected one of: \"fs\", \"network\", \"resolved\", \
\"local_cells\"",
"unexpected token, expected one of: \"fs\", \"network\", \
\"non_local_return\", \"local_cells\"",
))
}
}
......
......@@ -28,9 +28,9 @@ pub fn derive_shrink_to_fit(input: TokenStream) -> TokenStream {
derive::derive_shrink_to_fit(input)
}
#[proc_macro_derive(ResolvedValue, attributes(turbo_tasks))]
pub fn derive_resolved_value_attr(input: TokenStream) -> TokenStream {
derive::derive_resolved_value(input)
#[proc_macro_derive(NonLocalValue, attributes(turbo_tasks))]
pub fn derive_non_local_value_attr(input: TokenStream) -> TokenStream {
derive::derive_non_local_value(input)
}
#[proc_macro_derive(OperationValue, attributes(turbo_tasks))]
......@@ -91,7 +91,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
///
/// ### 'resolved`
///
/// Adds [`turbo_tasks::ResolvedValue`] as a supertrait of this trait.
/// Adds [`turbo_tasks::NonLocalValue`] as a supertrait of this trait.
///
/// Example: `#[turbo_tasks::value_trait(resolved)]`
#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
......
......@@ -110,10 +110,10 @@ struct ValueArguments {
cell_mode: CellMode,
manual_eq: bool,
transparent: bool,
/// Should we `#[derive(turbo_tasks::ResolvedValue)]`?
/// Should we `#[derive(turbo_tasks::NonLocalValue)]`?
///
/// `Some(...)` if enabled, containing the span that enabled the derive.
resolved: Option<Span>,
non_local: Option<Span>,
/// Should we `#[derive(turbo_tasks::OperationValue)]`?
operation: Option<Span>,
}
......@@ -126,7 +126,7 @@ impl Parse for ValueArguments {
cell_mode: CellMode::Shared,
manual_eq: false,
transparent: false,
resolved: None,
non_local: None,
operation: None,
};
let punctuated: Punctuated<Meta, Token![,]> = input.parse_terminated(Meta::parse)?;
......@@ -182,8 +182,8 @@ impl Parse for ValueArguments {
("transparent", Meta::Path(_)) => {
result.transparent = true;
}
("resolved", Meta::Path(path)) => {
result.resolved = Some(path.span());
("non_local", Meta::Path(path)) => {
result.non_local = Some(path.span());
}
("operation", Meta::Path(path)) => {
result.operation = Some(path.span());
......@@ -193,7 +193,7 @@ impl Parse for ValueArguments {
&meta,
format!(
"unexpected {:?}, expected \"shared\", \"into\", \"serialization\", \
\"cell\", \"eq\", \"transparent\", \"resolved\", or \"operation\"",
\"cell\", \"eq\", \"transparent\", \"non_local\", or \"operation\"",
meta
),
))
......@@ -213,7 +213,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
cell_mode,
manual_eq,
transparent,
resolved,
non_local: resolved,
operation,
} = parse_macro_input!(args as ValueArguments);
......@@ -393,7 +393,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
if let Some(span) = resolved {
struct_attributes.push(quote_spanned! {
span =>
#[derive(turbo_tasks::ResolvedValue)]
#[derive(turbo_tasks::NonLocalValue)]
});
}
if let Some(span) = operation {
......
......@@ -14,7 +14,7 @@ use crate::func::{DefinitionContext, FunctionArguments, NativeFn, TurboFn};
pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
let ValueTraitArguments {
debug,
resolved,
non_local,
operation,
} = parse_macro_input!(args as ValueTraitArguments);
......@@ -200,9 +200,9 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
};
let mut extended_supertraits = vec![quote!(::std::marker::Send), quote!(::std::marker::Sync)];
if let Some(span) = resolved {
if let Some(span) = non_local {
extended_supertraits.push(quote_spanned! {
span => turbo_tasks::ResolvedValue
span => turbo_tasks::NonLocalValue
});
}
if let Some(span) = operation {
......
......@@ -4,7 +4,7 @@
use anyhow::Result;
use turbo_tasks::{
debug::ValueDebug, test_helpers::current_task_for_testing, ResolvedValue, ResolvedVc,
debug::ValueDebug, test_helpers::current_task_for_testing, NonLocalValue, ResolvedVc,
ValueDefault, Vc,
};
use turbo_tasks_testing::{register, run, Registration};
......@@ -115,7 +115,7 @@ struct Untracked {
cell: ResolvedVc<u32>,
}
unsafe impl ResolvedValue for Untracked {}
unsafe impl NonLocalValue for Untracked {}
impl PartialEq for Untracked {
fn eq(&self, other: &Self) -> bool {
......
......@@ -121,7 +121,7 @@ pub use turbo_tasks_macros::{function, value_impl, value_trait, KeyValuePair, Ta
pub use value::{TransientInstance, TransientValue, Value};
pub use value_type::{TraitMethod, TraitType, ValueType};
pub use vc::{
Dynamic, OperationValue, OperationVc, ResolvedValue, ResolvedVc, TypedForInput, Upcast,
Dynamic, NonLocalValue, OperationValue, OperationVc, ResolvedVc, TypedForInput, Upcast,
ValueDefault, Vc, VcCast, VcCellNewMode, VcCellSharedMode, VcDefaultRead, VcRead,
VcTransparentRead, VcValueTrait, VcValueTraitCast, VcValueType, VcValueTypeCast,
};
......@@ -259,13 +259,13 @@ macro_rules! fxindexset {
///
/// [repr-transparent]: https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent
///
/// ## `resolved`
/// ## `non_local`
///
/// Applies the [`#[derive(ResolvedValue)]`][macro@ResolvedValue] macro.
/// Applies the [`#[derive(NonLocalValue)]`][macro@NonLocalValue] macro.
///
/// Indicates that this struct has no fields containing [`Vc`] by implementing the [`ResolvedValue`]
/// marker trait. In order to safely implement [`ResolvedValue`], this inserts compile-time
/// assertions that every field in this struct has a type that is also a [`ResolvedValue`].
/// Indicates that this struct has no fields containing [`Vc`] by implementing the [`NonLocalValue`]
/// marker trait. In order to safely implement [`NonLocalValue`], this inserts compile-time
/// assertions that every field in this struct has a type that is also a [`NonLocalValue`].
#[rustfmt::skip]
pub use turbo_tasks_macros::value;
......
......@@ -11,8 +11,8 @@ pub use super::{
manager::{find_cell_by_type, notify_scheduled_tasks, spawn_detached_for_testing},
};
use crate::{
debug::ValueDebugFormatString, shrink_to_fit::ShrinkToFit, task::TaskOutput, RawVc,
ResolvedValue, TaskInput, TaskPersistence, Vc,
debug::ValueDebugFormatString, shrink_to_fit::ShrinkToFit, task::TaskOutput, NonLocalValue,
RawVc, TaskInput, TaskPersistence, Vc,
};
#[inline(never)]
......@@ -45,10 +45,10 @@ pub fn get_non_local_persistence_from_inputs_and_this(
}
}
pub fn assert_returns_resolved_value<ReturnType, Rv>()
pub fn assert_returns_non_local_value<ReturnType, Rv>()
where
ReturnType: TaskOutput<Return = Vc<Rv>>,
Rv: ResolvedValue + Send,
Rv: NonLocalValue + Send,
{
}
......
use crate::{marker_trait::impl_auto_marker_trait, OperationVc, ResolvedVc};
/// Marker trait indicating that a type does not contain any instances of [`Vc`] or references to
/// [`Vc`]. It may contain [`ResolvedVc`] or [`OperationVc`].
///
/// This is referred to as "non-local", as a base [`Vc`] type may contain task-local references that
/// are not valid after the contructing task finishes execution.
///
/// [`Vc`] can be thought of as containing a lifetime (`Vc<'task, T>`), and a [`NonLocalValue`] can
/// be thought of as `'static` or ["owned"][ToOwned]. We don't currently use literal lifetimes for
/// verbosity reasons, but safety is guaranteed through a combination of this trait and runtime
/// assertions.
///
/// A future version of this trait may be implemented using a combination of [`auto_traits`] and
/// [`negative_impls`], but [a derive macro][macro@NonLocalValue] is provided that avoids the need
/// for these nightly-only features.
///
/// # Safety
///
/// This trait is marked as unsafe. You should not derive it yourself, but instead you should rely
/// on [`#[turbo_tasks::value(non_local)]`][macro@crate::value] or [the derive
/// macro][macro@NonLocalValue] to do it for you.
///
/// There are currently runtime assertions in place as a fallback to ensure memory safety, but those
/// assertions may become debug-only in the future if it significantly improves performance.
///
/// [`Vc`]: crate::Vc
/// [`auto_traits`]: https://doc.rust-lang.org/beta/unstable-book/language-features/auto-traits.html
/// [`negative_impls`]: https://doc.rust-lang.org/beta/unstable-book/language-features/negative-impls.html
pub unsafe trait NonLocalValue {}
unsafe impl<T: ?Sized + NonLocalValue> NonLocalValue for OperationVc<T> {}
unsafe impl<T: ?Sized + NonLocalValue> NonLocalValue for ResolvedVc<T> {}
impl_auto_marker_trait!(NonLocalValue);
/// Implements [`NonLocalValue`] for a struct or enum by adding static (compile-time)
/// assertions that every field implements [`NonLocalValue`].
///
/// Fields that do not contain [`Vc`] can be excluded from assertions using [`TraceRawVcs`]'s
/// `#[turbo_tasks(trace_ignore)]` annotation. This can be useful for third-party library types
/// that cannot implement [`NonLocalValue`] due to the orphan rules.
///
/// [`NonLocalValue`]: trait@NonLocalValue
/// [`Vc`]: crate::Vc
/// [`TraceRawVcs`]: crate::trace::TraceRawVcs
pub use turbo_tasks_macros::NonLocalValue;
pub(crate) mod cast;
mod cell_mode;
pub(crate) mod default;
mod local;
pub(crate) mod operation;
mod read;
pub(crate) mod resolved;
......@@ -23,9 +24,10 @@ pub use self::{
cast::{VcCast, VcValueTraitCast, VcValueTypeCast},
cell_mode::{VcCellMode, VcCellNewMode, VcCellSharedMode},
default::ValueDefault,
local::NonLocalValue,
operation::{OperationValue, OperationVc},
read::{ReadVcFuture, VcDefaultRead, VcRead, VcTransparentRead},
resolved::{ResolvedValue, ResolvedVc},
resolved::ResolvedVc,
traits::{Dynamic, TypedForInput, Upcast, VcValueTrait, VcValueType},
};
use crate::{
......
......@@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
use crate::{
debug::{ValueDebug, ValueDebugFormat, ValueDebugFormatString},
marker_trait::impl_auto_marker_trait,
trace::{TraceRawVcs, TraceRawVcsContext},
vc::Vc,
ResolveTypeError, Upcast, VcRead, VcTransparentRead, VcValueTrait, VcValueType,
......@@ -240,18 +239,3 @@ where
self.node.value_debug_format(depth)
}
}
/// Indicates that a type does not contain any instances of [`Vc`] or
/// [`OperationVc`][crate::OperationVc]. It may contain [`ResolvedVc`].
///
/// # Safety
///
/// This trait is marked as unsafe. You should not derive it yourself, but instead you should rely
/// on [`#[turbo_tasks::value(resolved)]`][macro@ crate::value] to do it for you.
pub unsafe trait ResolvedValue {}
unsafe impl<T: ?Sized + ResolvedValue> ResolvedValue for ResolvedVc<T> {}
impl_auto_marker_trait!(ResolvedValue);
pub use turbo_tasks_macros::ResolvedValue;
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