Skip to content

Commit

Permalink
fix(turbo-tasks): Implement ValueDebugFormat for ResolvedVc (#71173)
Browse files Browse the repository at this point in the history
Caught this missing implementation when the codemod in #71172 tried to
convert this test to use `ResolvedVc`.

This implementation just forwards to the one on `Vc`.

I don't think we need an explicit test case for `Vc` inside of a struct,
because the plan is to codemod away virtually every instance of this.

Co-authored-by: Niklas Mischkulnig <[email protected]>
  • Loading branch information
bgw and mischnic authored Oct 22, 2024
1 parent e06cd47 commit 95720f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions turbopack/crates/turbo-tasks-testing/tests/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn enum_none_debug() {
#[tokio::test]
async fn enum_transparent_debug() {
run(&REGISTRATION, || async {
let a: Vc<Enum> = Enum::Transparent(Transparent(42).cell()).cell();
let a: Vc<Enum> = Enum::Transparent(Transparent(42).resolved_cell()).cell();
assert_eq!(
format!("{:?}", a.dbg().await?),
r#"Enum :: Transparent(
Expand All @@ -63,7 +63,7 @@ async fn enum_transparent_debug() {
#[tokio::test]
async fn enum_inner_vc_debug() {
run(&REGISTRATION, || async {
let a: Vc<Enum> = Enum::Enum(Enum::None.cell()).cell();
let a: Vc<Enum> = Enum::Enum(Enum::None.resolved_cell()).cell();
assert_eq!(
format!("{:?}", a.dbg().await?),
r#"Enum :: Enum(
Expand Down Expand Up @@ -163,8 +163,8 @@ struct Transparent(u32);
#[turbo_tasks::value(shared)]
enum Enum {
None,
Transparent(Vc<Transparent>),
Enum(Vc<Enum>),
Transparent(ResolvedVc<Transparent>),
Enum(ResolvedVc<Enum>),
}

#[turbo_tasks::value(shared)]
Expand Down
11 changes: 11 additions & 0 deletions turbopack/crates/turbo-tasks/src/vc/resolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use indexmap::{IndexMap, IndexSet};
use serde::{Deserialize, Serialize};

use crate::{
debug::{ValueDebug, ValueDebugFormat, ValueDebugFormatString},
trace::{TraceRawVcs, TraceRawVcsContext},
vc::Vc,
RcStr, ResolveTypeError, Upcast, VcRead, VcTransparentRead, VcValueTrait, VcValueType,
Expand Down Expand Up @@ -215,6 +216,16 @@ where
}
}

impl<T> ValueDebugFormat for ResolvedVc<T>
where
T: ?Sized + Send,
T: Upcast<Box<dyn ValueDebug>>,
{
fn value_debug_format(&self, depth: usize) -> ValueDebugFormatString {
self.node.value_debug_format(depth)
}
}

/// Indicates that a type does not contain any instances of [`Vc`]. It may
/// contain [`ResolvedVc`].
///
Expand Down

0 comments on commit 95720f4

Please sign in to comment.