Skip to content

Commit

Permalink
refactor(turbo-tasks): Implement NonLocalValue for State<T> where…
Browse files Browse the repository at this point in the history
… `T: NonLocalValue` (vercel#73770)

Title says it all. This lets us implement `NonLocalValue` on more structs.

**What is NonLocalValue?** https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/trait.NonLocalValue.html
  • Loading branch information
bgw authored Dec 13, 2024
1 parent c824a7a commit af1b74f
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-testing/tests/detached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async fn test_spawns_detached_changing() -> anyhow::Result<()> {
.await
}

#[turbo_tasks::value(local)]
#[turbo_tasks::value]
struct ChangingInput {
state: State<u32>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn dirty_in_progress() {
.unwrap()
}

#[turbo_tasks::value(local)]
#[turbo_tasks::value]
struct ChangingInput {
state: State<u32>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn recompute() {
.unwrap();
}

#[turbo_tasks::value(local)]
#[turbo_tasks::value]
struct ChangingInput {
state: State<u32>,
}
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-testing/tests/recompute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async fn recompute() {
.unwrap()
}

#[turbo_tasks::value(local)]
#[turbo_tasks::value]
struct ChangingInput {
state: State<u32>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn recompute() {
.unwrap()
}

#[turbo_tasks::value(local)]
#[turbo_tasks::value]
struct ChangingInput {
state: State<u32>,
}
Expand Down
1 change: 1 addition & 0 deletions turbopack/crates/turbo-tasks/src/marker_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ macro_rules! impl_auto_marker_trait {
T: $crate::VcValueType,
<<T as $crate::VcValueType>::Read as $crate::VcRead<T>>::Target: $trait
{}
unsafe impl<T: $trait> $trait for $crate::State<T> {}

unsafe impl<T: $trait + ?Sized> $trait for &T {}
unsafe impl<T: $trait + ?Sized> $trait for &mut T {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct OutputAssetsMap(FxIndexMap<RcStr, ResolvedVc<Box<dyn OutputAsset>>>);

type ExpandedState = State<HashSet<RcStr>>;

#[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new", local)]
#[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new")]
pub struct AssetGraphContentSource {
root_path: ResolvedVc<FileSystemPath>,
root_assets: ResolvedVc<OutputAssetsSet>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::source::{ContentSourceContent, ContentSources};
/// pages. Here HTML and "other assets" are in different content sources. So we
/// use this source to only serve (and process) "other assets" when the HTML was
/// served once.
#[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new", local)]
#[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new")]
pub struct ConditionalContentSource {
activator: ResolvedVc<Box<dyn ContentSource>>,
action: ResolvedVc<Box<dyn ContentSource>>,
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-dev-server/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl ContentSourceDataVary {
}

/// A source of content that the dev server uses to respond to http requests.
#[turbo_tasks::value_trait(local)]
#[turbo_tasks::value_trait]
pub trait ContentSource {
fn get_routes(self: Vc<Self>) -> Vc<RouteTree>;

Expand Down

0 comments on commit af1b74f

Please sign in to comment.