Commit 5018dcfb authored by Tobias Koppers's avatar Tobias Koppers

Turbopack: remove TaskInput from AutoSet

parent 90bc934b
...@@ -19,6 +19,11 @@ use crate::{ ...@@ -19,6 +19,11 @@ use crate::{
/// Trait to implement in order for a type to be accepted as a /// Trait to implement in order for a type to be accepted as a
/// [`#[turbo_tasks::function]`][crate::function] argument. /// [`#[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 { pub trait TaskInput: Send + Sync + Clone + Debug + PartialEq + Eq + Hash + TraceRawVcs {
fn resolve_input(&self) -> impl Future<Output = Result<Self>> + Send + '_ { fn resolve_input(&self) -> impl Future<Output = Result<Self>> + Send + '_ {
async { Ok(self.clone()) } async { Ok(self.clone()) }
...@@ -332,19 +337,6 @@ where ...@@ -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 { macro_rules! tuple_impls {
( $( $name:ident )+ ) => { ( $( $name:ident )+ ) => {
impl<$($name: TaskInput),+> TaskInput for ($($name,)+) impl<$($name: TaskInput),+> TaskInput for ($($name,)+)
......
...@@ -6,7 +6,6 @@ pub mod resolve; ...@@ -6,7 +6,6 @@ pub mod resolve;
use std::{ use std::{
cmp::min, cmp::min,
fmt::{Display, Formatter}, fmt::{Display, Formatter},
sync::Arc,
}; };
use anyhow::{Result, anyhow}; use anyhow::{Result, anyhow};
...@@ -164,9 +163,7 @@ pub trait ImportTracer { ...@@ -164,9 +163,7 @@ pub trait ImportTracer {
fn get_traces(self: Vc<Self>, path: FileSystemPath) -> Vc<ImportTraces>; fn get_traces(self: Vc<Self>, path: FileSystemPath) -> Vc<ImportTraces>;
} }
#[derive( #[turbo_tasks::value]
Debug, Clone, TaskInput, TraceRawVcs, Hash, Eq, PartialEq, Serialize, Deserialize, NonLocalValue,
)]
pub struct DelegatingImportTracer { pub struct DelegatingImportTracer {
delegates: AutoSet<ResolvedVc<Box<dyn ImportTracer>>>, delegates: AutoSet<ResolvedVc<Box<dyn ImportTracer>>>,
} }
...@@ -220,7 +217,7 @@ pub struct Issues(Vec<ResolvedVc<Box<dyn Issue>>>); ...@@ -220,7 +217,7 @@ pub struct Issues(Vec<ResolvedVc<Box<dyn Issue>>>);
#[derive(Debug)] #[derive(Debug)]
pub struct CapturedIssues { pub struct CapturedIssues {
issues: AutoSet<ResolvedVc<Box<dyn Issue>>>, issues: AutoSet<ResolvedVc<Box<dyn Issue>>>,
tracer: Arc<DelegatingImportTracer>, tracer: ResolvedVc<DelegatingImportTracer>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -250,12 +247,10 @@ impl CapturedIssues { ...@@ -250,12 +247,10 @@ impl CapturedIssues {
// Returns all the issues as formatted `PlainIssues`. // Returns all the issues as formatted `PlainIssues`.
pub async fn get_plain_issues(&self) -> Result<Vec<ReadRef<PlainIssue>>> { pub async fn get_plain_issues(&self) -> Result<Vec<ReadRef<PlainIssue>>> {
let mut list = let mut list = self
self.issues .issues
.iter() .iter()
.map(|issue| async move { .map(|issue| async move { PlainIssue::from_issue(**issue, Some(*self.tracer)).await })
PlainIssue::from_issue(**issue, Some(self.tracer.clone())).await
})
.try_join() .try_join()
.await?; .await?;
list.sort(); list.sort();
...@@ -716,7 +711,7 @@ impl PlainIssue { ...@@ -716,7 +711,7 @@ impl PlainIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn from_issue( pub async fn from_issue(
issue: ResolvedVc<Box<dyn Issue>>, issue: ResolvedVc<Box<dyn Issue>>,
import_tracer: Option<Arc<DelegatingImportTracer>>, import_tracer: Option<ResolvedVc<DelegatingImportTracer>>,
) -> Result<Vc<Self>> { ) -> Result<Vc<Self>> {
let description: Option<StyledString> = match *issue.description().await? { let description: Option<StyledString> = match *issue.description().await? {
Some(description) => Some(description.owned().await?), Some(description) => Some(description.owned().await?),
...@@ -747,7 +742,12 @@ impl PlainIssue { ...@@ -747,7 +742,12 @@ impl PlainIssue {
}, },
import_traces: match import_tracer { import_traces: match import_tracer {
Some(tracer) => { Some(tracer) => {
into_plain_trace(tracer.get_traces(issue.file_path().owned().await?).await?) into_plain_trace(
tracer
.await?
.get_traces(issue.file_path().owned().await?)
.await?,
)
.await? .await?
} }
None => vec![], None => vec![],
...@@ -835,9 +835,10 @@ where ...@@ -835,9 +835,10 @@ where
CapturedIssues { CapturedIssues {
issues: self.peek_collectibles(), issues: self.peek_collectibles(),
tracer: Arc::new(DelegatingImportTracer { tracer: DelegatingImportTracer {
delegates: self.peek_collectibles(), delegates: self.peek_collectibles(),
}), }
.resolved_cell(),
} }
} }
...@@ -845,9 +846,10 @@ where ...@@ -845,9 +846,10 @@ where
CapturedIssues { CapturedIssues {
issues: self.take_collectibles(), issues: self.take_collectibles(),
tracer: Arc::new(DelegatingImportTracer { tracer: DelegatingImportTracer {
delegates: self.take_collectibles(), delegates: self.take_collectibles(),
}), }
.resolved_cell(),
} }
} }
} }
......
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