From cc93003e0439cd09cb20d021be29efdc0c0d1089 Mon Sep 17 00:00:00 2001 From: Alex Kirszenberg Date: Mon, 12 Jun 2023 11:18:24 +0200 Subject: [PATCH] node-file-trace fixes --- crates/node-file-trace/src/lib.rs | 36 ++++++++++++++++---------- crates/node-file-trace/src/nft_json.rs | 4 +-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/crates/node-file-trace/src/lib.rs b/crates/node-file-trace/src/lib.rs index 97da3112d6725..b2059a0d1e672 100644 --- a/crates/node-file-trace/src/lib.rs +++ b/crates/node-file-trace/src/lib.rs @@ -1,4 +1,6 @@ #![feature(min_specialization)] +#![feature(arbitrary_self_types)] +#![feature(async_fn_in_trait)] mod nft_json; @@ -22,8 +24,8 @@ use serde::Deserialize; use serde::Serialize; use tokio::sync::mpsc::channel; use turbo_tasks::{ - backend::Backend, util::FormatDuration, Nothing, TaskId, TransientInstance, TransientValue, - TurboTasks, TurboTasksBackendApi, UpdateInfo, Value, Vc, + backend::Backend, util::FormatDuration, TaskId, TransientInstance, TransientValue, TurboTasks, + TurboTasksBackendApi, UpdateInfo, Value, Vc, }; use turbo_tasks_fs::{ glob::Glob, DirectoryEntry, DiskFileSystem, FileSystem, FileSystemPath, ReadGlobResult, @@ -200,7 +202,7 @@ async fn create_fs(name: &str, context: &str, watch: bool) -> Result( +async fn input_to_modules( fs: Vc>, input: Vec, exact: bool, @@ -247,11 +249,15 @@ async fn input_to_modules<'a>( .clone() .map(|p| p.trim_start_matches(&context).to_owned()); - let context: Vc> = - create_module_asset(root, process_cwd, module_options, resolve_options).into(); + let context: Vc> = Vc::upcast(create_module_asset( + root, + process_cwd, + module_options, + resolve_options, + )); let mut list = Vec::new(); - for input in input.iter() { + for input in input { if exact { let source = Vc::upcast(SourceAsset::new(root.join(input))); list.push(context.process( @@ -490,14 +496,16 @@ async fn run>( resolve_options, ); - let source = TransientValue::new(output.into()); - let issues = Issue::peek_issues_with_path(output) + let source = TransientValue::new(output.node); + let issues = output + .peek_issues_with_path() .await? .strongly_consistent() .await?; let console_ui = ConsoleUi::new(log_options); - Vc::upcast(console_ui).report_issues(TransientInstance::new(issues), source); + Vc::upcast::>(console_ui) + .report_issues(TransientInstance::new(issues), source); if has_return_value { let output_read_ref = output.await?; @@ -505,7 +513,7 @@ async fn run>( sender.send(output_iter.collect::>()).await?; drop(sender); } - Ok(Nothing::new().into()) + Ok(Vc::<()>::cell(()).node) }) }); finish(tt, task).await?; @@ -582,7 +590,7 @@ async fn main_operation( let nft_asset = NftJsonAsset::new(*module); let path = nft_asset.ident().path().await?.path.clone(); output_nft_assets.push(path); - emits.push(emit_asset(nft_asset.into())); + emits.push(emit_asset(Vc::upcast(nft_asset))); } // Wait for all files to be emitted for emit in emits { @@ -646,12 +654,12 @@ async fn create_module_asset( let glob_mappings = vec![ ( root, - Glob::new("**/*/next/dist/server/next.js"), + Glob::new("**/*/next/dist/server/next.js".to_string()), ImportMapping::Ignore.into(), ), ( root, - Glob::new("**/*/next/dist/bin/next"), + Glob::new("**/*/next/dist/bin/next".to_string()), ImportMapping::Ignore.into(), ), ]; diff --git a/crates/node-file-trace/src/nft_json.rs b/crates/node-file-trace/src/nft_json.rs index 15b88906c971a..a85211034902a 100644 --- a/crates/node-file-trace/src/nft_json.rs +++ b/crates/node-file-trace/src/nft_json.rs @@ -27,7 +27,7 @@ impl Asset for NftJsonAsset { async fn ident(&self) -> Result> { let path = self.entry.ident().path().await?; Ok(AssetIdent::from_path( - path.fs.root().join(&format!("{}.nft.json", path.path)), + path.fs.root().join(format!("{}.nft.json", path.path)), )) } @@ -55,6 +55,6 @@ impl Asset for NftJsonAsset { "files": result }); - Ok(File::from(json.to_string()).into()) + Ok(AssetContent::file(File::from(json.to_string()).into())) } }