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 { ...@@ -12,10 +12,10 @@ pub struct ValueTraitArguments {
/// Whether the macro should generate a `ValueDebug`-like `dbg()` /// Whether the macro should generate a `ValueDebug`-like `dbg()`
/// implementation on the trait's `Vc`. /// implementation on the trait's `Vc`.
pub debug: bool, 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. /// `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? /// Should the trait have a `turbo_tasks::OperationValue` constraint?
pub operation: Option<Span>, pub operation: Option<Span>,
} }
...@@ -24,7 +24,7 @@ impl Default for ValueTraitArguments { ...@@ -24,7 +24,7 @@ impl Default for ValueTraitArguments {
fn default() -> Self { fn default() -> Self {
Self { Self {
debug: true, debug: true,
resolved: None, non_local: None,
operation: None, operation: None,
} }
} }
...@@ -43,8 +43,8 @@ impl Parse for ValueTraitArguments { ...@@ -43,8 +43,8 @@ impl Parse for ValueTraitArguments {
Some("no_debug") => { Some("no_debug") => {
result.debug = false; result.debug = false;
} }
Some("resolved") => { Some("non_local") => {
result.resolved = Some(meta.span()); result.non_local = Some(meta.span());
} }
Some("operation") => { Some("operation") => {
result.operation = Some(meta.span()); result.operation = Some(meta.span());
......
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::{ResolvedValue, Vc}; use turbo_tasks::{NonLocalValue, Vc};
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsOnlyVc { struct ContainsOnlyVc {
a: Vc<i32>, a: Vc<i32>,
} }
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/derive_resolved_value/fail_contains_only_vc.rs:7:8 --> tests/derive_non_local_value/fail_contains_only_vc.rs:7:8
| |
7 | a: Vc<i32>, 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 &T
&mut T &mut T
() ()
...@@ -14,9 +14,9 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_resolved_value/fail_contains_only_vc.rs:5:10 --> tests/derive_non_local_value/fail_contains_only_vc.rs:5:10
| |
5 | #[derive(ResolvedValue)] 5 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::{ResolvedValue, ResolvedVc, Vc}; use turbo_tasks::{NonLocalValue, ResolvedVc, Vc};
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsResolvedVcAndVc { struct ContainsResolvedVcAndVc {
a: ResolvedVc<i32>, a: ResolvedVc<i32>,
b: Vc<i32>, b: Vc<i32>,
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/derive_resolved_value/fail_contains_resolved_vc_and_vc.rs:8:8 --> tests/derive_non_local_value/fail_contains_resolved_vc_and_vc.rs:8:8
| |
8 | b: Vc<i32>, 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 &T
&mut T &mut T
() ()
...@@ -14,9 +14,9 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_resolved_value/fail_contains_resolved_vc_and_vc.rs:5:10 --> tests/derive_non_local_value/fail_contains_resolved_vc_and_vc.rs:5:10
| |
5 | #[derive(ResolvedValue)] 5 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::{ResolvedValue, Vc}; use turbo_tasks::{NonLocalValue, Vc};
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsVcInsideGeneric { struct ContainsVcInsideGeneric {
a: Option<Box<[Vc<i32>; 4]>>, a: Option<Box<[Vc<i32>; 4]>>,
} }
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/derive_resolved_value/fail_contains_vc_inside_generic.rs:7:8 --> tests/derive_non_local_value/fail_contains_vc_inside_generic.rs:7:8
| |
7 | a: Option<Box<[Vc<i32>; 4]>>, 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 &T
&mut T &mut T
() ()
...@@ -14,12 +14,12 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 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: 2 redundant requirements hidden
= note: required for `std::option::Option<Box<[Vc<i32>; 4]>>` to implement `ResolvedValue` = note: required for `std::option::Option<Box<[Vc<i32>; 4]>>` to implement `NonLocalValue`
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_resolved_value/fail_contains_vc_inside_generic.rs:5:10 --> tests/derive_non_local_value/fail_contains_vc_inside_generic.rs:5:10
| |
5 | #[derive(ResolvedValue)] 5 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
struct UnresolvedValue; struct UnresolvedValue;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
enum ContainsUnresolvedValue { enum ContainsUnresolvedValue {
Unit, Unit,
Unnamed(UnresolvedValue), Unnamed(UnresolvedValue),
......
error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_enum.rs:10:13 --> tests/derive_non_local_value/fail_simple_enum.rs:10:13
| |
10 | Unnamed(UnresolvedValue), 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 &T
&mut T &mut T
() ()
...@@ -14,20 +14,20 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_resolved_value/fail_simple_enum.rs:7:10 --> tests/derive_non_local_value/fail_simple_enum.rs:7:10
| |
7 | #[derive(ResolvedValue)] 7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = 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 error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_enum.rs:11:16 --> tests/derive_non_local_value/fail_simple_enum.rs:11:16
| |
11 | Named { a: UnresolvedValue }, 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 &T
&mut T &mut T
() ()
...@@ -37,9 +37,9 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_resolved_value/fail_simple_enum.rs:7:10 --> tests/derive_non_local_value/fail_simple_enum.rs:7:10
| |
7 | #[derive(ResolvedValue)] 7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
struct UnresolvedValue; struct UnresolvedValue;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsUnresolvedValueNamed { struct ContainsUnresolvedValueNamed {
a: UnresolvedValue, a: UnresolvedValue,
} }
......
error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_named_struct.rs:9:8 --> tests/derive_non_local_value/fail_simple_named_struct.rs:9:8
| |
9 | a: UnresolvedValue, 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 &T
&mut T &mut T
() ()
...@@ -14,9 +14,9 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_resolved_value/fail_simple_named_struct.rs:7:10 --> tests/derive_non_local_value/fail_simple_named_struct.rs:7:10
| |
7 | #[derive(ResolvedValue)] 7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
struct UnresolvedValue; struct UnresolvedValue;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsUnresolvedValueUnnamed(UnresolvedValue); struct ContainsUnresolvedValueUnnamed(UnresolvedValue);
fn main() {} fn main() {}
error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied error[E0277]: the trait bound `UnresolvedValue: NonLocalValue` is not satisfied
--> tests/derive_resolved_value/fail_simple_unnamed_struct.rs:8:39 --> tests/derive_non_local_value/fail_simple_unnamed_struct.rs:8:39
| |
8 | struct ContainsUnresolvedValueUnnamed(UnresolvedValue); 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 &T
&mut T &mut T
() ()
...@@ -14,9 +14,9 @@ error[E0277]: the trait bound `UnresolvedValue: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/derive_resolved_value/fail_simple_unnamed_struct.rs:7:10 --> tests/derive_non_local_value/fail_simple_unnamed_struct.rs:7:10
| |
7 | #[derive(ResolvedValue)] 7 | #[derive(NonLocalValue)]
| ^^^^^^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `NonLocalValue` (in Nightly builds, run with -Z macro-backtrace for more info)
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsUnderconstrainedGeneric<T> { struct ContainsUnderconstrainedGeneric<T> {
value: 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)] #![allow(dead_code)]
use turbo_tasks::{ResolvedValue, ResolvedVc}; use turbo_tasks::{NonLocalValue, ResolvedVc};
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsResolvedVcNamedStruct { struct ContainsResolvedVcNamedStruct {
a: ResolvedVc<i32>, a: ResolvedVc<i32>,
} }
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsResolvedVcUnnamedStruct(ResolvedVc<i32>); struct ContainsResolvedVcUnnamedStruct(ResolvedVc<i32>);
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
enum ContainsResolvedVcEnum { enum ContainsResolvedVcEnum {
Unit, Unit,
Unnamed(ResolvedVc<i32>), Unnamed(ResolvedVc<i32>),
Named { a: ResolvedVc<i32> }, Named { a: ResolvedVc<i32> },
} }
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsResolvedAlongWithOtherValues { struct ContainsResolvedAlongWithOtherValues {
a: i32, a: i32,
b: ResolvedVc<i32>, b: ResolvedVc<i32>,
......
use std::marker::PhantomData; use std::marker::PhantomData;
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
struct UnannotatedValue<T>(PhantomData<T>); struct UnannotatedValue<T>(PhantomData<T>);
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsIgnore<T> { struct ContainsIgnore<T> {
#[turbo_tasks(trace_ignore)] #[turbo_tasks(trace_ignore)]
a: UnannotatedValue<T>, a: UnannotatedValue<T>,
......
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsBorrowedData<'a> { struct ContainsBorrowedData<'a> {
borrowed: &'a Option<&'a [&'a str]>, borrowed: &'a Option<&'a [&'a str]>,
} }
......
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
// use an inline type constraint here // use an inline type constraint here
struct LinkedList<T: ResolvedValue> { struct LinkedList<T: NonLocalValue> {
// LinkedListNode is also a ResolvedValue // LinkedListNode is also a NonLocalValue
head: Option<Box<LinkedListNode<T>>>, head: Option<Box<LinkedListNode<T>>>,
} }
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct LinkedListNode<T> struct LinkedListNode<T>
where where
T: ResolvedValue, // use a where type constraint here T: NonLocalValue, // use a where type constraint here
{ {
current: T, current: T,
// A self-recursive type // A self-recursive type
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use turbo_tasks::{ResolvedValue, Vc}; use turbo_tasks::{NonLocalValue, Vc};
struct Unresolved; struct Unresolved;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct PhantomDataCanContainAnything<T: Send>( struct PhantomDataCanContainAnything<T: Send>(
PhantomData<Vc<T>>, PhantomData<Vc<T>>,
PhantomData<Unresolved>, PhantomData<Unresolved>,
......
#![allow(dead_code)] #![allow(dead_code)]
use turbo_tasks::{ResolvedValue, ResolvedVc}; use turbo_tasks::{NonLocalValue, ResolvedVc};
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
enum EnumI32 { enum EnumI32 {
Unit, Unit,
Unnamed(i32), Unnamed(i32),
Named { a: i32 }, Named { a: i32 },
} }
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
enum EnumResolvedVc { enum EnumResolvedVc {
Unit, Unit,
Unnamed(ResolvedVc<i32>), Unnamed(ResolvedVc<i32>),
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use turbo_tasks::ResolvedValue; use turbo_tasks::NonLocalValue;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct UnitStruct; struct UnitStruct;
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsSimpleValuesNamed { struct ContainsSimpleValuesNamed {
a: i32, a: i32,
b: String, b: String,
...@@ -17,7 +17,7 @@ struct ContainsSimpleValuesNamed { ...@@ -17,7 +17,7 @@ struct ContainsSimpleValuesNamed {
f: PhantomData<u8>, f: PhantomData<u8>,
} }
#[derive(ResolvedValue)] #[derive(NonLocalValue)]
struct ContainsSimpleValuesUnnamed(i32, String, ()); struct ContainsSimpleValuesUnnamed(i32, String, ());
fn main() {} 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 @@ ...@@ -3,7 +3,7 @@
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value(transparent, resolved)] #[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>); struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::function(invalid_argument)] #[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 --> tests/function/fail_attribute_invalid_args.rs:9:25
| |
9 | #[turbo_tasks::function(invalid_argument)] 9 | #[turbo_tasks::function(invalid_argument)]
......
...@@ -6,7 +6,7 @@ use turbo_tasks::{ResolvedVc, Vc}; ...@@ -6,7 +6,7 @@ use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value] #[turbo_tasks::value]
struct ExampleStruct; struct ExampleStruct;
#[turbo_tasks::value(transparent, resolved)] #[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>); struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_impl] #[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 --> tests/function/fail_attribute_invalid_args_inherent_impl.rs:14:29
| |
14 | #[turbo_tasks::function(invalid_argument)] 14 | #[turbo_tasks::function(invalid_argument)]
......
...@@ -12,7 +12,7 @@ struct IntegersVec(Vec<Vc<u32>>); ...@@ -12,7 +12,7 @@ struct IntegersVec(Vec<Vc<u32>>);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ExampleStruct { impl ExampleStruct {
#[turbo_tasks::function(resolved)] #[turbo_tasks::function(non_local_return)]
fn return_contains_unresolved_vc(self: Vc<Self>) -> Vc<IntegersVec> { fn return_contains_unresolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new()) Vc::cell(Vec::new())
} }
......
error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied error[E0277]: the trait bound `IntegersVec: NonLocalValue` is not satisfied
--> tests/function/fail_resolved_trait_impl.rs:20:29 --> tests/function/fail_non_local_inherent_impl.rs:15:29
| |
20 | #[turbo_tasks::function(resolved)] 15 | #[turbo_tasks::function(non_local_return)]
| ^^^^^^^^ the trait `ResolvedValue` is not implemented for `IntegersVec` | ^^^^^^^^^^^^^^^^ 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 &T
&mut T &mut T
() ()
...@@ -14,11 +14,11 @@ error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 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 --> $WORKSPACE/turbopack/crates/turbo-tasks/src/macro_helpers.rs
| |
| pub fn assert_returns_resolved_value<ReturnType, Rv>() | pub fn assert_returns_non_local_value<ReturnType, Rv>()
| ----------------------------- required by a bound in this function | ------------------------------ required by a bound in this function
... ...
| Rv: ResolvedValue + Send, | Rv: NonLocalValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_resolved_value` | ^^^^^^^^^^^^^ required by this bound in `assert_returns_non_local_value`
...@@ -7,7 +7,7 @@ use turbo_tasks::Vc; ...@@ -7,7 +7,7 @@ use turbo_tasks::Vc;
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
struct IntegersVec(Vec<Vc<u32>>); struct IntegersVec(Vec<Vc<u32>>);
#[turbo_tasks::function(resolved)] #[turbo_tasks::function(non_local_return)]
fn return_contains_unresolved_vc() -> Vc<IntegersVec> { fn return_contains_unresolved_vc() -> Vc<IntegersVec> {
Vc::cell(Vec::new()) Vc::cell(Vec::new())
} }
......
error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied error[E0277]: the trait bound `IntegersVec: NonLocalValue` is not satisfied
--> tests/function/fail_resolved_inherent_impl.rs:15:29 --> tests/function/fail_non_local_static.rs:10:25
| |
15 | #[turbo_tasks::function(resolved)] 10 | #[turbo_tasks::function(non_local_return)]
| ^^^^^^^^ the trait `ResolvedValue` is not implemented for `IntegersVec` | ^^^^^^^^^^^^^^^^ 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 &T
&mut T &mut T
() ()
...@@ -14,11 +14,11 @@ error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 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 --> $WORKSPACE/turbopack/crates/turbo-tasks/src/macro_helpers.rs
| |
| pub fn assert_returns_resolved_value<ReturnType, Rv>() | pub fn assert_returns_non_local_value<ReturnType, Rv>()
| ----------------------------- required by a bound in this function | ------------------------------ required by a bound in this function
... ...
| Rv: ResolvedValue + Send, | Rv: NonLocalValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_resolved_value` | ^^^^^^^^^^^^^ required by this bound in `assert_returns_non_local_value`
...@@ -17,7 +17,7 @@ trait ExampleTrait { ...@@ -17,7 +17,7 @@ trait ExampleTrait {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ExampleTrait for ExampleStruct { impl ExampleTrait for ExampleStruct {
#[turbo_tasks::function(resolved)] #[turbo_tasks::function(non_local_return)]
fn return_contains_unresolved_vc(self: Vc<Self>) -> Vc<IntegersVec> { fn return_contains_unresolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new()) Vc::cell(Vec::new())
} }
......
error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied error[E0277]: the trait bound `IntegersVec: NonLocalValue` is not satisfied
--> tests/function/fail_resolved_static.rs:10:25 --> tests/function/fail_non_local_trait_impl.rs:20:29
| |
10 | #[turbo_tasks::function(resolved)] 20 | #[turbo_tasks::function(non_local_return)]
| ^^^^^^^^ the trait `ResolvedValue` is not implemented for `IntegersVec` | ^^^^^^^^^^^^^^^^ 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 &T
&mut T &mut T
() ()
...@@ -14,11 +14,11 @@ error[E0277]: the trait bound `IntegersVec: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 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 --> $WORKSPACE/turbopack/crates/turbo-tasks/src/macro_helpers.rs
| |
| pub fn assert_returns_resolved_value<ReturnType, Rv>() | pub fn assert_returns_non_local_value<ReturnType, Rv>()
| ----------------------------- required by a bound in this function | ------------------------------ required by a bound in this function
... ...
| Rv: ResolvedValue + Send, | Rv: NonLocalValue + Send,
| ^^^^^^^^^^^^^ required by this bound in `assert_returns_resolved_value` | ^^^^^^^^^^^^^ required by this bound in `assert_returns_non_local_value`
...@@ -7,12 +7,12 @@ use turbo_tasks::{ResolvedVc, Vc}; ...@@ -7,12 +7,12 @@ use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value] #[turbo_tasks::value]
struct ExampleStruct; struct ExampleStruct;
#[turbo_tasks::value(transparent, resolved)] #[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>); struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ExampleStruct { impl ExampleStruct {
#[turbo_tasks::function(resolved)] #[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> { fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new()) Vc::cell(Vec::new())
} }
......
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value(transparent, resolved)] #[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>); struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::function(resolved)] #[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc() -> Vc<IntegersVec> { fn return_contains_resolved_vc() -> Vc<IntegersVec> {
Vc::cell(Vec::new()) Vc::cell(Vec::new())
} }
#[turbo_tasks::function(resolved)] #[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc_result() -> anyhow::Result<Vc<IntegersVec>> { fn return_contains_resolved_vc_result() -> anyhow::Result<Vc<IntegersVec>> {
Ok(Vc::cell(Vec::new())) Ok(Vc::cell(Vec::new()))
} }
......
...@@ -7,7 +7,7 @@ use turbo_tasks::{ResolvedVc, Vc}; ...@@ -7,7 +7,7 @@ use turbo_tasks::{ResolvedVc, Vc};
#[turbo_tasks::value] #[turbo_tasks::value]
struct ExampleStruct; struct ExampleStruct;
#[turbo_tasks::value(transparent, resolved)] #[turbo_tasks::value(transparent, non_local)]
struct IntegersVec(Vec<ResolvedVc<u32>>); struct IntegersVec(Vec<ResolvedVc<u32>>);
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
...@@ -17,7 +17,7 @@ trait ExampleTrait { ...@@ -17,7 +17,7 @@ trait ExampleTrait {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ExampleTrait for ExampleStruct { impl ExampleTrait for ExampleStruct {
#[turbo_tasks::function(resolved)] #[turbo_tasks::function(non_local_return)]
fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> { fn return_contains_resolved_vc(self: Vc<Self>) -> Vc<IntegersVec> {
Vc::cell(Vec::new()) Vc::cell(Vec::new())
} }
......
...@@ -6,7 +6,7 @@ use anyhow::Result; ...@@ -6,7 +6,7 @@ use anyhow::Result;
use turbo_tasks::{ResolvedVc, Vc}; use turbo_tasks::{ResolvedVc, Vc};
#[derive(Clone)] #[derive(Clone)]
#[turbo_tasks::value(resolved)] #[turbo_tasks::value(non_local)]
struct ExampleStruct { struct ExampleStruct {
items: Vec<ResolvedVc<u32>>, items: Vec<ResolvedVc<u32>>,
} }
...@@ -41,7 +41,7 @@ impl ExampleStruct { ...@@ -41,7 +41,7 @@ impl ExampleStruct {
fn non_turbo_method_with_resolved_vc_self(self: ResolvedVc<Self>) {} 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>); struct MaybeExampleStruct(Option<ExampleStruct>);
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -6,10 +6,10 @@ fn derive_operation_value() { ...@@ -6,10 +6,10 @@ fn derive_operation_value() {
} }
#[test] #[test]
fn derive_resolved_value() { fn derive_non_local_value() {
let t = trybuild::TestCases::new(); let t = trybuild::TestCases::new();
t.pass("tests/derive_resolved_value/pass_*.rs"); t.pass("tests/derive_non_local_value/pass_*.rs");
t.compile_fail("tests/derive_resolved_value/fail_*.rs"); t.compile_fail("tests/derive_non_local_value/fail_*.rs");
} }
#[test] #[test]
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
use turbo_tasks::Vc; use turbo_tasks::Vc;
#[turbo_tasks::value(resolved)] #[turbo_tasks::value(non_local)]
struct MyValue { struct MyValue {
value: Vc<i32>, value: Vc<i32>,
} }
......
error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied error[E0277]: the trait bound `Vc<i32>: NonLocalValue` is not satisfied
--> tests/value/fail_resolved.rs:8:12 --> tests/value/fail_non_local.rs:8:12
| |
8 | value: Vc<i32>, 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 &T
&mut T &mut T
() ()
...@@ -14,9 +14,9 @@ error[E0277]: the trait bound `Vc<i32>: ResolvedValue` is not satisfied ...@@ -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) (D, C, B, A, Z, Y, X, W, V, U, T)
(E, 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 and $N others
note: required by a bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` note: required by a bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
--> tests/value/fail_resolved.rs:6:22 --> tests/value/fail_non_local.rs:6:22
| |
6 | #[turbo_tasks::value(resolved)] 6 | #[turbo_tasks::value(non_local)]
| ^^^^^^^^ required by this bound in `DeriveResolvedValueAssertion::assert_impl_ResolvedValue` | ^^^^^^^^^ required by this bound in `DeriveNonLocalValueAssertion::assert_impl_NonLocalValue`
= note: this error originates in the derive macro `turbo_tasks::ResolvedValue` (in Nightly builds, run with -Z macro-backtrace for more info) = 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)]
#![feature(arbitrary_self_types_pointers)] #![feature(arbitrary_self_types_pointers)]
#[turbo_tasks::value(resolved)] #[turbo_tasks::value(non_local)]
struct MyValue { struct MyValue {
value: i32, value: i32,
} }
fn expects_resolved<T: turbo_tasks::ResolvedValue>(_value: T) {} fn expects_non_local<T: turbo_tasks::NonLocalValue>(_value: T) {}
fn main() { fn main() {
let v = MyValue { value: 0 }; let v = MyValue { value: 0 };
expects_resolved(v); expects_non_local(v);
let _ = v.value; let _ = v.value;
} }
#![feature(arbitrary_self_types)] #![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)] #![feature(arbitrary_self_types_pointers)]
#[turbo_tasks::value_trait(resolved)] #[turbo_tasks::value_trait(non_local)]
trait MyTrait {} trait MyTrait {}
fn expects_resolved<T: turbo_tasks::ResolvedValue + ?Sized>() {} fn expects_non_local<T: turbo_tasks::NonLocalValue + ?Sized>() {}
fn main() { fn main() {
expects_resolved::<&dyn MyTrait>(); expects_non_local::<&dyn MyTrait>();
} }
...@@ -35,7 +35,7 @@ pub fn assert_fields_impl_trait( ...@@ -35,7 +35,7 @@ pub fn assert_fields_impl_trait(
quote_spanned! { quote_spanned! {
// attribute type assertion errors to the line where the field is defined // attribute type assertion errors to the line where the field is defined
ty.span() => 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>(); Self::#assertion_fn_ident::<#ty>();
} }
}); });
......
mod deterministic_hash_macro; mod deterministic_hash_macro;
mod key_value_pair_macro; mod key_value_pair_macro;
mod non_local_value_macro;
mod operation_value_macro; mod operation_value_macro;
mod resolved_value_macro;
mod shrink_to_fit_macro; mod shrink_to_fit_macro;
mod task_input_macro; mod task_input_macro;
mod trace_raw_vcs_macro; mod trace_raw_vcs_macro;
...@@ -10,8 +10,8 @@ mod value_debug_macro; ...@@ -10,8 +10,8 @@ mod value_debug_macro;
pub use deterministic_hash_macro::derive_deterministic_hash; pub use deterministic_hash_macro::derive_deterministic_hash;
pub use key_value_pair_macro::derive_key_value_pair; 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 operation_value_macro::derive_operation_value;
pub use resolved_value_macro::derive_resolved_value;
pub use shrink_to_fit_macro::derive_shrink_to_fit; pub use shrink_to_fit_macro::derive_shrink_to_fit;
use syn::{spanned::Spanned, Attribute, Meta, MetaList, NestedMeta}; use syn::{spanned::Spanned, Attribute, Meta, MetaList, NestedMeta};
pub use task_input_macro::derive_task_input; pub use task_input_macro::derive_task_input;
......
...@@ -4,12 +4,12 @@ use syn::{parse_macro_input, parse_quote, DeriveInput}; ...@@ -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}; 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 derive_input = parse_macro_input!(input as DeriveInput);
let ident = &derive_input.ident; let ident = &derive_input.ident;
let assertions = assert_fields_impl_trait( let assertions = assert_fields_impl_trait(
&parse_quote!(turbo_tasks::ResolvedValue), &parse_quote!(turbo_tasks::NonLocalValue),
&derive_input.generics, &derive_input.generics,
&derive_input.data, &derive_input.data,
filter_field, filter_field,
...@@ -17,7 +17,7 @@ pub fn derive_resolved_value(input: TokenStream) -> TokenStream { ...@@ -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(); let (impl_generics, ty_generics, where_clause) = derive_input.generics.split_for_impl();
quote! { quote! {
unsafe impl #impl_generics turbo_tasks::ResolvedValue unsafe impl #impl_generics turbo_tasks::NonLocalValue
for #ident #ty_generics #where_clause {} for #ident #ty_generics #where_clause {}
#assertions #assertions
} }
......
...@@ -28,8 +28,8 @@ pub struct TurboFn<'a> { ...@@ -28,8 +28,8 @@ 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 `ResolvedValue`? /// Should we check that the return type contains a `NonLocalValue`?
resolved: Option<Span>, non_local: Option<Span>,
/// Should this function use `TaskPersistence::LocalCells`? /// Should this function use `TaskPersistence::LocalCells`?
local_cells: bool, local_cells: bool,
} }
...@@ -273,7 +273,7 @@ impl TurboFn<'_> { ...@@ -273,7 +273,7 @@ impl TurboFn<'_> {
output, output,
this, this,
inputs, inputs,
resolved: args.resolved, non_local: args.non_local_return,
local_cells: args.local_cells.is_some(), local_cells: args.local_cells.is_some(),
inline_ident, inline_ident,
}) })
...@@ -496,12 +496,12 @@ impl TurboFn<'_> { ...@@ -496,12 +496,12 @@ impl TurboFn<'_> {
} }
fn get_assertions(&self) -> TokenStream { fn get_assertions(&self) -> TokenStream {
if let Some(span) = self.resolved { if let Some(span) = self.non_local {
let return_type = &self.output; let return_type = &self.output;
quote_spanned! { quote_spanned! {
span => span =>
{ {
turbo_tasks::macro_helpers::assert_returns_resolved_value::<#return_type, _>() turbo_tasks::macro_helpers::assert_returns_non_local_value::<#return_type, _>()
} }
} }
} else { } else {
...@@ -649,18 +649,18 @@ pub struct FunctionArguments { ...@@ -649,18 +649,18 @@ 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 `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 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. /// 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 /// 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`. /// 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::resolved`] to the same span. /// Setting this option will also set [`Self::non_local`] to the same span.
pub local_cells: Option<Span>, pub local_cells: Option<Span>,
} }
...@@ -683,19 +683,19 @@ impl Parse for FunctionArguments { ...@@ -683,19 +683,19 @@ impl Parse for FunctionArguments {
("network", Meta::Path(_)) => { ("network", Meta::Path(_)) => {
parsed_args.io_markers.insert(IoMarker::Network); parsed_args.io_markers.insert(IoMarker::Network);
} }
("resolved", Meta::Path(_)) => { ("non_local_return", Meta::Path(_)) => {
parsed_args.resolved = Some(meta.span()); parsed_args.non_local_return = 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.resolved = 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\", \"resolved\", \ "unexpected token, expected one of: \"fs\", \"network\", \
\"local_cells\"", \"non_local_return\", \"local_cells\"",
)) ))
} }
} }
......
...@@ -28,9 +28,9 @@ pub fn derive_shrink_to_fit(input: TokenStream) -> TokenStream { ...@@ -28,9 +28,9 @@ pub fn derive_shrink_to_fit(input: TokenStream) -> TokenStream {
derive::derive_shrink_to_fit(input) derive::derive_shrink_to_fit(input)
} }
#[proc_macro_derive(ResolvedValue, attributes(turbo_tasks))] #[proc_macro_derive(NonLocalValue, attributes(turbo_tasks))]
pub fn derive_resolved_value_attr(input: TokenStream) -> TokenStream { pub fn derive_non_local_value_attr(input: TokenStream) -> TokenStream {
derive::derive_resolved_value(input) derive::derive_non_local_value(input)
} }
#[proc_macro_derive(OperationValue, attributes(turbo_tasks))] #[proc_macro_derive(OperationValue, attributes(turbo_tasks))]
...@@ -91,7 +91,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -91,7 +91,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
/// ///
/// ### 'resolved` /// ### '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)]` /// Example: `#[turbo_tasks::value_trait(resolved)]`
#[allow_internal_unstable(min_specialization, into_future, trivial_bounds)] #[allow_internal_unstable(min_specialization, into_future, trivial_bounds)]
......
...@@ -110,10 +110,10 @@ struct ValueArguments { ...@@ -110,10 +110,10 @@ struct ValueArguments {
cell_mode: CellMode, cell_mode: CellMode,
manual_eq: bool, manual_eq: bool,
transparent: 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. /// `Some(...)` if enabled, containing the span that enabled the derive.
resolved: Option<Span>, non_local: Option<Span>,
/// Should we `#[derive(turbo_tasks::OperationValue)]`? /// Should we `#[derive(turbo_tasks::OperationValue)]`?
operation: Option<Span>, operation: Option<Span>,
} }
...@@ -126,7 +126,7 @@ impl Parse for ValueArguments { ...@@ -126,7 +126,7 @@ impl Parse for ValueArguments {
cell_mode: CellMode::Shared, cell_mode: CellMode::Shared,
manual_eq: false, manual_eq: false,
transparent: false, transparent: false,
resolved: None, non_local: None,
operation: None, operation: None,
}; };
let punctuated: Punctuated<Meta, Token![,]> = input.parse_terminated(Meta::parse)?; let punctuated: Punctuated<Meta, Token![,]> = input.parse_terminated(Meta::parse)?;
...@@ -182,8 +182,8 @@ impl Parse for ValueArguments { ...@@ -182,8 +182,8 @@ impl Parse for ValueArguments {
("transparent", Meta::Path(_)) => { ("transparent", Meta::Path(_)) => {
result.transparent = true; result.transparent = true;
} }
("resolved", Meta::Path(path)) => { ("non_local", Meta::Path(path)) => {
result.resolved = Some(path.span()); result.non_local = Some(path.span());
} }
("operation", Meta::Path(path)) => { ("operation", Meta::Path(path)) => {
result.operation = Some(path.span()); result.operation = Some(path.span());
...@@ -193,7 +193,7 @@ impl Parse for ValueArguments { ...@@ -193,7 +193,7 @@ impl Parse for ValueArguments {
&meta, &meta,
format!( format!(
"unexpected {:?}, expected \"shared\", \"into\", \"serialization\", \ "unexpected {:?}, expected \"shared\", \"into\", \"serialization\", \
\"cell\", \"eq\", \"transparent\", \"resolved\", or \"operation\"", \"cell\", \"eq\", \"transparent\", \"non_local\", or \"operation\"",
meta meta
), ),
)) ))
...@@ -213,7 +213,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -213,7 +213,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
cell_mode, cell_mode,
manual_eq, manual_eq,
transparent, transparent,
resolved, non_local: resolved,
operation, operation,
} = parse_macro_input!(args as ValueArguments); } = parse_macro_input!(args as ValueArguments);
...@@ -393,7 +393,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -393,7 +393,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
if let Some(span) = resolved { if let Some(span) = resolved {
struct_attributes.push(quote_spanned! { struct_attributes.push(quote_spanned! {
span => span =>
#[derive(turbo_tasks::ResolvedValue)] #[derive(turbo_tasks::NonLocalValue)]
}); });
} }
if let Some(span) = operation { if let Some(span) = operation {
......
...@@ -14,7 +14,7 @@ use crate::func::{DefinitionContext, FunctionArguments, NativeFn, TurboFn}; ...@@ -14,7 +14,7 @@ use crate::func::{DefinitionContext, FunctionArguments, NativeFn, TurboFn};
pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
let ValueTraitArguments { let ValueTraitArguments {
debug, debug,
resolved, non_local,
operation, operation,
} = parse_macro_input!(args as ValueTraitArguments); } = parse_macro_input!(args as ValueTraitArguments);
...@@ -200,9 +200,9 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -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)]; 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! { extended_supertraits.push(quote_spanned! {
span => turbo_tasks::ResolvedValue span => turbo_tasks::NonLocalValue
}); });
} }
if let Some(span) = operation { if let Some(span) = operation {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{ 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, ValueDefault, Vc,
}; };
use turbo_tasks_testing::{register, run, Registration}; use turbo_tasks_testing::{register, run, Registration};
...@@ -115,7 +115,7 @@ struct Untracked { ...@@ -115,7 +115,7 @@ struct Untracked {
cell: ResolvedVc<u32>, cell: ResolvedVc<u32>,
} }
unsafe impl ResolvedValue for Untracked {} unsafe impl NonLocalValue for Untracked {}
impl PartialEq for Untracked { impl PartialEq for Untracked {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
......
...@@ -121,7 +121,7 @@ pub use turbo_tasks_macros::{function, value_impl, value_trait, KeyValuePair, Ta ...@@ -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::{TransientInstance, TransientValue, Value};
pub use value_type::{TraitMethod, TraitType, ValueType}; pub use value_type::{TraitMethod, TraitType, ValueType};
pub use vc::{ pub use vc::{
Dynamic, OperationValue, OperationVc, ResolvedValue, ResolvedVc, TypedForInput, Upcast, Dynamic, NonLocalValue, OperationValue, OperationVc, ResolvedVc, TypedForInput, Upcast,
ValueDefault, Vc, VcCast, VcCellNewMode, VcCellSharedMode, VcDefaultRead, VcRead, ValueDefault, Vc, VcCast, VcCellNewMode, VcCellSharedMode, VcDefaultRead, VcRead,
VcTransparentRead, VcValueTrait, VcValueTraitCast, VcValueType, VcValueTypeCast, VcTransparentRead, VcValueTrait, VcValueTraitCast, VcValueType, VcValueTypeCast,
}; };
...@@ -259,13 +259,13 @@ macro_rules! fxindexset { ...@@ -259,13 +259,13 @@ macro_rules! fxindexset {
/// ///
/// [repr-transparent]: https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent /// [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`] /// Indicates that this struct has no fields containing [`Vc`] by implementing the [`NonLocalValue`]
/// marker trait. In order to safely implement [`ResolvedValue`], this inserts compile-time /// 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 [`ResolvedValue`]. /// assertions that every field in this struct has a type that is also a [`NonLocalValue`].
#[rustfmt::skip] #[rustfmt::skip]
pub use turbo_tasks_macros::value; pub use turbo_tasks_macros::value;
......
...@@ -11,8 +11,8 @@ pub use super::{ ...@@ -11,8 +11,8 @@ pub use super::{
manager::{find_cell_by_type, notify_scheduled_tasks, spawn_detached_for_testing}, manager::{find_cell_by_type, notify_scheduled_tasks, spawn_detached_for_testing},
}; };
use crate::{ use crate::{
debug::ValueDebugFormatString, shrink_to_fit::ShrinkToFit, task::TaskOutput, RawVc, debug::ValueDebugFormatString, shrink_to_fit::ShrinkToFit, task::TaskOutput, NonLocalValue,
ResolvedValue, TaskInput, TaskPersistence, Vc, RawVc, TaskInput, TaskPersistence, Vc,
}; };
#[inline(never)] #[inline(never)]
...@@ -45,10 +45,10 @@ pub fn get_non_local_persistence_from_inputs_and_this( ...@@ -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 where
ReturnType: TaskOutput<Return = Vc<Rv>>, 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; pub(crate) mod cast;
mod cell_mode; mod cell_mode;
pub(crate) mod default; pub(crate) mod default;
mod local;
pub(crate) mod operation; pub(crate) mod operation;
mod read; mod read;
pub(crate) mod resolved; pub(crate) mod resolved;
...@@ -23,9 +24,10 @@ pub use self::{ ...@@ -23,9 +24,10 @@ pub use self::{
cast::{VcCast, VcValueTraitCast, VcValueTypeCast}, cast::{VcCast, VcValueTraitCast, VcValueTypeCast},
cell_mode::{VcCellMode, VcCellNewMode, VcCellSharedMode}, cell_mode::{VcCellMode, VcCellNewMode, VcCellSharedMode},
default::ValueDefault, default::ValueDefault,
local::NonLocalValue,
operation::{OperationValue, OperationVc}, operation::{OperationValue, OperationVc},
read::{ReadVcFuture, VcDefaultRead, VcRead, VcTransparentRead}, read::{ReadVcFuture, VcDefaultRead, VcRead, VcTransparentRead},
resolved::{ResolvedValue, ResolvedVc}, resolved::ResolvedVc,
traits::{Dynamic, TypedForInput, Upcast, VcValueTrait, VcValueType}, traits::{Dynamic, TypedForInput, Upcast, VcValueTrait, VcValueType},
}; };
use crate::{ use crate::{
......
...@@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize}; ...@@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
use crate::{ use crate::{
debug::{ValueDebug, ValueDebugFormat, ValueDebugFormatString}, debug::{ValueDebug, ValueDebugFormat, ValueDebugFormatString},
marker_trait::impl_auto_marker_trait,
trace::{TraceRawVcs, TraceRawVcsContext}, trace::{TraceRawVcs, TraceRawVcsContext},
vc::Vc, vc::Vc,
ResolveTypeError, Upcast, VcRead, VcTransparentRead, VcValueTrait, VcValueType, ResolveTypeError, Upcast, VcRead, VcTransparentRead, VcValueTrait, VcValueType,
...@@ -240,18 +239,3 @@ where ...@@ -240,18 +239,3 @@ where
self.node.value_debug_format(depth) 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