pub unsafe trait NonLocalValue { }
Expand description
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”. 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 is provided that avoids the need
for these nightly-only features.
§Safety
This trait is marked as unsafe. You should not implement it yourself, but instead you should
rely on #[turbo_tasks::value]
or
#[derive(NonLocalValue)]
to do it for you.
There may be a few rare cases (e.g. custom generic bounds) where you cannot use
#[turbo_tasks::value]
. In these cases, it is your responsibility to ensure that no fields can
contain a Vc
or a transitive reference to a Vc
.
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.