Unverified Commit a24f9e4d authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

test(turbopack): remove remaining test unmarks (#98376)

### What?

Remove all 14 remaining non-API
`unmark_top_level_task_may_leak_eventually_consistent_state()` calls
from Turbopack tests across eight files. The manual mark/unmark
consistency test remains unchanged because it intentionally covers this
API.

### Why?

Top-level test reads should state their consistency boundary explicitly
instead of globally permitting eventually consistent state. Removing the
suppressions makes accidental eventual reads fail normally and keeps
each test aligned with production consistency rules.

### How?

Use coarse operation roots for collectible and recomputation scenarios
where the operation can settle, and narrower phase boundaries for tests
that mutate dependencies. Preserve graph-sensitive behavior by
extracting task IDs without resolving in parent-count tests and by
strongly reading the existing leaf root without inserting wrapper
parents in GC tests. Error tests use separate operation and plain-future
helpers so their expected context stacks remain unchanged.

### Verification

- `cargo fmt --all -- --check`
- `timeout 300 cargo test -p turbo-tasks-backend --test parent_count
--test trait_ref_cell_mode --test recompute_collectibles --test
recompute --test collectibles --test errors --test immutable --test
gc_collection` (36 passed)
- `git diff --check`

<!-- NEXT_JS_LLM -->

<!-- fleet 475180cd-06a7-4669-89b5-a2029a3a18c9 -->
Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
parent 12374810
...@@ -9,10 +9,7 @@ use auto_hash_map::AutoSet; ...@@ -9,10 +9,7 @@ use auto_hash_map::AutoSet;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use tokio::time::sleep; use tokio::time::sleep;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{CollectiblesSource, ResolvedVc, ValueToString, Vc, emit};
CollectiblesSource, ResolvedVc, ValueToString, Vc, emit,
unmark_top_level_task_may_leak_eventually_consistent_state,
};
use turbo_tasks_testing::{Registration, register, run_once}; use turbo_tasks_testing::{Registration, register, run_once};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
...@@ -20,16 +17,21 @@ static REGISTRATION: Registration = register!(); ...@@ -20,16 +17,21 @@ static REGISTRATION: Registration = register!();
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_transitive_emitting() { async fn test_transitive_emitting() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); #[turbo_tasks::function(operation, root)]
let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!("")); async fn operation() -> Result<Vc<()>> {
let result_val = result_op.connect().strongly_consistent().await?; let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!(""));
let list = result_op.peek_collectibles::<Box<dyn ValueToString>>(); let result_val = result_op.connect().await?;
assert_eq!(list.len(), 2); let list = result_op.peek_collectibles::<Box<dyn ValueToString>>();
let mut expected = ["123", "42"].into_iter().collect::<FxHashSet<_>>(); assert_eq!(list.len(), 2);
for collectible in list { let mut expected = ["123", "42"].into_iter().collect::<FxHashSet<_>>();
assert!(expected.remove(collectible.to_string().await?.as_str())) for collectible in list {
assert!(expected.remove(collectible.to_string().await?.as_str()))
}
assert_eq!(result_val.0, 0);
Ok(Vc::cell(()))
} }
assert_eq!(result_val.0, 0);
operation().read_strongly_consistent().await?;
anyhow::Ok(()) anyhow::Ok(())
}) })
.await .await
...@@ -39,16 +41,22 @@ async fn test_transitive_emitting() { ...@@ -39,16 +41,22 @@ async fn test_transitive_emitting() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_transitive_emitting_indirect() { async fn test_transitive_emitting_indirect() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); #[turbo_tasks::function(operation, root)]
let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!("")); async fn operation() -> Result<Vc<()>> {
let collectibles_op = my_transitive_emitting_function_collectibles(rcstr!(""), rcstr!("")); let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!(""));
let list = collectibles_op.connect().strongly_consistent().await?; let collectibles_op =
assert_eq!(list.len(), 2); my_transitive_emitting_function_collectibles(rcstr!(""), rcstr!(""));
let mut expected = ["123", "42"].into_iter().collect::<FxHashSet<_>>(); let list = collectibles_op.connect().await?;
for collectible in list.iter() { assert_eq!(list.len(), 2);
assert!(expected.remove(collectible.to_string().await?.as_str())) let mut expected = ["123", "42"].into_iter().collect::<FxHashSet<_>>();
for collectible in list.iter() {
assert!(expected.remove(collectible.to_string().await?.as_str()))
}
assert_eq!(result_op.connect().await?.0, 0);
Ok(Vc::cell(()))
} }
assert_eq!(result_op.connect().await?.0, 0);
operation().read_strongly_consistent().await?;
anyhow::Ok(()) anyhow::Ok(())
}) })
.await .await
...@@ -58,16 +66,21 @@ async fn test_transitive_emitting_indirect() { ...@@ -58,16 +66,21 @@ async fn test_transitive_emitting_indirect() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_multi_emitting() { async fn test_multi_emitting() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); #[turbo_tasks::function(operation, root)]
let result_op = my_multi_emitting_function(); async fn operation() -> Result<Vc<()>> {
let result_val = result_op.connect().strongly_consistent().await?; let result_op = my_multi_emitting_function();
let list = result_op.peek_collectibles::<Box<dyn ValueToString>>(); let result_val = result_op.connect().await?;
assert_eq!(list.len(), 2); let list = result_op.peek_collectibles::<Box<dyn ValueToString>>();
let mut expected = ["123", "42"].into_iter().collect::<FxHashSet<_>>(); assert_eq!(list.len(), 2);
for collectible in list { let mut expected = ["123", "42"].into_iter().collect::<FxHashSet<_>>();
assert!(expected.remove(collectible.to_string().await?.as_str())) for collectible in list {
assert!(expected.remove(collectible.to_string().await?.as_str()))
}
assert_eq!(result_val.0, 0);
Ok(Vc::cell(()))
} }
assert_eq!(result_val.0, 0);
operation().read_strongly_consistent().await?;
anyhow::Ok(()) anyhow::Ok(())
}) })
.await .await
......
...@@ -7,9 +7,7 @@ use std::{ ...@@ -7,9 +7,7 @@ use std::{
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use indoc::indoc; use indoc::indoc;
use turbo_tasks::{ use turbo_tasks::{OperationVc, PrettyPrintError, Vc, VcValueType};
PrettyPrintError, Vc, unmark_top_level_task_may_leak_eventually_consistent_state,
};
use turbo_tasks_testing::{Registration, register, run}; use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
...@@ -18,11 +16,27 @@ static REGISTRATION: Registration = register!(); ...@@ -18,11 +16,27 @@ static REGISTRATION: Registration = register!();
// Helper function to test error messages // Helper function to test error messages
// ============================================================================ // ============================================================================
async fn assert_error<T: Debug>( async fn assert_error<T: VcValueType>(
operation: OperationVc<T>,
expected: &'static str,
) -> Result<()> {
let error = match operation.read_strongly_consistent().await {
Ok(_) => panic!("expected an error"),
Err(error) => error,
};
assert_eq!(
&PrettyPrintError(&error).to_string(),
expected,
"{:#?}",
error
);
Ok(())
}
async fn assert_future_error<T: Debug>(
future: impl IntoFuture<Output = Result<T>>, future: impl IntoFuture<Output = Result<T>>,
expected: &'static str, expected: &'static str,
) -> Result<()> { ) -> Result<()> {
unmark_top_level_task_may_leak_eventually_consistent_state();
let error = future.into_future().await.unwrap_err(); let error = future.into_future().await.unwrap_err();
assert_eq!( assert_eq!(
&PrettyPrintError(&error).to_string(), &PrettyPrintError(&error).to_string(),
...@@ -44,22 +58,22 @@ where ...@@ -44,22 +58,22 @@ where
// Direct error functions // Direct error functions
// ============================================================================ // ============================================================================
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
fn direct_bail() -> Result<Vc<u32>> { fn direct_bail() -> Result<Vc<u32>> {
bail!("direct bail error") bail!("direct bail error")
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
fn direct_bail_with_context() -> Result<Vc<u32>> { fn direct_bail_with_context() -> Result<Vc<u32>> {
Err(anyhow::anyhow!("direct bail error")).context("bail-context") Err(anyhow::anyhow!("direct bail error")).context("bail-context")
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
fn direct_panic() -> Result<Vc<u32>> { fn direct_panic() -> Result<Vc<u32>> {
panic!("direct panic error") panic!("direct panic error")
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
fn direct_panic_with_context() -> Result<Vc<u32>> { fn direct_panic_with_context() -> Result<Vc<u32>> {
// Note: panic! is synchronous, so context cannot wrap it // Note: panic! is synchronous, so context cannot wrap it
panic!("direct panic error") panic!("direct panic error")
...@@ -69,27 +83,27 @@ fn direct_panic_with_context() -> Result<Vc<u32>> { ...@@ -69,27 +83,27 @@ fn direct_panic_with_context() -> Result<Vc<u32>> {
// Indirect error functions (call another function that errors) // Indirect error functions (call another function that errors)
// ============================================================================ // ============================================================================
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
async fn indirect_bail() -> Result<Vc<u32>> { async fn indirect_bail() -> Result<Vc<u32>> {
direct_bail().await?; direct_bail().connect().await?;
Ok(Vc::cell(0)) Ok(Vc::cell(0))
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
async fn indirect_bail_with_context() -> Result<Vc<u32>> { async fn indirect_bail_with_context() -> Result<Vc<u32>> {
direct_bail().await.context("indirect-context")?; direct_bail().connect().await.context("indirect-context")?;
Ok(Vc::cell(0)) Ok(Vc::cell(0))
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
async fn indirect_panic() -> Result<Vc<u32>> { async fn indirect_panic() -> Result<Vc<u32>> {
direct_panic().await?; direct_panic().connect().await?;
Ok(Vc::cell(0)) Ok(Vc::cell(0))
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
async fn indirect_panic_with_context() -> Result<Vc<u32>> { async fn indirect_panic_with_context() -> Result<Vc<u32>> {
direct_panic().await.context("indirect-context")?; direct_panic().connect().await.context("indirect-context")?;
Ok(Vc::cell(0)) Ok(Vc::cell(0))
} }
...@@ -251,46 +265,70 @@ async fn test_indirect_panic_with_context() { ...@@ -251,46 +265,70 @@ async fn test_indirect_panic_with_context() {
} }
// ============================================================================ // ============================================================================
// In-context wrapper functions (not turbo_tasks functions) // In-context wrapper operations
// ============================================================================ // ============================================================================
async fn direct_bail_in_context() -> Result<()> { async fn direct_bail_in_context() -> Result<()> {
direct_bail().await.context("in-context")?; direct_bail()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
async fn direct_bail_with_context_in_context() -> Result<()> { async fn direct_bail_with_context_in_context() -> Result<()> {
direct_bail_with_context().await.context("in-context")?; direct_bail_with_context()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
async fn direct_panic_in_context() -> Result<()> { async fn direct_panic_in_context() -> Result<()> {
direct_panic().await.context("in-context")?; direct_panic()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
async fn direct_panic_with_context_in_context() -> Result<()> { async fn direct_panic_with_context_in_context() -> Result<()> {
direct_panic_with_context().await.context("in-context")?; direct_panic_with_context()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
async fn indirect_bail_in_context() -> Result<()> { async fn indirect_bail_in_context() -> Result<()> {
indirect_bail().await.context("in-context")?; indirect_bail()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
async fn indirect_bail_with_context_in_context() -> Result<()> { async fn indirect_bail_with_context_in_context() -> Result<()> {
indirect_bail_with_context().await.context("in-context")?; indirect_bail_with_context()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
async fn indirect_panic_in_context() -> Result<()> { async fn indirect_panic_in_context() -> Result<()> {
indirect_panic().await.context("in-context")?; indirect_panic()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
async fn indirect_panic_with_context_in_context() -> Result<()> { async fn indirect_panic_with_context_in_context() -> Result<()> {
indirect_panic_with_context().await.context("in-context")?; indirect_panic_with_context()
.read_strongly_consistent()
.await
.context("in-context")?;
Ok(()) Ok(())
} }
...@@ -301,7 +339,7 @@ async fn indirect_panic_with_context_in_context() -> Result<()> { ...@@ -301,7 +339,7 @@ async fn indirect_panic_with_context_in_context() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_direct_bail_in_context() { async fn test_direct_bail_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
direct_bail_in_context(), direct_bail_in_context(),
indoc! {" indoc! {"
in-context in-context
...@@ -322,7 +360,7 @@ async fn test_direct_bail_in_context() { ...@@ -322,7 +360,7 @@ async fn test_direct_bail_in_context() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_direct_bail_with_context_in_context() { async fn test_direct_bail_with_context_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
direct_bail_with_context_in_context(), direct_bail_with_context_in_context(),
indoc! {" indoc! {"
in-context in-context
...@@ -345,7 +383,7 @@ async fn test_direct_bail_with_context_in_context() { ...@@ -345,7 +383,7 @@ async fn test_direct_bail_with_context_in_context() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_direct_panic_in_context() { async fn test_direct_panic_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
direct_panic_in_context(), direct_panic_in_context(),
indoc! {" indoc! {"
in-context in-context
...@@ -366,7 +404,7 @@ async fn test_direct_panic_in_context() { ...@@ -366,7 +404,7 @@ async fn test_direct_panic_in_context() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_direct_panic_with_context_in_context() { async fn test_direct_panic_with_context_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
direct_panic_with_context_in_context(), direct_panic_with_context_in_context(),
indoc! {" indoc! {"
in-context in-context
...@@ -387,7 +425,7 @@ async fn test_direct_panic_with_context_in_context() { ...@@ -387,7 +425,7 @@ async fn test_direct_panic_with_context_in_context() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_indirect_bail_in_context() { async fn test_indirect_bail_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
indirect_bail_in_context(), indirect_bail_in_context(),
indoc! {" indoc! {"
in-context in-context
...@@ -409,7 +447,7 @@ async fn test_indirect_bail_in_context() { ...@@ -409,7 +447,7 @@ async fn test_indirect_bail_in_context() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_indirect_bail_with_context_in_context() { async fn test_indirect_bail_with_context_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
indirect_bail_with_context_in_context(), indirect_bail_with_context_in_context(),
indoc! {" indoc! {"
in-context in-context
...@@ -433,7 +471,7 @@ async fn test_indirect_bail_with_context_in_context() { ...@@ -433,7 +471,7 @@ async fn test_indirect_bail_with_context_in_context() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_indirect_panic_in_context() { async fn test_indirect_panic_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
indirect_panic_in_context(), indirect_panic_in_context(),
indoc! {" indoc! {"
in-context in-context
...@@ -455,7 +493,7 @@ async fn test_indirect_panic_in_context() { ...@@ -455,7 +493,7 @@ async fn test_indirect_panic_in_context() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_indirect_panic_with_context_in_context() { async fn test_indirect_panic_with_context_in_context() {
test(async || { test(async || {
assert_error( assert_future_error(
indirect_panic_with_context_in_context(), indirect_panic_with_context_in_context(),
indoc! {" indoc! {"
in-context in-context
......
...@@ -8,23 +8,21 @@ mod util; ...@@ -8,23 +8,21 @@ mod util;
use std::sync::Arc; use std::sync::Arc;
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{ use turbo_tasks::{ResolvedVc, TaskId, Vc, prevent_gc};
ResolvedVc, TaskId, Vc, prevent_gc, unmark_top_level_task_may_leak_eventually_consistent_state,
};
use crate::{ use crate::{
gc_fixture::{Selector, create_selector}, gc_fixture::{Selector, create_selector},
util::create_tt, util::create_tt,
}; };
/// The `TaskId` backing a resolved `Vc` (its `TaskOutput` node). /// The `TaskId` backing a `Vc`'s `TaskOutput` node.
fn task_id_of<T>(vc: Vc<T>) -> TaskId { fn task_id_of<T>(vc: Vc<T>) -> TaskId {
Vc::into_raw(vc) Vc::into_raw(vc)
.try_get_task_id() .try_get_task_id()
.expect("a resolved Vc should be backed by a task") .expect("a resolved Vc should be backed by a task")
} }
#[turbo_tasks::function] #[turbo_tasks::function(root)]
fn leaf(n: u32) -> Vc<u32> { fn leaf(n: u32) -> Vc<u32> {
Vc::cell(n) Vc::cell(n)
} }
...@@ -210,11 +208,10 @@ async fn dispose_root_task_releases_anchored_subgraph() { ...@@ -210,11 +208,10 @@ async fn dispose_root_task_releases_anchored_subgraph() {
let tx = tx.lock().unwrap().take(); let tx = tx.lock().unwrap().take();
Box::pin(async move { Box::pin(async move {
// The root body runs as a top-level task, as `subscribe`'s HMR handler does. // The root body runs as a top-level task, as `subscribe`'s HMR handler does.
unmark_top_level_task_may_leak_eventually_consistent_state();
let leaf_vc = leaf(88); let leaf_vc = leaf(88);
let value = *leaf_vc.await?; let value = *leaf_vc.strongly_consistent().await?;
if let Some(tx) = tx { if let Some(tx) = tx {
let _ = tx.send(task_id_of(leaf_vc.resolve().await?)); let _ = tx.send(task_id_of(leaf_vc));
} }
anyhow::Ok(Vc::<u32>::cell(value)) anyhow::Ok(Vc::<u32>::cell(value))
}) })
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#![allow(clippy::needless_return)] // tokio macro-generated code doesn't respect this #![allow(clippy::needless_return)] // tokio macro-generated code doesn't respect this
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{State, Vc, unmark_top_level_task_may_leak_eventually_consistent_state}; use turbo_tasks::{ResolvedVc, State, Vc};
use turbo_tasks_testing::{Registration, register, run_once}; use turbo_tasks_testing::{Registration, register, run_once};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
...@@ -11,37 +11,46 @@ static REGISTRATION: Registration = register!(); ...@@ -11,37 +11,46 @@ static REGISTRATION: Registration = register!();
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_hidden_mutate() { async fn test_hidden_mutate() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); #[turbo_tasks::function(operation, root)]
let input = *create_input().to_resolved().await?; fn read_self_operation(input: ResolvedVc<Value>) -> Vc<u32> {
input.read_self()
}
#[turbo_tasks::function(operation, root)]
fn immutable_self_operation(input: ResolvedVc<Value>) -> Vc<u32> {
input.immutable_self_fn()
}
let input = create_input().resolve().strongly_consistent().await?;
input.await?.state.set(1); input.await?.state.set(1);
let changing_value = compute(input); let changing_value = compute(input);
assert_eq!(changing_value.await?.value, 1); assert_eq!(changing_value.read_strongly_consistent().await?.value, 1);
let changing_value_resolved = *changing_value.to_resolved().await?; let changing_value_resolved = changing_value.resolve().strongly_consistent().await?;
let read_input = read_input(changing_value_resolved); let read_input = read_input(changing_value_resolved);
let static_immutable = immutable_fn(changing_value_resolved); let static_immutable = immutable_fn(changing_value_resolved);
let read_self = changing_value_resolved.read_self(); let read_self = read_self_operation(changing_value_resolved);
let static_immutable_self = changing_value_resolved.immutable_self_fn(); let static_immutable_self = immutable_self_operation(changing_value_resolved);
assert_eq!(*read_input.await?, 1); assert_eq!(*read_input.read_strongly_consistent().await?, 1);
assert_eq!(*static_immutable.await?, 42); assert_eq!(*static_immutable.read_strongly_consistent().await?, 42);
assert_eq!(*read_self.await?, 1); assert_eq!(*read_self.read_strongly_consistent().await?, 1);
assert_eq!(*static_immutable_self.await?, 42); assert_eq!(*static_immutable_self.read_strongly_consistent().await?, 42);
println!("changing input"); println!("changing input");
input.await?.state.set(10); input.await?.state.set(10);
assert_eq!(changing_value.strongly_consistent().await?.value, 10); assert_eq!(changing_value.read_strongly_consistent().await?.value, 10);
assert_eq!(*read_input.strongly_consistent().await?, 10); assert_eq!(*read_input.read_strongly_consistent().await?, 10);
assert_eq!(*static_immutable.strongly_consistent().await?, 42); assert_eq!(*static_immutable.read_strongly_consistent().await?, 42);
assert_eq!(*read_self.strongly_consistent().await?, 10); assert_eq!(*read_self.read_strongly_consistent().await?, 10);
assert_eq!(*static_immutable_self.strongly_consistent().await?, 42); assert_eq!(*static_immutable_self.read_strongly_consistent().await?, 42);
println!("changing input"); println!("changing input");
input.await?.state.set(5); input.await?.state.set(5);
assert_eq!(changing_value.strongly_consistent().await?.value, 5); assert_eq!(changing_value.read_strongly_consistent().await?.value, 5);
assert_eq!(*read_input.strongly_consistent().await?, 5); assert_eq!(*read_input.read_strongly_consistent().await?, 5);
assert_eq!(*static_immutable.strongly_consistent().await?, 42); assert_eq!(*static_immutable.read_strongly_consistent().await?, 42);
assert_eq!(*read_self.strongly_consistent().await?, 5); assert_eq!(*read_self.read_strongly_consistent().await?, 5);
assert_eq!(*static_immutable_self.strongly_consistent().await?, 42); assert_eq!(*static_immutable_self.read_strongly_consistent().await?, 42);
anyhow::Ok(()) anyhow::Ok(())
}) })
...@@ -59,7 +68,7 @@ struct Value { ...@@ -59,7 +68,7 @@ struct Value {
value: u32, value: u32,
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
async fn create_input() -> Result<Vc<ChangingInput>> { async fn create_input() -> Result<Vc<ChangingInput>> {
println!("create_input()"); println!("create_input()");
Ok(ChangingInput { Ok(ChangingInput {
...@@ -68,23 +77,23 @@ async fn create_input() -> Result<Vc<ChangingInput>> { ...@@ -68,23 +77,23 @@ async fn create_input() -> Result<Vc<ChangingInput>> {
.cell()) .cell())
} }
#[turbo_tasks::function(root)] #[turbo_tasks::function(operation, root)]
async fn compute(input: Vc<ChangingInput>) -> Result<Vc<Value>> { async fn compute(input: ResolvedVc<ChangingInput>) -> Result<Vc<Value>> {
println!("compute()"); println!("compute()");
let input = input.await?; let input = input.await?;
let value = input.state.get(); let value = input.state.get();
Ok(Value { value: *value }.cell()) Ok(Value { value: *value }.cell())
} }
#[turbo_tasks::function(root)] #[turbo_tasks::function(operation, root)]
async fn read_input(input: Vc<Value>) -> Result<Vc<u32>> { async fn read_input(input: ResolvedVc<Value>) -> Result<Vc<u32>> {
println!("read_input()"); println!("read_input()");
let value = input.await?; let value = input.await?;
Ok(Vc::cell(value.value)) Ok(Vc::cell(value.value))
} }
#[turbo_tasks::function(root)] #[turbo_tasks::function(operation, root)]
fn immutable_fn(input: Vc<Value>) -> Vc<u32> { fn immutable_fn(input: ResolvedVc<Value>) -> Vc<u32> {
let _ = input; let _ = input;
println!("immutable_fn()"); println!("immutable_fn()");
Vc::cell(42) Vc::cell(42)
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
mod util; mod util;
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{ use turbo_tasks::{ResolvedVc, State, TaskId, Vc};
ResolvedVc, State, TaskId, Vc, unmark_top_level_task_may_leak_eventually_consistent_state,
};
use crate::util::create_tt; use crate::util::create_tt;
...@@ -62,8 +60,6 @@ async fn parent_count_tracks_connect_and_disconnect() { ...@@ -62,8 +60,6 @@ async fn parent_count_tracks_connect_and_disconnect() {
let tt2 = tt.clone(); let tt2 = tt.clone();
let result = turbo_tasks::run_once(tt.clone(), async move { let result = turbo_tasks::run_once(tt.clone(), async move {
unmark_top_level_task_may_leak_eventually_consistent_state();
let selector_op = create_selector(false); let selector_op = create_selector(false);
let selector_vc = selector_op.resolve().strongly_consistent().await?; let selector_vc = selector_op.resolve().strongly_consistent().await?;
let selector = selector_op.read_strongly_consistent().await?; let selector = selector_op.read_strongly_consistent().await?;
...@@ -73,9 +69,9 @@ async fn parent_count_tracks_connect_and_disconnect() { ...@@ -73,9 +69,9 @@ async fn parent_count_tracks_connect_and_disconnect() {
assert_eq!(*output.read_strongly_consistent().await?, 11); assert_eq!(*output.read_strongly_consistent().await?, 11);
// Resolve the branch task ids (calling the cached functions returns the same tasks). // Resolve the branch task ids (calling the cached functions returns the same tasks).
let branch_a_id = task_id_of(branch_a().resolve().await?); let branch_a_id = task_id_of(branch_a());
let leaf10_id = task_id_of(leaf(10).resolve().await?); let leaf10_id = task_id_of(leaf(10));
let branch_b_id = task_id_of(branch_b().resolve().await?); let branch_b_id = task_id_of(branch_b());
assert_eq!( assert_eq!(
tt2.backend().parent_count_for_testing(branch_a_id), tt2.backend().parent_count_for_testing(branch_a_id),
...@@ -148,8 +144,6 @@ async fn parent_count_not_double_counted_on_revalidation() { ...@@ -148,8 +144,6 @@ async fn parent_count_not_double_counted_on_revalidation() {
let tt2 = tt.clone(); let tt2 = tt.clone();
let result = turbo_tasks::run_once(tt.clone(), async move { let result = turbo_tasks::run_once(tt.clone(), async move {
unmark_top_level_task_may_leak_eventually_consistent_state();
let selector_op = create_selector(false); let selector_op = create_selector(false);
let selector_vc = selector_op.resolve().strongly_consistent().await?; let selector_vc = selector_op.resolve().strongly_consistent().await?;
let selector = selector_op.read_strongly_consistent().await?; let selector = selector_op.read_strongly_consistent().await?;
...@@ -157,7 +151,7 @@ async fn parent_count_not_double_counted_on_revalidation() { ...@@ -157,7 +151,7 @@ async fn parent_count_not_double_counted_on_revalidation() {
let output = stable_child_parent(selector_vc); let output = stable_child_parent(selector_vc);
assert_eq!(*output.read_strongly_consistent().await?, 30); assert_eq!(*output.read_strongly_consistent().await?, 30);
let leaf30_id = task_id_of(leaf(30).resolve().await?); let leaf30_id = task_id_of(leaf(30));
assert_eq!( assert_eq!(
tt2.backend().parent_count_for_testing(leaf30_id), tt2.backend().parent_count_for_testing(leaf30_id),
1, 1,
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
#![allow(clippy::needless_return)] // tokio macro-generated code doesn't respect this #![allow(clippy::needless_return)] // tokio macro-generated code doesn't respect this
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{ use turbo_tasks::{ResolvedVc, State, Vc};
ResolvedVc, State, Vc, unmark_top_level_task_may_leak_eventually_consistent_state,
};
use turbo_tasks_testing::{Registration, register, run, run_once}; use turbo_tasks_testing::{Registration, register, run, run_once};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
...@@ -13,38 +11,37 @@ static REGISTRATION: Registration = register!(); ...@@ -13,38 +11,37 @@ static REGISTRATION: Registration = register!();
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn recompute() { async fn recompute() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state();
let input = ChangingInput { let input = ChangingInput {
state: State::new(1), state: State::new(1),
} }
.cell(); .resolved_cell();
let input2 = ChangingInput { let input2 = ChangingInput {
state: State::new(10), state: State::new(10),
} }
.cell(); .resolved_cell();
let output = compute(input, input2); let output = compute(input, input2);
let read = output.await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.state_value, 1); assert_eq!(read.state_value, 1);
assert_eq!(read.state_value2, 10); assert_eq!(read.state_value2, 10);
let random_value = read.random_value; let random_value = read.random_value;
println!("changing input"); println!("changing input");
input.await?.state.set(2); input.await?.state.set(2);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.state_value, 2); assert_eq!(read.state_value, 2);
assert_ne!(read.random_value, random_value); assert_ne!(read.random_value, random_value);
let random_value = read.random_value; let random_value = read.random_value;
println!("changing input2"); println!("changing input2");
input2.await?.state.set(20); input2.await?.state.set(20);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.state_value2, 20); assert_eq!(read.state_value2, 20);
assert_ne!(read.random_value, random_value); assert_ne!(read.random_value, random_value);
let random_value = read.random_value; let random_value = read.random_value;
println!("changing input"); println!("changing input");
input.await?.state.set(5); input.await?.state.set(5);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.state_value, 5); assert_eq!(read.state_value, 5);
assert_eq!(read.state_value2, 42); assert_eq!(read.state_value2, 42);
assert_ne!(read.random_value, random_value); assert_ne!(read.random_value, random_value);
...@@ -52,7 +49,7 @@ async fn recompute() { ...@@ -52,7 +49,7 @@ async fn recompute() {
println!("changing input2"); println!("changing input2");
input2.await?.state.set(30); input2.await?.state.set(30);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.random_value, random_value); assert_eq!(read.random_value, random_value);
anyhow::Ok(()) anyhow::Ok(())
...@@ -64,7 +61,6 @@ async fn recompute() { ...@@ -64,7 +61,6 @@ async fn recompute() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn immutable_analysis() { async fn immutable_analysis() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state();
let input = ChangingInput { let input = ChangingInput {
state: State::new(1), state: State::new(1),
} }
...@@ -105,7 +101,7 @@ struct VcHolder { ...@@ -105,7 +101,7 @@ struct VcHolder {
impl VcHolder { impl VcHolder {
#[turbo_tasks::function(root)] #[turbo_tasks::function(root)]
fn compute(&self) -> Vc<Output> { fn compute(&self) -> Vc<Output> {
compute(*self.vc, *self.vc) compute(self.vc, self.vc).connect()
} }
} }
...@@ -116,11 +112,14 @@ struct Output { ...@@ -116,11 +112,14 @@ struct Output {
random_value: u32, random_value: u32,
} }
#[turbo_tasks::function(root)] #[turbo_tasks::function(operation, root)]
async fn compute(input: Vc<ChangingInput>, input2: Vc<ChangingInput>) -> Result<Vc<Output>> { async fn compute(
input: ResolvedVc<ChangingInput>,
input2: ResolvedVc<ChangingInput>,
) -> Result<Vc<Output>> {
let state_value = *input.await?.state.get(); let state_value = *input.await?.state.get();
let state_value2 = if state_value < 5 { let state_value2 = if state_value < 5 {
*compute2(input2).await? *compute2(*input2).await?
} else { } else {
42 42
}; };
...@@ -150,15 +149,17 @@ async fn compute2(input: Vc<ChangingInput>) -> Result<Vc<u32>> { ...@@ -150,15 +149,17 @@ async fn compute2(input: Vc<ChangingInput>) -> Result<Vc<u32>> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn recompute_dependency() { async fn recompute_dependency() {
run(&REGISTRATION, async || { run(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); let input = get_dependency_input()
let input = *get_dependency_input().to_resolved().await?; .resolve()
.strongly_consistent()
.await?;
// Reset state to 1 at the start of each iteration (important for multi-run tests) // Reset state to 1 at the start of each iteration (important for multi-run tests)
input.await?.state.set(1); input.await?.state.set(1);
// Initial execution - establishes dependency chain: // Initial execution - establishes dependency chain:
// outer_compute -> inner_compute -> input.state // outer_compute -> inner_compute -> input.state
let output = outer_compute(input); let output = outer_compute(input);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
println!( println!(
"first read: value={}, inner_random={}, outer_random={}", "first read: value={}, inner_random={}, outer_random={}",
read.value, read.inner_random, read.outer_random read.value, read.inner_random, read.outer_random
...@@ -172,7 +173,7 @@ async fn recompute_dependency() { ...@@ -172,7 +173,7 @@ async fn recompute_dependency() {
println!("changing input"); println!("changing input");
input.await?.state.set(2); input.await?.state.set(2);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
println!( println!(
"second read: value={}, inner_random={}, outer_random={}", "second read: value={}, inner_random={}, outer_random={}",
read.value, read.inner_random, read.outer_random read.value, read.inner_random, read.outer_random
...@@ -201,7 +202,7 @@ async fn recompute_dependency() { ...@@ -201,7 +202,7 @@ async fn recompute_dependency() {
.unwrap(); .unwrap();
} }
#[turbo_tasks::function] #[turbo_tasks::function(operation, root)]
fn get_dependency_input() -> Vc<ChangingInput> { fn get_dependency_input() -> Vc<ChangingInput> {
ChangingInput { ChangingInput {
state: State::new(1), state: State::new(1),
...@@ -227,10 +228,10 @@ async fn inner_compute(input: Vc<ChangingInput>) -> Result<Vc<u32>> { ...@@ -227,10 +228,10 @@ async fn inner_compute(input: Vc<ChangingInput>) -> Result<Vc<u32>> {
} }
/// Outer task - depends on inner_compute /// Outer task - depends on inner_compute
#[turbo_tasks::function(root)] #[turbo_tasks::function(operation, root)]
async fn outer_compute(input: Vc<ChangingInput>) -> Result<Vc<DependencyOutput>> { async fn outer_compute(input: ResolvedVc<ChangingInput>) -> Result<Vc<DependencyOutput>> {
println!("outer_compute()"); println!("outer_compute()");
let inner_result = *inner_compute(input).await?; let inner_result = *inner_compute(*input).await?;
let value = inner_result & 0xFFFF; let value = inner_result & 0xFFFF;
let inner_random = inner_result >> 16; let inner_random = inner_result >> 16;
Ok(DependencyOutput { Ok(DependencyOutput {
......
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ use turbo_tasks::{CollectiblesSource, ResolvedVc, State, ValueToString, Vc, emit};
CollectiblesSource, ResolvedVc, State, ValueToString, Vc, emit,
unmark_top_level_task_may_leak_eventually_consistent_state,
};
use turbo_tasks_testing::{Registration, register, run_once}; use turbo_tasks_testing::{Registration, register, run_once};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
...@@ -15,26 +12,31 @@ static REGISTRATION: Registration = register!(); ...@@ -15,26 +12,31 @@ static REGISTRATION: Registration = register!();
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn recompute() { async fn recompute() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); let input = ChangingInput {
let input = *ChangingInput::new(1).to_resolved().await?; state: State::new(1),
let input2 = *ChangingInput::new(2).to_resolved().await?; }
.resolved_cell();
let input2 = ChangingInput {
state: State::new(1),
}
.resolved_cell();
input.await?.state.set(1); input.await?.state.set(1);
input2.await?.state.set(1000); input2.await?.state.set(1000);
let output = compute(input, input2, 1); let output = compute(input, input2, 1);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.value, 42); assert_eq!(read.value, 42);
assert_eq!(read.collectible, "1"); assert_eq!(read.collectible, "1");
for i in 2..100 { for i in 2..100 {
input.await?.state.set(i); input.await?.state.set(i);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.value, 42); assert_eq!(read.value, 42);
assert_eq!(read.collectible, i.to_string()); assert_eq!(read.collectible, i.to_string());
} }
for i in 0..100 { for i in 0..100 {
input2.await?.state.set(i); input2.await?.state.set(i);
let read = output.strongly_consistent().await?; let read = output.read_strongly_consistent().await?;
assert_eq!(read.value, 42); assert_eq!(read.value, 42);
assert_eq!(read.collectible, "99"); assert_eq!(read.collectible, "99");
} }
...@@ -49,18 +51,6 @@ struct ChangingInput { ...@@ -49,18 +51,6 @@ struct ChangingInput {
state: State<u32>, state: State<u32>,
} }
#[turbo_tasks::value_impl]
impl ChangingInput {
#[turbo_tasks::function]
fn new(key: u32) -> Vc<Self> {
let _ = key;
Self {
state: State::new(1),
}
.cell()
}
}
#[turbo_tasks::value] #[turbo_tasks::value]
struct Output { struct Output {
value: u32, value: u32,
...@@ -103,7 +93,7 @@ async fn inner_compute2(input: Vc<ChangingInput>, innerness: u32) -> Result<Vc<u ...@@ -103,7 +93,7 @@ async fn inner_compute2(input: Vc<ChangingInput>, innerness: u32) -> Result<Vc<u
Ok(Vc::cell(42)) Ok(Vc::cell(42))
} }
#[turbo_tasks::function(root)] #[turbo_tasks::function(operation, root)]
async fn compute( async fn compute(
input: ResolvedVc<ChangingInput>, input: ResolvedVc<ChangingInput>,
input2: ResolvedVc<ChangingInput>, input2: ResolvedVc<ChangingInput>,
...@@ -111,7 +101,7 @@ async fn compute( ...@@ -111,7 +101,7 @@ async fn compute(
) -> Result<Vc<Output>> { ) -> Result<Vc<Output>> {
println!("compute({innerness})"); println!("compute({innerness})");
if innerness > 0 { if innerness > 0 {
return Ok(compute(*input, *input2, innerness - 1)); return Ok(compute(input, input2, innerness - 1).connect());
} }
let operation = inner_compute(input, input2); let operation = inner_compute(input, input2);
let value = *operation.connect().await?; let value = *operation.connect().await?;
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
#![feature(arbitrary_self_types_pointers)] #![feature(arbitrary_self_types_pointers)]
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{ use turbo_tasks::{ResolvedVc, State, TraitRef, Upcast, Vc};
State, TraitRef, Upcast, Vc, unmark_top_level_task_may_leak_eventually_consistent_state,
};
use turbo_tasks_testing::{Registration, register, run_once}; use turbo_tasks_testing::{Registration, register, run_once};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
...@@ -14,25 +12,35 @@ static REGISTRATION: Registration = register!(); ...@@ -14,25 +12,35 @@ static REGISTRATION: Registration = register!();
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_trait_ref_shared_cell_mode() { async fn test_trait_ref_shared_cell_mode() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); #[turbo_tasks::function(operation, root)]
fn operation(input: ResolvedVc<CellIdSelector>) -> Vc<Box<dyn ValueTrait>> {
shared_value_from_input(*input)
}
let input = CellIdSelector { let input = CellIdSelector {
value: 42, value: 42,
cell_idx: State::new(0), cell_idx: State::new(0),
} }
.cell(); .resolved_cell();
// create the task and compute it // create the task and compute it
let counter_value_vc = shared_value_from_input(input); let counter_value_op = operation(input);
let trait_ref_a = counter_value_vc.into_trait_ref().await?; let trait_ref_a = counter_value_op.read_trait_strongly_consistent().await?;
// invalidate the task, and pick a different cell id for the next execution // invalidate the task, and pick a different cell id for the next execution
input.await?.cell_idx.set_unconditionally(1); input.await?.cell_idx.set_unconditionally(1);
// recompute the task // recompute the task
let trait_ref_b = counter_value_vc.into_trait_ref().await?; let trait_ref_b = counter_value_op.read_trait_strongly_consistent().await?;
for trait_ref in [&trait_ref_a, &trait_ref_b] { for trait_ref in [&trait_ref_a, &trait_ref_b] {
assert_eq!(*TraitRef::cell(trait_ref.clone()).get_value().await?, 42); assert_eq!(
*TraitRef::cell(trait_ref.clone())
.get_value()
.strongly_consistent()
.await?,
42
);
} }
// because we're using `cell = "compare"`, these trait refs must use the same // because we're using `cell = "compare"`, these trait refs must use the same
...@@ -50,25 +58,35 @@ async fn test_trait_ref_shared_cell_mode() { ...@@ -50,25 +58,35 @@ async fn test_trait_ref_shared_cell_mode() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_trait_ref_new_cell_mode() { async fn test_trait_ref_new_cell_mode() {
run_once(&REGISTRATION, async || { run_once(&REGISTRATION, async || {
unmark_top_level_task_may_leak_eventually_consistent_state(); #[turbo_tasks::function(operation, root)]
fn operation(input: ResolvedVc<CellIdSelector>) -> Vc<Box<dyn ValueTrait>> {
new_value_from_input(*input)
}
let input = CellIdSelector { let input = CellIdSelector {
value: 42, value: 42,
cell_idx: State::new(0), cell_idx: State::new(0),
} }
.cell(); .resolved_cell();
// create the task and compute it // create the task and compute it
let counter_value_vc = new_value_from_input(input); let counter_value_op = operation(input);
let trait_ref_a = counter_value_vc.into_trait_ref().await?; let trait_ref_a = counter_value_op.read_trait_strongly_consistent().await?;
// invalidate the task, and pick a different cell id for the next execution // invalidate the task, and pick a different cell id for the next execution
input.await?.cell_idx.set_unconditionally(1); input.await?.cell_idx.set_unconditionally(1);
// recompute the task // recompute the task
let trait_ref_b = counter_value_vc.into_trait_ref().await?; let trait_ref_b = counter_value_op.read_trait_strongly_consistent().await?;
for trait_ref in [&trait_ref_a, &trait_ref_b] { for trait_ref in [&trait_ref_a, &trait_ref_b] {
assert_eq!(*TraitRef::cell(trait_ref.clone()).get_value().await?, 42); assert_eq!(
*TraitRef::cell(trait_ref.clone())
.get_value()
.strongly_consistent()
.await?,
42
);
} }
// because we're using `cell = "new"`, these trait refs must use different // because we're using `cell = "new"`, these trait refs must use different
...@@ -83,7 +101,7 @@ async fn test_trait_ref_new_cell_mode() { ...@@ -83,7 +101,7 @@ async fn test_trait_ref_new_cell_mode() {
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
trait ValueTrait { trait ValueTrait {
#[turbo_tasks::function] #[turbo_tasks::function(root)]
fn get_value(&self) -> Vc<usize>; fn get_value(&self) -> Vc<usize>;
} }
...@@ -95,7 +113,7 @@ struct NewValue(usize); ...@@ -95,7 +113,7 @@ struct NewValue(usize);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueTrait for SharedValue { impl ValueTrait for SharedValue {
#[turbo_tasks::function] #[turbo_tasks::function(root)]
fn get_value(&self) -> Vc<usize> { fn get_value(&self) -> Vc<usize> {
Vc::cell(self.0) Vc::cell(self.0)
} }
...@@ -103,7 +121,7 @@ impl ValueTrait for SharedValue { ...@@ -103,7 +121,7 @@ impl ValueTrait for SharedValue {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueTrait for NewValue { impl ValueTrait for NewValue {
#[turbo_tasks::function] #[turbo_tasks::function(root)]
fn get_value(&self) -> Vc<usize> { fn get_value(&self) -> Vc<usize> {
Vc::cell(self.0) Vc::cell(self.0)
} }
......
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