Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(turbopack/next-api): Implement NonLocalValue for TracedDiGraph and SingleModuleGraph #74506

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions turbopack/crates/turbopack-core/src/module_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::{
#[derive(Clone, Debug)]
pub struct ModuleSet(pub HashSet<ResolvedVc<Box<dyn Module>>>);

#[turbo_tasks::value(cell = "new", eq = "manual", into = "new", local)]
#[turbo_tasks::value(cell = "new", eq = "manual", into = "new")]
#[derive(Clone, Default)]
pub struct SingleModuleGraph {
graph: TracedDiGraph<SingleModuleGraphNode, ChunkingType>,
Expand Down Expand Up @@ -349,13 +349,18 @@ impl SingleModuleGraphNode {
}

#[derive(Clone, Debug, ValueDebugFormat, Serialize, Deserialize)]
struct TracedDiGraph<N: TraceRawVcs, E: TraceRawVcs>(DiGraph<N, E>);
impl<N: TraceRawVcs, E: TraceRawVcs> Default for TracedDiGraph<N, E> {
struct TracedDiGraph<N, E>(DiGraph<N, E>);
impl<N, E> Default for TracedDiGraph<N, E> {
fn default() -> Self {
Self(Default::default())
}
}
impl<N: TraceRawVcs, E: TraceRawVcs> TraceRawVcs for TracedDiGraph<N, E> {

impl<N, E> TraceRawVcs for TracedDiGraph<N, E>
where
N: TraceRawVcs,
E: TraceRawVcs,
{
fn trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext) {
for node in self.0.node_weights() {
node.trace_raw_vcs(trace_context);
Expand All @@ -365,13 +370,21 @@ impl<N: TraceRawVcs, E: TraceRawVcs> TraceRawVcs for TracedDiGraph<N, E> {
}
}
}
impl<N: TraceRawVcs, E: TraceRawVcs> Deref for TracedDiGraph<N, E> {

impl<N, E> Deref for TracedDiGraph<N, E> {
type Target = DiGraph<N, E>;
fn deref(&self) -> &Self::Target {
&self.0
}
}

unsafe impl<N, E> NonLocalValue for TracedDiGraph<N, E>
where
N: NonLocalValue,
E: NonLocalValue,
{
}

#[derive(PartialEq, Eq, Debug)]
pub enum GraphTraversalAction {
/// Continue visiting children
Expand Down
Loading