next.js
3b136b60 - refactor(turbo-tasks): Implement `NonLocalValue` for *all* `ResolvedVc`s and `OperationVc`s (#73764)

Commit
1 year ago
refactor(turbo-tasks): Implement `NonLocalValue` for *all* `ResolvedVc`s and `OperationVc`s (#73764) This is a follow-up to #73714 **What is NonLocalValue?** https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/trait.NonLocalValue.html The core change here is this bit in `turbopack/crates/turbo-tasks/src/vc/local.rs`: ```diff - unsafe impl<T: ?Sized + NonLocalValue> NonLocalValue for OperationVc<T> {} - unsafe impl<T: ?Sized + NonLocalValue> NonLocalValue for ResolvedVc<T> {} + unsafe impl<T: ?Sized> NonLocalValue for OperationVc<T> {} + unsafe impl<T: ?Sized> NonLocalValue for ResolvedVc<T> {} ``` These new implementations are intentionally incorrect, as these values `T` could contain references to local `Vc` values. We must also check that `T: NonLocalValue`. However, we're temporarily ignoring that problem, as: - We don't *currently* depend on `NonLocalValue` for safety (local tasks aren't enabled). - We intend to make all `VcValueType`s implement `NonLocalValue`, so implementing this for all values is approximating that future state. - Adding a `T: NonLocalValue` bound introduces a lot of noise that isn't directly actionable for types that include a `ResolvedVc` or `OperationVc` that is not *yet* a `NonLocalValue`. This PR also adds the `NonLocalValue` to types explicitly deriving `TraceRawVcs`, for types that couldn't before, by using the new weaker bounds on the `NonLocalValue` impls.
Author
bgw bgw
Parents
Loading