Skip to content
Closed
Show file tree
Hide file tree
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
18 changes: 5 additions & 13 deletions turbopack/crates/turbo-tasks/src/task/task_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ use crate::{

/// Trait to implement in order for a type to be accepted as a
/// [`#[turbo_tasks::function]`][crate::function] argument.
///
/// Note that in addition to the trait bounds, the type must also be deterministic serializable when
/// used for a persisted task (is_transient = false). This means serialization of equal values
/// should lead to byte-identical results. This is not enforced by the trait itself, but is required
/// for correct behavior.
pub trait TaskInput: Send + Sync + Clone + Debug + PartialEq + Eq + Hash + TraceRawVcs {
fn resolve_input(&self) -> impl Future<Output = Result<Self>> + Send + '_ {
async { Ok(self.clone()) }
Expand Down Expand Up @@ -332,19 +337,6 @@ where
}
}

impl<T> TaskInput for auto_hash_map::AutoSet<T>
where
T: TaskInput,
{
fn is_resolved(&self) -> bool {
self.iter().all(TaskInput::is_resolved)
}

fn is_transient(&self) -> bool {
self.iter().any(TaskInput::is_transient)
}
}

macro_rules! tuple_impls {
( $( $name:ident )+ ) => {
impl<$($name: TaskInput),+> TaskInput for ($($name,)+)
Expand Down
42 changes: 22 additions & 20 deletions turbopack/crates/turbopack-core/src/issue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub mod resolve;
use std::{
cmp::min,
fmt::{Display, Formatter},
sync::Arc,
};

use anyhow::{Result, anyhow};
Expand Down Expand Up @@ -164,9 +163,7 @@ pub trait ImportTracer {
fn get_traces(self: Vc<Self>, path: FileSystemPath) -> Vc<ImportTraces>;
}

#[derive(
Debug, Clone, TaskInput, TraceRawVcs, Hash, Eq, PartialEq, Serialize, Deserialize, NonLocalValue,
)]
#[turbo_tasks::value]
pub struct DelegatingImportTracer {
delegates: AutoSet<ResolvedVc<Box<dyn ImportTracer>>>,
}
Expand Down Expand Up @@ -220,7 +217,7 @@ pub struct Issues(Vec<ResolvedVc<Box<dyn Issue>>>);
#[derive(Debug)]
pub struct CapturedIssues {
issues: AutoSet<ResolvedVc<Box<dyn Issue>>>,
tracer: Arc<DelegatingImportTracer>,
tracer: ResolvedVc<DelegatingImportTracer>,
}

#[turbo_tasks::value_impl]
Expand Down Expand Up @@ -250,14 +247,12 @@ impl CapturedIssues {

// Returns all the issues as formatted `PlainIssues`.
pub async fn get_plain_issues(&self) -> Result<Vec<ReadRef<PlainIssue>>> {
let mut list =
self.issues
.iter()
.map(|issue| async move {
PlainIssue::from_issue(**issue, Some(self.tracer.clone())).await
})
.try_join()
.await?;
let mut list = self
.issues
.iter()
.map(|issue| async move { PlainIssue::from_issue(**issue, Some(*self.tracer)).await })
.try_join()
.await?;
list.sort();
Ok(list)
}
Expand Down Expand Up @@ -716,7 +711,7 @@ impl PlainIssue {
#[turbo_tasks::function]
pub async fn from_issue(
issue: ResolvedVc<Box<dyn Issue>>,
import_tracer: Option<Arc<DelegatingImportTracer>>,
import_tracer: Option<ResolvedVc<DelegatingImportTracer>>,
) -> Result<Vc<Self>> {
let description: Option<StyledString> = match *issue.description().await? {
Some(description) => Some(description.owned().await?),
Expand Down Expand Up @@ -747,8 +742,13 @@ impl PlainIssue {
},
import_traces: match import_tracer {
Some(tracer) => {
into_plain_trace(tracer.get_traces(issue.file_path().owned().await?).await?)
.await?
into_plain_trace(
tracer
.await?
.get_traces(issue.file_path().owned().await?)
.await?,
)
.await?
}
None => vec![],
},
Expand Down Expand Up @@ -835,19 +835,21 @@ where
CapturedIssues {
issues: self.peek_collectibles(),

tracer: Arc::new(DelegatingImportTracer {
tracer: DelegatingImportTracer {
delegates: self.peek_collectibles(),
}),
}
.resolved_cell(),
}
}

fn take_issues(self) -> CapturedIssues {
CapturedIssues {
issues: self.take_collectibles(),

tracer: Arc::new(DelegatingImportTracer {
tracer: DelegatingImportTracer {
delegates: self.take_collectibles(),
}),
}
.resolved_cell(),
}
}
}
Expand Down
Loading