Unverified Commit 9fbec930 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Migrate some async blocks to async closures (#97666)

This is everything except `turbo-tasks-[backend]`

Using ast-grep replacement:

- search: `|$$$ARGS| async move {$$$BODY}`
- replace: `async |$$$ARGS| {$$$BODY}`

This also made it obvious in some places that we don't actually need
async-await,
e.g. `.map(async |v| v.to_resolved.await)`
parent 1c86b8a4
...@@ -58,7 +58,7 @@ impl Version for AggregateHmrVersion { ...@@ -58,7 +58,7 @@ impl Version for AggregateHmrVersion {
let version = TraitRef::cell(version.clone()); let version = TraitRef::cell(version.clone());
async move { async move {
let id = version.id().owned().await?; let id = version.id().owned().await?;
Ok::<_, anyhow::Error>((path, id)) anyhow::Ok((path, id))
} }
}) })
.try_join() .try_join()
...@@ -93,7 +93,7 @@ impl AggregateHmrVersion { ...@@ -93,7 +93,7 @@ impl AggregateHmrVersion {
let content = *content; let content = *content;
async move { async move {
let version = content.version().into_trait_ref().await?; let version = content.version().into_trait_ref().await?;
Ok::<_, anyhow::Error>((path, version)) anyhow::Ok((path, version))
} }
}) })
.try_join() .try_join()
...@@ -194,9 +194,9 @@ pub async fn diff_chunks_against( ...@@ -194,9 +194,9 @@ pub async fn diff_chunks_against(
}; };
Some((path.clone(), *content, TraitRef::cell(prev))) Some((path.clone(), *content, TraitRef::cell(prev)))
}) })
.map(|(path, content, prev)| async move { .map(async |(path, content, prev)| {
let update = content.update(prev).await?; let update = content.update(prev).await?;
Ok::<_, anyhow::Error>((path, update)) anyhow::Ok((path, update))
}) })
.try_join() .try_join()
.await?; .await?;
......
...@@ -827,7 +827,7 @@ impl AppProject { ...@@ -827,7 +827,7 @@ impl AppProject {
.any(|route| route.as_str() == pathname.to_string()) .any(|route| route.as_str() == pathname.to_string())
}) })
}) })
.map(|(pathname, app_entrypoint)| async { .map(async |(pathname, app_entrypoint)| {
Ok(( Ok((
pathname.to_string().into(), pathname.to_string().into(),
app_entry_point_to_route(self, app_entrypoint.clone()) app_entry_point_to_route(self, app_entrypoint.clone())
......
...@@ -34,7 +34,7 @@ pub async fn map_client_references( ...@@ -34,7 +34,7 @@ pub async fn map_client_references(
let manifest = graph let manifest = graph
.await? .await?
.iter_reachable_modules()? .iter_reachable_modules()?
.map(|module| async move { .map(async |module| {
if let Some(client_reference_module) = if let Some(client_reference_module) =
ResolvedVc::try_downcast_type::<EcmascriptClientReferenceModule>(module) ResolvedVc::try_downcast_type::<EcmascriptClientReferenceModule>(module)
{ {
......
...@@ -54,7 +54,7 @@ pub(crate) async fn collect_next_dynamic_chunks( ...@@ -54,7 +54,7 @@ pub(crate) async fn collect_next_dynamic_chunks(
let chunking_availability = &chunking_availability; let chunking_availability = &chunking_availability;
let dynamic_import_chunks = dynamic_import_entries let dynamic_import_chunks = dynamic_import_entries
.iter() .iter()
.map(|(dynamic_entry, parent_client_reference)| async move { .map(async |(dynamic_entry, parent_client_reference)| {
let module = ResolvedVc::upcast::<Box<dyn ChunkableModule>>(*dynamic_entry); let module = ResolvedVc::upcast::<Box<dyn ChunkableModule>>(*dynamic_entry);
// This is the availability info for the parent chunk group, i.e. the client reference // This is the availability info for the parent chunk group, i.e. the client reference
...@@ -124,7 +124,7 @@ pub async fn map_next_dynamic( ...@@ -124,7 +124,7 @@ pub async fn map_next_dynamic(
graph graph
.await? .await?
.iter_reachable_modules()? .iter_reachable_modules()?
.map(|module| async move { .map(async |module| {
if let Some(dynamic_entry_module) = if let Some(dynamic_entry_module) =
ResolvedVc::try_downcast_type::<NextDynamicEntryModule>(module) ResolvedVc::try_downcast_type::<NextDynamicEntryModule>(module)
&& module.ident().await?.layer.as_ref().is_some_and(|layer| { && module.ident().await?.layer.as_ref().is_some_and(|layer| {
......
...@@ -103,7 +103,7 @@ impl NextDynamicGraphs { ...@@ -103,7 +103,7 @@ impl NextDynamicGraphs {
let result = self let result = self
.0 .0
.iter() .iter()
.map(|graph| async move { .map(async |graph| {
Ok(graph Ok(graph
.get_next_dynamic_imports_for_endpoint(entry) .get_next_dynamic_imports_for_endpoint(entry)
.await? .await?
...@@ -300,7 +300,7 @@ impl ServerActionsGraphs { ...@@ -300,7 +300,7 @@ impl ServerActionsGraphs {
let result = self let result = self
.0 .0
.iter() .iter()
.map(|graph| async move { .map(async |graph| {
graph graph
.get_server_actions_for_endpoint(entry, rsc_asset_context) .get_server_actions_for_endpoint(entry, rsc_asset_context)
.owned() .owned()
...@@ -372,7 +372,7 @@ impl ServerActionsGraph { ...@@ -372,7 +372,7 @@ impl ServerActionsGraph {
let actions = data let actions = data
.iter() .iter()
.map(|(module, (layer, actions))| async move { .map(async |(module, (layer, actions))| {
let actions = actions.await?; let actions = actions.await?;
actions actions
.actions .actions
......
...@@ -124,7 +124,7 @@ impl VersionedContentMap { ...@@ -124,7 +124,7 @@ impl VersionedContentMap {
let rel = root.get_path_to(&path)?; let rel = root.get_path_to(&path)?;
Some((RcStr::from(rel), path)) Some((RcStr::from(rel), path))
}) })
.map(|(name, path)| async move { .map(async |(name, path)| {
// Skip Redirect assets: they're symlinks with no file content, // Skip Redirect assets: they're symlinks with no file content,
// so versioning them would bail with "not a file". // so versioning them would bail with "not a file".
let Some(asset) = *self.get_asset(path).await? else { let Some(asset) = *self.get_asset(path).await? else {
...@@ -337,7 +337,7 @@ async fn get_entries(assets: OperationVc<ExpandedOutputAssets>) -> Result<Vc<Get ...@@ -337,7 +337,7 @@ async fn get_entries(assets: OperationVc<ExpandedOutputAssets>) -> Result<Vc<Get
let assets_ref = assets.connect().await?; let assets_ref = assets.connect().await?;
let entries = assets_ref let entries = assets_ref
.iter() .iter()
.map(|&asset| async move { .map(async |&asset| {
let path = asset.path().owned().await?; let path = asset.path().owned().await?;
Ok((path, asset)) Ok((path, asset))
}) })
......
...@@ -192,7 +192,7 @@ pub async fn get_app_client_references_chunks( ...@@ -192,7 +192,7 @@ pub async fn get_app_client_references_chunks(
let ssr_modules = client_reference_types let ssr_modules = client_reference_types
.iter() .iter()
.map(|client_reference_ty| async move { .map(async |client_reference_ty| {
Ok(match client_reference_ty { Ok(match client_reference_ty {
ClientReferenceType::EcmascriptClientReference( ClientReferenceType::EcmascriptClientReference(
ecmascript_client_reference, ecmascript_client_reference,
...@@ -241,7 +241,7 @@ pub async fn get_app_client_references_chunks( ...@@ -241,7 +241,7 @@ pub async fn get_app_client_references_chunks(
let client_modules = client_reference_types let client_modules = client_reference_types
.iter() .iter()
.map(|client_reference_ty| async move { .map(async |client_reference_ty| {
Ok(match client_reference_ty { Ok(match client_reference_ty {
ClientReferenceType::EcmascriptClientReference( ClientReferenceType::EcmascriptClientReference(
ecmascript_client_reference, ecmascript_client_reference,
...@@ -351,7 +351,7 @@ pub async fn get_client_references_chunks_for_hmr( ...@@ -351,7 +351,7 @@ pub async fn get_client_references_chunks_for_hmr(
let mut extras: FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>> = client_references_chunks_ref let mut extras: FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>> = client_references_chunks_ref
.layout_segment_client_chunks .layout_segment_client_chunks
.values() .values()
.map(|&assets| async move { .map(async |&assets| {
let primary = assets.primary_assets().await?; let primary = assets.primary_assets().await?;
Ok(primary.iter().copied().collect::<Vec<_>>()) Ok(primary.iter().copied().collect::<Vec<_>>())
}) })
......
...@@ -241,12 +241,12 @@ async fn get_pages_structure_for_root_directory( ...@@ -241,12 +241,12 @@ async fn get_pages_structure_for_root_directory(
next_router_path: next_router_path.clone(), next_router_path: next_router_path.clone(),
items: items items: items
.into_iter() .into_iter()
.map(|(_, v)| async move { v.to_resolved().await }) .map(|(_, v)| v.to_resolved())
.try_join() .try_join()
.await?, .await?,
children: children children: children
.into_iter() .into_iter()
.map(|(_, v)| async move { v.to_resolved().await }) .map(|(_, v)| v.to_resolved())
.try_join() .try_join()
.await?, .await?,
} }
...@@ -386,13 +386,13 @@ async fn get_pages_structure_for_directory( ...@@ -386,13 +386,13 @@ async fn get_pages_structure_for_directory(
items: items items: items
.into_iter() .into_iter()
.map(|(_, v)| v) .map(|(_, v)| v)
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?, .await?,
children: children children: children
.into_iter() .into_iter()
.map(|(_, v)| v) .map(|(_, v)| v)
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?, .await?,
} }
......
...@@ -1361,9 +1361,7 @@ async fn parse_segment_config_from_loader_tree_internal( ...@@ -1361,9 +1361,7 @@ async fn parse_segment_config_from_loader_tree_internal(
let parallel_configs = loader_tree let parallel_configs = loader_tree
.parallel_routes .parallel_routes
.values() .values()
.map(|loader_tree| async move { .map(|loader_tree| Box::pin(parse_segment_config_from_loader_tree_internal(loader_tree)))
Box::pin(parse_segment_config_from_loader_tree_internal(loader_tree)).await
})
.try_join() .try_join()
.await?; .await?;
......
...@@ -1684,7 +1684,7 @@ async fn output_assets_operation( ...@@ -1684,7 +1684,7 @@ async fn output_assets_operation(
let endpoint_assets = endpoints let endpoint_assets = endpoints
.iter() .iter()
.map(|endpoint| async move { endpoint.output().await?.output_assets.await }) .map(async |endpoint| endpoint.output().await?.output_assets.await)
.try_join() .try_join()
.await?; .await?;
......
...@@ -22,7 +22,7 @@ static REGISTRATION: Registration = register!(); ...@@ -22,7 +22,7 @@ static REGISTRATION: Registration = register!();
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn split_chunk() { async fn split_chunk() {
run_once(&REGISTRATION, || async { run_once(&REGISTRATION, async || {
let mut code = CodeBuilder::new(true, false); let mut code = CodeBuilder::new(true, false);
code += "Hello world!\n"; code += "Hello world!\n";
code += "This is a test file.\n"; code += "This is a test file.\n";
......
...@@ -88,7 +88,7 @@ fn bench_startup_internal( ...@@ -88,7 +88,7 @@ fn bench_startup_internal(
|b, &(bundler, test_app)| { |b, &(bundler, test_app)| {
let test_app = &**test_app; let test_app = &**test_app;
let browser = &*browser; let browser = &*browser;
b.to_async(&runtime).try_iter_custom(|iters, m| async move { b.to_async(&runtime).try_iter_custom(async |iters, m| {
let mut value = m.zero(); let mut value = m.zero();
for _ in 0..iters { for _ in 0..iters {
...@@ -183,7 +183,7 @@ fn bench_hmr_internal( ...@@ -183,7 +183,7 @@ fn bench_hmr_internal(
b.to_async(&runtime).try_iter_async( b.to_async(&runtime).try_iter_async(
&runtime, &runtime,
|| async { async || {
let mut app = PreparedApp::new_without_copy( let mut app = PreparedApp::new_without_copy(
bundler, bundler,
test_app.path().to_path_buf(), test_app.path().to_path_buf(),
...@@ -318,7 +318,7 @@ fn bench_hmr_internal( ...@@ -318,7 +318,7 @@ fn bench_hmr_internal(
Ok((guard, value)) Ok((guard, value))
} }
}, },
|guard| async move { async |guard| {
let hmr_is_happening = guard let hmr_is_happening = guard
.page() .page()
.evaluate_expression("globalThis.HMR_IS_HAPPENING") .evaluate_expression("globalThis.HMR_IS_HAPPENING")
...@@ -484,7 +484,7 @@ fn bench_startup_cached_internal( ...@@ -484,7 +484,7 @@ fn bench_startup_cached_internal(
|b, &(bundler, test_app)| { |b, &(bundler, test_app)| {
let test_app = &**test_app; let test_app = &**test_app;
let browser = &*browser; let browser = &*browser;
b.to_async(&runtime).try_iter_custom(|iters, m| async move { b.to_async(&runtime).try_iter_custom(async |iters, m| {
// Run a complete build, shut down, and test running it again // Run a complete build, shut down, and test running it again
let mut app = let mut app =
PreparedApp::new(bundler, test_app.path().to_path_buf()).await?; PreparedApp::new(bundler, test_app.path().to_path_buf()).await?;
......
...@@ -164,7 +164,7 @@ impl<A: AsyncExecutor> AsyncBencherExtension<A> for AsyncBencher<'_, '_, A> { ...@@ -164,7 +164,7 @@ impl<A: AsyncExecutor> AsyncBencherExtension<A> for AsyncBencher<'_, '_, A> {
let log_progress = read_env_bool("TURBOPACK_BENCH_PROGRESS"); let log_progress = read_env_bool("TURBOPACK_BENCH_PROGRESS");
let routine = &routine; let routine = &routine;
self.iter_custom(|iters| async move { self.iter_custom(async |iters| {
let measurement = WallTime; let measurement = WallTime;
let value = routine(iters, measurement).await.expect("routine failed"); let value = routine(iters, measurement).await.expect("routine failed");
if log_progress { if log_progress {
...@@ -208,7 +208,7 @@ impl<A: AsyncExecutor> AsyncBencherExtension<A> for AsyncBencher<'_, '_, A> { ...@@ -208,7 +208,7 @@ impl<A: AsyncExecutor> AsyncBencherExtension<A> for AsyncBencher<'_, '_, A> {
input input
})))); }))));
self.iter_custom(|iters| async move { self.iter_custom(async |iters| {
let measurement = WallTime; let measurement = WallTime;
let input = input_mutex let input = input_mutex
......
...@@ -262,27 +262,20 @@ async fn build_internal( ...@@ -262,27 +262,20 @@ async fn build_internal(
source_maps_type, source_maps_type,
); );
let entry_requests = (*entry_requests let entry_requests = entry_requests.into_iter().map(|r| match r {
.into_iter() EntryRequest::Relative(p) => Request::relative(
.map(|r| async move { p.clone().into(),
Ok(match r { Default::default(),
EntryRequest::Relative(p) => Request::relative( Default::default(),
p.clone().into(), false,
Default::default(), ),
Default::default(), EntryRequest::Module(m, p) => Request::module(
false, m.clone().into(),
), p.clone().into(),
EntryRequest::Module(m, p) => Request::module( Default::default(),
m.clone().into(), Default::default(),
p.clone().into(), ),
Default::default(), });
Default::default(),
),
})
})
.try_join()
.await?)
.to_vec();
let origin = let origin =
PlainResolveOrigin::new(asset_context, project_fs.root().await?.join("_")?).await?; PlainResolveOrigin::new(asset_context, project_fs.root().await?.join("_")?).await?;
...@@ -292,7 +285,6 @@ async fn build_internal( ...@@ -292,7 +285,6 @@ async fn build_internal(
let project_dir = &project_dir; let project_dir = &project_dir;
let entries = async move { let entries = async move {
entry_requests entry_requests
.into_iter()
.map(|request_vc| { .map(|request_vc| {
let origin_path = origin_path.clone(); let origin_path = origin_path.clone();
async move { async move {
...@@ -524,7 +516,7 @@ async fn build_internal( ...@@ -524,7 +516,7 @@ async fn build_internal(
all_assets all_assets
.iter() .iter()
.map(|c| async move { c.content().write(c.path().owned().await?).await }) .map(async |c| c.content().write(c.path().owned().await?).await)
.try_join() .try_join()
.await?; .await?;
......
...@@ -183,7 +183,7 @@ pub async fn create_web_entry_source( ...@@ -183,7 +183,7 @@ pub async fn create_web_entry_source(
let entries: Vec<_> = entries let entries: Vec<_> = entries
.into_iter() .into_iter()
.map(|module| async move { .map(async |module| {
if let (Some(chunkable_module), Some(entry)) = ( if let (Some(chunkable_module), Some(entry)) = (
ResolvedVc::try_sidecast::<Box<dyn ChunkableModule>>(module), ResolvedVc::try_sidecast::<Box<dyn ChunkableModule>>(module),
ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(module), ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(module),
......
...@@ -768,7 +768,7 @@ pub type PlainTrace = Vec<PlainTraceItem>; ...@@ -768,7 +768,7 @@ pub type PlainTrace = Vec<PlainTraceItem>;
async fn into_plain_trace(traces: Vec<Vec<ReadRef<AssetIdent>>>) -> Result<Vec<PlainTrace>> { async fn into_plain_trace(traces: Vec<Vec<ReadRef<AssetIdent>>>) -> Result<Vec<PlainTrace>> {
let mut plain_traces = traces let mut plain_traces = traces
.into_iter() .into_iter()
.map(|trace| async move { .map(async |trace| {
let mut plain_trace = trace let mut plain_trace = trace
.into_iter() .into_iter()
.filter(|asset| { .filter(|asset| {
......
...@@ -683,7 +683,7 @@ impl ModuleGraphImportTracer { ...@@ -683,7 +683,7 @@ impl ModuleGraphImportTracer {
.await? .await?
.modules .modules
.iter() .iter()
.map(|(&module, _)| async move { Ok((module.ident().await?.path.clone(), module)) }) .map(async |(&module, _)| Ok((module.ident().await?.path.clone(), module)))
.try_join() .try_join()
.await?; .await?;
let mut map: FxHashMap<FileSystemPath, Vec<ResolvedVc<Box<dyn Module>>>> = let mut map: FxHashMap<FileSystemPath, Vec<ResolvedVc<Box<dyn Module>>>> =
...@@ -711,7 +711,7 @@ impl ImportTracer for ModuleGraphImportTracer { ...@@ -711,7 +711,7 @@ impl ImportTracer for ModuleGraphImportTracer {
return Ok(ImportTraces::cell(ImportTraces( return Ok(ImportTraces::cell(ImportTraces(
modules modules
.iter() .iter()
.map(|m| async move { .map(async |m| {
let Some(&module_idx) = graph.modules.get(m) else { let Some(&module_idx) = graph.modules.get(m) else {
// The only way this could really happen is if `path_to_modules` is computed // The only way this could really happen is if `path_to_modules` is computed
// from a different graph than graph`. Just error out. // from a different graph than graph`. Just error out.
...@@ -2344,7 +2344,7 @@ pub mod tests { ...@@ -2344,7 +2344,7 @@ pub mod tests {
// test traversing backwards from 'd' which is only in the child graph // test traversing backwards from 'd' which is only in the child graph
let d_module = child_graph let d_module = child_graph
.enumerate_nodes() .enumerate_nodes()
.map(|(_index, module)| async move { .map(async |(_index, module)| {
Ok(match module { Ok(match module {
crate::module_graph::SingleModuleGraphNode::Module(module) => { crate::module_graph::SingleModuleGraphNode::Module(module) => {
if module.ident().to_string().owned().await? == "[test]/d.js" { if module.ident().to_string().owned().await? == "[test]/d.js" {
...@@ -2854,7 +2854,7 @@ pub mod tests { ...@@ -2854,7 +2854,7 @@ pub mod tests {
.await? .await?
.modules .modules
.keys() .keys()
.map(|m| async move { Ok((*m, m.ident().await?.path.path.clone())) }) .map(async |m| Ok((*m, m.ident().await?.path.path.clone())))
.try_join() .try_join()
.await? .await?
.into_iter() .into_iter()
......
...@@ -131,7 +131,7 @@ pub async fn referenced_modules_and_affecting_sources( ...@@ -131,7 +131,7 @@ pub async fn referenced_modules_and_affecting_sources(
.references() .references()
.await? .await?
.iter() .iter()
.map(|reference| async { .map(async |reference| {
let trait_ref = reference.into_trait_ref().await?; let trait_ref = reference.into_trait_ref().await?;
let resolve_result = reference.resolve_reference().await?; let resolve_result = reference.resolve_reference().await?;
if let Some(chunking_type) = &trait_ref.chunking_type() { if let Some(chunking_type) = &trait_ref.chunking_type() {
...@@ -141,7 +141,7 @@ pub async fn referenced_modules_and_affecting_sources( ...@@ -141,7 +141,7 @@ pub async fn referenced_modules_and_affecting_sources(
modules.extend( modules.extend(
resolve_result resolve_result
.affecting_sources_iter() .affecting_sources_iter()
.map(|source| async move { .map(async |source| {
Ok(ResolvedVc::upcast( Ok(ResolvedVc::upcast(
RawModule::new(*source).to_resolved().await?, RawModule::new(*source).to_resolved().await?,
)) ))
...@@ -211,7 +211,7 @@ pub async fn primary_referenced_modules(module: Vc<Box<dyn Module>>) -> Result<V ...@@ -211,7 +211,7 @@ pub async fn primary_referenced_modules(module: Vc<Box<dyn Module>>) -> Result<V
.references() .references()
.await? .await?
.iter() .iter()
.map(|reference| async { reference.resolve_reference().await?.primary_modules().await }) .map(async |reference| reference.resolve_reference().await?.primary_modules().await)
.try_join() .try_join()
.await? .await?
.into_iter() .into_iter()
...@@ -246,7 +246,7 @@ pub async fn primary_chunkable_referenced_modules( ...@@ -246,7 +246,7 @@ pub async fn primary_chunkable_referenced_modules(
.references() .references()
.await? .await?
.iter() .iter()
.map(|reference| async { .map(async |reference| {
let trait_ref = reference.into_trait_ref().await?; let trait_ref = reference.into_trait_ref().await?;
if let Some(chunking_type) = &trait_ref.chunking_type() { if let Some(chunking_type) = &trait_ref.chunking_type() {
if !include_traced && chunking_type.is_traced() { if !include_traced && chunking_type.is_traced() {
......
...@@ -890,7 +890,7 @@ impl ResolveResult { ...@@ -890,7 +890,7 @@ impl ResolveResult {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn as_raw_module_result(&self) -> Result<Vc<ModuleResolveResult>> { pub async fn as_raw_module_result(&self) -> Result<Vc<ModuleResolveResult>> {
Ok(self Ok(self
.map_module(|asset| async move { .map_module(async |asset| {
Ok(ModuleResolveResultItem::Module(ResolvedVc::upcast( Ok(ModuleResolveResultItem::Module(ResolvedVc::upcast(
RawModule::new(*asset).to_resolved().await?, RawModule::new(*asset).to_resolved().await?,
))) )))
...@@ -1138,7 +1138,7 @@ async fn realpath( ...@@ -1138,7 +1138,7 @@ async fn realpath(
result result
.symlinks .symlinks
.iter() .iter()
.map(|path| async move { .map(async |path| {
Ok(ResolvedVc::upcast( Ok(ResolvedVc::upcast(
FileSource::new(path.clone()).to_resolved().await?, FileSource::new(path.clone()).to_resolved().await?,
)) ))
...@@ -1540,7 +1540,7 @@ pub async fn resolve_raw( ...@@ -1540,7 +1540,7 @@ pub async fn resolve_raw(
) -> Result<Vec<Vc<ResolveResult>>> { ) -> Result<Vec<Vc<ResolveResult>>> {
Ok(matches Ok(matches
.iter() .iter()
.map(|m| async move { .map(async |m| {
Ok(if let PatternMatch::File(request, path) = m { Ok(if let PatternMatch::File(request, path) = m {
Some(to_result(request.clone(), path, collect_affecting_sources).await?) Some(to_result(request.clone(), path, collect_affecting_sources).await?)
} else { } else {
...@@ -1930,9 +1930,7 @@ async fn resolve_internal_inline( ...@@ -1930,9 +1930,7 @@ async fn resolve_internal_inline(
Request::Alternatives { requests } => { Request::Alternatives { requests } => {
let results = requests let results = requests
.iter() .iter()
.map(|req| async { .map(|req| resolve_internal_inline(lookup_path.clone(), **req, options))
resolve_internal_inline(lookup_path.clone(), **req, options).await
})
.try_join() .try_join()
.await?; .await?;
...@@ -3169,7 +3167,7 @@ async fn resolved( ...@@ -3169,7 +3167,7 @@ async fn resolved(
result result
.symlinks .symlinks
.iter() .iter()
.map(|symlink| async move { .map(async |symlink| {
anyhow::Ok(ResolvedVc::upcast( anyhow::Ok(ResolvedVc::upcast(
FileSource::new(symlink.clone()).to_resolved().await?, FileSource::new(symlink.clone()).to_resolved().await?,
)) ))
......
...@@ -440,7 +440,7 @@ impl Request { ...@@ -440,7 +440,7 @@ impl Request {
.copied() .copied()
.map(|v| *v) .map(|v| *v)
.map(Request::as_relative) .map(Request::as_relative)
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?; .await?;
Request::Alternatives { requests }.cell() Request::Alternatives { requests }.cell()
...@@ -500,7 +500,7 @@ impl Request { ...@@ -500,7 +500,7 @@ impl Request {
.iter() .iter()
.copied() .copied()
.map(|req| req.with_query(query.clone())) .map(|req| req.with_query(query.clone()))
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?; .await?;
Request::Alternatives { requests }.cell() Request::Alternatives { requests }.cell()
...@@ -578,7 +578,7 @@ impl Request { ...@@ -578,7 +578,7 @@ impl Request {
.iter() .iter()
.copied() .copied()
.map(|req| req.with_fragment(fragment.clone())) .map(|req| req.with_fragment(fragment.clone()))
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?; .await?;
Request::Alternatives { requests }.cell() Request::Alternatives { requests }.cell()
...@@ -690,7 +690,7 @@ impl Request { ...@@ -690,7 +690,7 @@ impl Request {
Request::Alternatives { requests } => { Request::Alternatives { requests } => {
let requests = requests let requests = requests
.iter() .iter()
.map(|req| async { req.append_path(suffix.clone()).to_resolved().await }) .map(|req| req.append_path(suffix.clone()).to_resolved())
.try_join() .try_join()
.await?; .await?;
Request::Alternatives { requests }.cell() Request::Alternatives { requests }.cell()
......
...@@ -190,7 +190,7 @@ impl CssChunk { ...@@ -190,7 +190,7 @@ impl CssChunk {
} }
let assets = chunk_items let assets = chunk_items
.iter() .iter()
.map(|chunk_item| async move { .map(async |chunk_item| {
Ok(( Ok((
rcstr!("chunk item"), rcstr!("chunk item"),
chunk_item.content_ident().to_resolved().await?, chunk_item.content_ident().to_resolved().await?,
...@@ -257,7 +257,7 @@ impl OutputAssetsReference for CssChunk { ...@@ -257,7 +257,7 @@ impl OutputAssetsReference for CssChunk {
let references = content let references = content
.chunk_items .chunk_items
.iter() .iter()
.map(|item| async { .map(async |item| {
let refs = item.references().await?; let refs = item.references().await?;
let single_css_chunk = if should_generate_single_item_chunks { let single_css_chunk = if should_generate_single_item_chunks {
Some(ResolvedVc::upcast( Some(ResolvedVc::upcast(
...@@ -353,7 +353,7 @@ impl OutputChunk for CssChunk { ...@@ -353,7 +353,7 @@ impl OutputChunk for CssChunk {
.await?; .await?;
let imports_chunk_items: Vec<_> = entries_chunk_items let imports_chunk_items: Vec<_> = entries_chunk_items
.iter() .iter()
.map(|&css_item| async move { .map(async |&css_item| {
Ok(css_item Ok(css_item
.content() .content()
.await? .await?
...@@ -498,7 +498,7 @@ impl Introspectable for CssChunk { ...@@ -498,7 +498,7 @@ impl Introspectable for CssChunk {
.await? .await?
.chunk_items .chunk_items
.iter() .iter()
.map(|chunk_item| async move { .map(async |chunk_item| {
Ok(( Ok((
rcstr!("entry module"), rcstr!("entry module"),
IntrospectableModule::new(chunk_item.module()) IntrospectableModule::new(chunk_item.module())
......
...@@ -131,7 +131,7 @@ impl DevHtmlAsset { ...@@ -131,7 +131,7 @@ impl DevHtmlAsset {
let all_chunk_groups = self let all_chunk_groups = self
.entries .entries
.iter() .iter()
.map(|entry| async move { .map(async |entry| {
let &DevHtmlEntry { let &DevHtmlEntry {
chunkable_module, chunkable_module,
chunking_context, chunking_context,
......
...@@ -135,7 +135,7 @@ impl GetContentSourceContent for IntrospectionSource { ...@@ -135,7 +135,7 @@ impl GetContentSourceContent for IntrospectionSource {
let has_children = !children.is_empty(); let has_children = !children.is_empty();
let children = children let children = children
.iter() .iter()
.map(|(name, child)| async move { .map(async |(name, child)| {
let ty = child.ty().await; let ty = child.ty().await;
let ty = str_or_err(&ty); let ty = str_or_err(&ty);
let title = child.title().await; let title = child.title().await;
......
...@@ -89,7 +89,7 @@ async fn expand( ...@@ -89,7 +89,7 @@ async fn expand(
let mut assets_set = FxHashSet::default(); let mut assets_set = FxHashSet::default();
let root_assets_with_path = root_assets let root_assets_with_path = root_assets
.iter() .iter()
.map(|&asset| async move { .map(async |&asset| {
let path = asset.path().await?; let path = asset.path().await?;
Ok((path, asset)) Ok((path, asset))
}) })
...@@ -220,7 +220,7 @@ impl ContentSource for AssetGraphContentSource { ...@@ -220,7 +220,7 @@ impl ContentSource for AssetGraphContentSource {
)), )),
) )
}) })
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?; .await?;
Ok(Vc::<RouteTrees>::cell(routes).merge()) Ok(Vc::<RouteTrees>::cell(routes).merge())
...@@ -307,7 +307,7 @@ impl Introspectable for AssetGraphContentSource { ...@@ -307,7 +307,7 @@ impl Introspectable for AssetGraphContentSource {
let root_assets = this.root_assets.await?; let root_assets = this.root_assets.await?;
let root_asset_children = root_assets let root_asset_children = root_assets
.iter() .iter()
.map(|&asset| async move { .map(async |&asset| {
Ok(( Ok((
rcstr!("root"), rcstr!("root"),
IntrospectableOutputAsset::new(*asset).to_resolved().await?, IntrospectableOutputAsset::new(*asset).to_resolved().await?,
...@@ -320,7 +320,7 @@ impl Introspectable for AssetGraphContentSource { ...@@ -320,7 +320,7 @@ impl Introspectable for AssetGraphContentSource {
let expanded_asset_children = expanded_assets let expanded_asset_children = expanded_assets
.values() .values()
.filter(|&a| !root_assets.contains(a)) .filter(|&a| !root_assets.contains(a))
.map(|&asset| async move { .map(async |&asset| {
Ok(( Ok((
rcstr!("inner"), rcstr!("inner"),
IntrospectableOutputAsset::new(*asset).to_resolved().await?, IntrospectableOutputAsset::new(*asset).to_resolved().await?,
...@@ -364,7 +364,7 @@ impl Introspectable for FullyExpanded { ...@@ -364,7 +364,7 @@ impl Introspectable for FullyExpanded {
let expanded_assets = expand(&*source.root_assets.await?, &source.root_path, None).await?; let expanded_assets = expand(&*source.root_assets.await?, &source.root_path, None).await?;
let children = expanded_assets let children = expanded_assets
.iter() .iter()
.map(|(_k, &v)| async move { .map(async |(_k, &v)| {
Ok(( Ok((
rcstr!("asset"), rcstr!("asset"),
IntrospectableOutputAsset::new(*v).to_resolved().await?, IntrospectableOutputAsset::new(*v).to_resolved().await?,
......
...@@ -27,7 +27,7 @@ impl ContentSource for CombinedContentSource { ...@@ -27,7 +27,7 @@ impl ContentSource for CombinedContentSource {
let all_routes = self let all_routes = self
.sources .sources
.iter() .iter()
.map(|s| async move { s.get_routes().to_resolved().await }) .map(|s| s.get_routes().to_resolved())
.try_join() .try_join()
.await?; .await?;
Ok(Vc::<RouteTrees>::cell(all_routes).merge()) Ok(Vc::<RouteTrees>::cell(all_routes).merge())
...@@ -51,7 +51,7 @@ impl Introspectable for CombinedContentSource { ...@@ -51,7 +51,7 @@ impl Introspectable for CombinedContentSource {
let titles = self let titles = self
.sources .sources
.iter() .iter()
.map(|&source| async move { .map(async |&source| {
Ok( Ok(
if let Some(source) = if let Some(source) =
ResolvedVc::try_sidecast::<Box<dyn Introspectable>>(source) ResolvedVc::try_sidecast::<Box<dyn Introspectable>>(source)
...@@ -85,11 +85,7 @@ impl Introspectable for CombinedContentSource { ...@@ -85,11 +85,7 @@ impl Introspectable for CombinedContentSource {
self.sources self.sources
.iter() .iter()
.copied() .copied()
.map(|s| async move { Ok(ResolvedVc::try_sidecast::<Box<dyn Introspectable>>(s)) }) .flat_map(ResolvedVc::try_sidecast::<Box<dyn Introspectable>>)
.try_join()
.await?
.into_iter()
.flatten()
.map(|i| (rcstr!("source"), i)) .map(|i| (rcstr!("source"), i))
.collect(), .collect(),
)) ))
......
...@@ -168,7 +168,7 @@ impl RouteTree { ...@@ -168,7 +168,7 @@ impl RouteTree {
self.static_segments.extend( self.static_segments.extend(
static_segments static_segments
.into_iter() .into_iter()
.map(|(key, value)| async { .map(async |(key, value)| {
Ok(( Ok((
key, key,
if value.len() == 1 { if value.len() == 1 {
......
...@@ -105,7 +105,7 @@ impl ContentSource for PrefixedRouterContentSource { ...@@ -105,7 +105,7 @@ impl ContentSource for PrefixedRouterContentSource {
Ok(Vc::<RouteTrees>::cell( Ok(Vc::<RouteTrees>::cell(
inner_trees inner_trees
.chain(once(self.fallback.get_routes())) .chain(once(self.fallback.get_routes()))
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?, .await?,
) )
......
...@@ -66,7 +66,7 @@ async fn get_routes_from_directory(dir: FileSystemPath) -> Result<Vc<RouteTree>> ...@@ -66,7 +66,7 @@ async fn get_routes_from_directory(dir: FileSystemPath) -> Result<Vc<RouteTree>>
), ),
_ => None, _ => None,
}) })
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?; .await?;
Ok(Vc::<RouteTrees>::cell(routes).merge()) Ok(Vc::<RouteTrees>::cell(routes).merge())
......
...@@ -54,7 +54,7 @@ async fn wrap_sources_operation( ...@@ -54,7 +54,7 @@ async fn wrap_sources_operation(
**s, *processor, **s, *processor,
)) ))
}) })
.map(|v| async move { v.to_resolved().await }) .map(|v| v.to_resolved())
.try_join() .try_join()
.await?, .await?,
)) ))
......
...@@ -145,7 +145,7 @@ fn bench_full(b: &mut Bencher, input: &BenchInput) { ...@@ -145,7 +145,7 @@ fn bench_full(b: &mut Bencher, input: &BenchInput) {
}); });
(tt, module) (tt, module)
}, },
|(tt, module)| async move { async |(tt, module)| {
tt.run_once(async move { tt.run_once(async move {
// `analyze_ecmascript_module` performs eventually-consistent Vc reads. Reading // `analyze_ecmascript_module` performs eventually-consistent Vc reads. Reading
// not-yet-settled state at the top level is fine for a throughput benchmark, but // not-yet-settled state at the top level is fine for a throughput benchmark, but
......
...@@ -62,7 +62,7 @@ pub async fn item_code_module_ids_and_paths( ...@@ -62,7 +62,7 @@ pub async fn item_code_module_ids_and_paths(
.await? .await?
.chunk_items .chunk_items
.iter() .iter()
.map(|item| async { .map(async |item| {
Ok(( Ok((
item.chunk_item.id().await?, item.chunk_item.id().await?,
item.chunk_item item.chunk_item
......
...@@ -71,7 +71,7 @@ impl EcmascriptChunkContentEntries { ...@@ -71,7 +71,7 @@ impl EcmascriptChunkContentEntries {
batch batch
.chunk_items .chunk_items
.iter() .iter()
.map(|item| async move { .map(async |item| {
Ok(( Ok((
item.chunk_item.id().await?, item.chunk_item.id().await?,
EcmascriptChunkContentEntry::new( EcmascriptChunkContentEntry::new(
......
...@@ -150,7 +150,7 @@ impl Chunk for EcmascriptChunk { ...@@ -150,7 +150,7 @@ impl Chunk for EcmascriptChunk {
let assets = chunk_items let assets = chunk_items
.iter() .iter()
.map(|&chunk_item| async move { .map(async |&chunk_item| {
Ok(( Ok((
rcstr!("chunk item"), rcstr!("chunk item"),
chunk_item.content_ident().to_resolved().await?, chunk_item.content_ident().to_resolved().await?,
......
...@@ -124,7 +124,7 @@ async fn side_effects_from_package_json( ...@@ -124,7 +124,7 @@ async fn side_effects_from_package_json(
}) })
} }
}) })
.map(|glob| async move { .map(async |glob| {
Ok(match glob { Ok(match glob {
Either::Left(glob) => { Either::Left(glob) => {
match glob.to_resolved().await { match glob.to_resolved().await {
......
...@@ -38,7 +38,7 @@ impl Version for ChunkListVersion { ...@@ -38,7 +38,7 @@ impl Version for ChunkListVersion {
.by_path .by_path
.iter() .iter()
.map(|(path, version)| (path, TraitRef::cell(version.clone()))) .map(|(path, version)| (path, TraitRef::cell(version.clone())))
.map(|(path, version)| async move { .map(async |(path, version)| {
let id = version.id().owned().await?; let id = version.id().owned().await?;
Ok((path, id)) Ok((path, id))
}) })
......
...@@ -31,7 +31,7 @@ impl EcmascriptMergedChunkContent { ...@@ -31,7 +31,7 @@ impl EcmascriptMergedChunkContent {
versions: self versions: self
.contents .contents
.iter() .iter()
.map(|content| async move { content.ecmascript_chunk_version().await }) .map(|content| content.ecmascript_chunk_version())
.try_join() .try_join()
.await?, .await?,
} }
......
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc}; use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::version::{VersionedContent, VersionedContentMerger, VersionedContents}; use turbopack_core::version::{VersionedContent, VersionedContentMerger, VersionedContents};
use crate::hmr::{EcmascriptHmrChunkContent, content::EcmascriptMergedChunkContent}; use crate::hmr::{EcmascriptHmrChunkContent, content::EcmascriptMergedChunkContent};
...@@ -28,7 +28,7 @@ impl VersionedContentMerger for EcmascriptChunkContentMerger { ...@@ -28,7 +28,7 @@ impl VersionedContentMerger for EcmascriptChunkContentMerger {
let contents = contents let contents = contents
.await? .await?
.iter() .iter()
.map(|content| async move { .map(|content| {
if let Some(content) = if let Some(content) =
ResolvedVc::try_sidecast::<Box<dyn EcmascriptHmrChunkContent>>(*content) ResolvedVc::try_sidecast::<Box<dyn EcmascriptHmrChunkContent>>(*content)
{ {
...@@ -37,8 +37,7 @@ impl VersionedContentMerger for EcmascriptChunkContentMerger { ...@@ -37,8 +37,7 @@ impl VersionedContentMerger for EcmascriptChunkContentMerger {
bail!("expected Vc<Box<dyn EcmascriptHmrChunkContent>>") bail!("expected Vc<Box<dyn EcmascriptHmrChunkContent>>")
} }
}) })
.try_join() .collect::<Result<Vec<_>>>()?;
.await?;
Ok(Vc::upcast(EcmascriptMergedChunkContent { contents }.cell())) Ok(Vc::upcast(EcmascriptMergedChunkContent { contents }.cell()))
} }
......
...@@ -237,7 +237,7 @@ pub async fn update_ecmascript_merged_chunk( ...@@ -237,7 +237,7 @@ pub async fn update_ecmascript_merged_chunk(
let to_contents = content let to_contents = content
.contents .contents
.iter() .iter()
.map(|content| async move { .map(async |content| {
let entries = content.entries().await?; let entries = content.entries().await?;
let version = content.ecmascript_chunk_version().await?; let version = content.ecmascript_chunk_version().await?;
Ok((*content, entries, version)) Ok((*content, entries, version))
......
...@@ -93,7 +93,7 @@ impl Module for SideEffectsModule { ...@@ -93,7 +93,7 @@ impl Module for SideEffectsModule {
references.extend( references.extend(
self.side_effects self.side_effects
.iter() .iter()
.map(|side_effect| async move { .map(async |side_effect| {
Ok(ResolvedVc::upcast( Ok(ResolvedVc::upcast(
SingleChunkableModuleReference::new( SingleChunkableModuleReference::new(
*ResolvedVc::upcast(*side_effect), *ResolvedVc::upcast(*side_effect),
......
...@@ -158,7 +158,7 @@ impl AmdDefineWithDependenciesCodeGen { ...@@ -158,7 +158,7 @@ impl AmdDefineWithDependenciesCodeGen {
let resolved_elements = self let resolved_elements = self
.dependencies_requests .dependencies_requests
.iter() .iter()
.map(|element| async move { .map(async |element| {
Ok(match element { Ok(match element {
AmdDefineDependencyElement::Request { AmdDefineDependencyElement::Request {
request, request,
......
...@@ -120,7 +120,7 @@ impl AsyncModule { ...@@ -120,7 +120,7 @@ impl AsyncModule {
let reference_idents = references let reference_idents = references
.await? .await?
.iter() .iter()
.map(|r| async { .map(async |r| {
let Some(referenced_asset) = get_inherit_async_referenced_asset(*r).await? else { let Some(referenced_asset) = get_inherit_async_referenced_asset(*r).await? else {
return Ok(None); return Ok(None);
}; };
...@@ -173,7 +173,7 @@ impl AsyncModule { ...@@ -173,7 +173,7 @@ impl AsyncModule {
&& references && references
.await? .await?
.iter() .iter()
.map(|r| async { .map(async |r| {
let Some(referenced_asset) = get_inherit_async_referenced_asset(*r).await? let Some(referenced_asset) = get_inherit_async_referenced_asset(*r).await?
else { else {
return Ok(false); return Ok(false);
......
...@@ -375,7 +375,7 @@ async fn get_all_export_names( ...@@ -375,7 +375,7 @@ async fn get_all_export_names(
let star_export_names = exports let star_export_names = exports
.star_exports .star_exports
.iter() .iter()
.map(|esm_ref| async { .map(async |esm_ref| {
Ok( Ok(
if let ReferencedAsset::Some(m) = if let ReferencedAsset::Some(m) =
ReferencedAsset::from_resolve_result(esm_ref.resolve_reference()).await? ReferencedAsset::from_resolve_result(esm_ref.resolve_reference()).await?
......
...@@ -135,7 +135,7 @@ impl ModuleHotReferenceCodeGen { ...@@ -135,7 +135,7 @@ impl ModuleHotReferenceCodeGen {
let resolved_ids: Vec<ReadRef<PatternMapping>> = self let resolved_ids: Vec<ReadRef<PatternMapping>> = self
.references .references
.iter() .iter()
.map(|reference| async move { .map(async |reference| {
let r = reference.await?; let r = reference.await?;
let resolve_result = reference.resolve_reference(); let resolve_result = reference.resolve_reference();
PatternMapping::resolve_request( PatternMapping::resolve_request(
...@@ -156,7 +156,7 @@ impl ModuleHotReferenceCodeGen { ...@@ -156,7 +156,7 @@ impl ModuleHotReferenceCodeGen {
let esm_reimports: Vec<Option<(String, SyntaxContext, Expr)>> = self let esm_reimports: Vec<Option<(String, SyntaxContext, Expr)>> = self
.esm_references .esm_references
.iter() .iter()
.map(|esm_ref| async move { .map(async |esm_ref| {
let Some(esm_ref) = esm_ref else { let Some(esm_ref) = esm_ref else {
return Ok(None); return Ok(None);
}; };
......
...@@ -1640,17 +1640,14 @@ async fn handle_call<'a, G: Fn(BumpVec<'a, Effect<'a>>) + Send + Sync>( ...@@ -1640,17 +1640,14 @@ async fn handle_call<'a, G: Fn(BumpVec<'a, Effect<'a>>) + Send + Sync>(
let linked_args_cache = OnceCell::new(); let linked_args_cache = OnceCell::new();
// Create the lazy linking closure that will be passed to handle_well_known_function_call // Create the lazy linking closure that will be passed to handle_well_known_function_call
let linked_args = || async { let linked_args = || {
linked_args_cache linked_args_cache.get_or_try_init(|| {
.get_or_try_init(|| async { unlinked_args
unlinked_args .iter()
.iter() .map(|arg| arg.clone_in(state.arena.get_or_default()))
.map(|arg| arg.clone_in(state.arena.get_or_default())) .map(|arg| state.link_value(arg, ImportAttributes::empty_ref()))
.map(|arg| state.link_value(arg, ImportAttributes::empty_ref())) .try_join()
.try_join() })
.await
})
.await
}; };
match func { match func {
...@@ -4014,15 +4011,12 @@ async fn require_resolve_visitor<'a>( ...@@ -4014,15 +4011,12 @@ async fn require_resolve_visitor<'a>(
) )
.to_resolved() .to_resolved()
.await?; .await?;
let mut values = let mut values = resolved
resolved .await?
.await? .primary_sources()
.primary_sources() .map(async |source| Ok(require_resolve(source.ident().await?.path.clone()).into()))
.map(|source| async move { .try_join()
Ok(require_resolve(source.ident().await?.path.clone()).into()) .await?;
})
.try_join()
.await?;
match values.len() { match values.len() {
0 => JsValue::unknown( 0 => JsValue::unknown(
......
...@@ -493,7 +493,7 @@ impl PatternMapping { ...@@ -493,7 +493,7 @@ impl PatternMapping {
.collect(); .collect();
let map = items let map = items
.into_iter() .into_iter()
.map(|(k, v)| async move { .map(async |(k, v)| {
let single_pattern_mapping = to_single_pattern_mapping( let single_pattern_mapping = to_single_pattern_mapping(
origin, origin,
chunking_context, chunking_context,
......
...@@ -62,7 +62,7 @@ impl Module for TsConfigModuleAsset { ...@@ -62,7 +62,7 @@ impl Module for TsConfigModuleAsset {
references.extend( references.extend(
configs[1..] configs[1..]
.iter() .iter()
.map(|(_, config_asset)| async move { .map(async |(_, config_asset)| {
Ok(ResolvedVc::upcast( Ok(ResolvedVc::upcast(
TsExtendsReference::new(**config_asset) TsExtendsReference::new(**config_asset)
.to_resolved() .to_resolved()
......
...@@ -207,7 +207,7 @@ impl ModuleReference for WebpackRuntimeAssetReference { ...@@ -207,7 +207,7 @@ impl ModuleReference for WebpackRuntimeAssetReference {
Ok(resolved Ok(resolved
.await? .await?
.map_module(|source| async move { .map_module(async |source| {
Ok(ModuleResolveResultItem::Module(ResolvedVc::upcast( Ok(ModuleResolveResultItem::Module(ResolvedVc::upcast(
WebpackModuleAsset::new( WebpackModuleAsset::new(
*source, *source,
......
...@@ -382,7 +382,7 @@ pub async fn custom_evaluate(evaluate_context: impl EvaluateContext) -> Result<V ...@@ -382,7 +382,7 @@ pub async fn custom_evaluate(evaluate_context: impl EvaluateContext) -> Result<V
// sending the job. // sending the job.
let (mut operation, _) = FutureRetry::new( let (mut operation, _) = FutureRetry::new(
|| async { async || {
let mut operation = pool.operation().await?; let mut operation = pool.operation().await?;
operation operation
.send(Bytes::from(serde_json::to_vec( .send(Bytes::from(serde_json::to_vec(
......
...@@ -886,15 +886,13 @@ pub struct ChildProcessOperation { ...@@ -886,15 +886,13 @@ pub struct ChildProcessOperation {
impl Operation for ChildProcessOperation { impl Operation for ChildProcessOperation {
async fn recv(&mut self) -> Result<Bytes> { async fn recv(&mut self) -> Result<Bytes> {
let bytes = self let bytes = self
.with_process(|process| async move { .with_process(async |process| process.recv().await.context("failed to receive message"))
process.recv().await.context("failed to receive message")
})
.await?; .await?;
Ok(bytes) Ok(bytes)
} }
async fn send(&mut self, message: Bytes) -> Result<()> { async fn send(&mut self, message: Bytes) -> Result<()> {
self.with_process(|process| async move { self.with_process(async |process| {
timeout(Duration::from_secs(30), process.send(message)) timeout(Duration::from_secs(30), process.send(message))
.await .await
.context("timeout while sending message")? .context("timeout while sending message")?
......
...@@ -233,7 +233,7 @@ async fn extra_configs_changed( ...@@ -233,7 +233,7 @@ async fn extra_configs_changed(
let configs = config_paths let configs = config_paths
.into_iter() .into_iter()
.map(|path| async move { .map(async |path| {
Ok( Ok(
if matches!(&*path.get_type().await?, FileSystemEntryType::File) { if matches!(&*path.get_type().await?, FileSystemEntryType::File) {
match *asset_context match *asset_context
......
...@@ -622,11 +622,11 @@ impl EvaluateContext for WebpackLoaderContext { ...@@ -622,11 +622,11 @@ impl EvaluateContext for WebpackLoaderContext {
.try_join(); .try_join();
let file_subscriptions = file_paths let file_subscriptions = file_paths
.iter() .iter()
.map(|p| async move { self.cwd.join(p)?.read().await }) .map(async |p| self.cwd.join(p)?.read().await)
.try_join(); .try_join();
let directory_subscriptions = directories let directory_subscriptions = directories
.iter() .iter()
.map(|(dir, glob)| async move { .map(async |(dir, glob)| {
self.cwd self.cwd
.join(dir)? .join(dir)?
.track_glob(Glob::new(glob.clone(), GlobOptions::default()), false) .track_glob(Glob::new(glob.clone(), GlobOptions::default()), false)
......
...@@ -204,7 +204,7 @@ async fn resolve_node_pre_gyp_files( ...@@ -204,7 +204,7 @@ async fn resolve_node_pre_gyp_files(
return Ok(*ModuleResolveResult::modules_with_affecting_sources( return Ok(*ModuleResolveResult::modules_with_affecting_sources(
sources sources
.into_iter() .into_iter()
.map(|(key, source)| async move { .map(async |(key, source)| {
Ok(( Ok((
RequestKey::new(key), RequestKey::new(key),
ResolvedVc::upcast(RawModule::new(source).to_resolved().await?), ResolvedVc::upcast(RawModule::new(source).to_resolved().await?),
...@@ -214,9 +214,7 @@ async fn resolve_node_pre_gyp_files( ...@@ -214,9 +214,7 @@ async fn resolve_node_pre_gyp_files(
.await?, .await?,
affecting_paths affecting_paths
.into_iter() .into_iter()
.map(|p| async move { .map(async |p| Ok(ResolvedVc::upcast(FileSource::new(p).to_resolved().await?)))
anyhow::Ok(ResolvedVc::upcast(FileSource::new(p).to_resolved().await?))
})
.try_join() .try_join()
.await?, .await?,
)); ));
...@@ -323,7 +321,7 @@ async fn resolve_node_gyp_build_files( ...@@ -323,7 +321,7 @@ async fn resolve_node_gyp_build_files(
return Ok(*ModuleResolveResult::modules_with_affecting_sources( return Ok(*ModuleResolveResult::modules_with_affecting_sources(
resolved resolved
.into_iter() .into_iter()
.map(|(key, source)| async move { .map(async |(key, source)| {
Ok(( Ok((
RequestKey::new(key), RequestKey::new(key),
ResolvedVc::upcast(RawModule::new(*source).to_resolved().await?), ResolvedVc::upcast(RawModule::new(*source).to_resolved().await?),
...@@ -434,7 +432,7 @@ async fn resolve_node_bindings_files( ...@@ -434,7 +432,7 @@ async fn resolve_node_bindings_files(
root_context_dir = parent; root_context_dir = parent;
} }
let try_path = |sub_path: RcStr| async move { let try_path = async |sub_path: RcStr| {
let path = root_context_dir.join(&sub_path)?; let path = root_context_dir.join(&sub_path)?;
Ok( Ok(
if matches!(*path.get_type().await?, FileSystemEntryType::File) { if matches!(*path.get_type().await?, FileSystemEntryType::File) {
...@@ -454,7 +452,7 @@ async fn resolve_node_bindings_files( ...@@ -454,7 +452,7 @@ async fn resolve_node_bindings_files(
let modules = BINDINGS_TRY let modules = BINDINGS_TRY
.iter() .iter()
.map(|try_dir| try_path.clone()(format!("{}/{}", try_dir, file_name).into())) .map(|try_dir| try_path(format!("{}/{}", try_dir, file_name).into()))
.try_flat_join() .try_flat_join()
.await?; .await?;
Ok(*ModuleResolveResult::modules(modules)) Ok(*ModuleResolveResult::modules(modules))
......
...@@ -187,7 +187,7 @@ async fn diff_paths( ...@@ -187,7 +187,7 @@ async fn diff_paths(
) -> Result<FxHashSet<FileSystemPath>> { ) -> Result<FxHashSet<FileSystemPath>> {
let mut map = left let mut map = left
.iter() .iter()
.map(|p| async move { Ok((p.path.clone(), p.clone())) }) .map(async |p| Ok((p.path.clone(), p.clone())))
.try_join() .try_join()
.await? .await?
.iter() .iter()
......
...@@ -49,7 +49,7 @@ pub async fn get_global_module_id_strategy( ...@@ -49,7 +49,7 @@ pub async fn get_global_module_id_strategy(
.into_iter() .into_iter()
.map(|m| m.ident()) .map(|m| m.ident())
.chain(async_idents.into_iter()) .chain(async_idents.into_iter())
.map(|ident| async move { .map(async |ident| {
let ident = ident.to_resolved().await?; let ident = ident.to_resolved().await?;
let ident_str = ident.to_string().await?; let ident_str = ident.to_string().await?;
let hash = hash_xxh3_hash64(&ident_str); let hash = hash_xxh3_hash64(&ident_str);
......
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