Skip to content

Commit

Permalink
Manual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkirsz committed Jul 15, 2023
1 parent 114b9a7 commit d6edf14
Show file tree
Hide file tree
Showing 229 changed files with 1,885 additions and 1,657 deletions.
14 changes: 0 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ members = [
"crates/turbo-tasks*",
"crates/turbopack*",
"crates/turborepo*",
"crates/turbo-tasks-vc-test",
"xtask",
]

Expand All @@ -28,7 +27,6 @@ default-members = [
"crates/turbo-tasks-signposter-sys",
"crates/turbo-tasks-testing",
"crates/turbo-tasks-tracing-signpost",
"crates/turbo-tasks-vc-test",
"crates/turbopack",
"crates/turbopack-bench",
"crates/turbopack-cli-utils",
Expand Down
54 changes: 28 additions & 26 deletions crates/node-file-trace/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(min_specialization)]
#![feature(arbitrary_self_types)]
#![feature(async_fn_in_trait)]

mod nft_json;

Expand All @@ -22,7 +24,7 @@ use serde::Deserialize;
use serde::Serialize;
use tokio::sync::mpsc::channel;
use turbo_tasks::{
backend::Backend, util::FormatDuration, Nothing, TaskId, TransientInstance, TransientValue,
backend::Backend, unit, util::FormatDuration, TaskId, TransientInstance, TransientValue,
TurboTasks, TurboTasksBackendApi, UpdateInfo, Value, Vc,
};
use turbo_tasks_fs::{
Expand All @@ -34,8 +36,7 @@ use turbo_tasks_memory::{
};
use turbopack::{
emit_asset, emit_with_completion, module_options::ModuleOptionsContext, rebase::RebasedAsset,
resolve_options_context::ResolveOptionsContext, transition::TransitionsByName,
ModuleAssetContext,
resolve_options_context::ResolveOptionsContext, ModuleAssetContext,
};
use turbopack_cli_utils::issue::{ConsoleUi, IssueSeverityCliOption, LogOptions};
use turbopack_core::{
Expand All @@ -44,7 +45,7 @@ use turbopack_core::{
context::AssetContext,
environment::{Environment, ExecutionEnvironment, NodeJsEnvironment},
file_source::FileSource,
issue::{Issue, IssueContextExt, IssueReporter, IssueSeverity},
issue::{IssueContextExt, IssueReporter, IssueSeverity},
reference::all_assets,
resolve::options::{ImportMapping, ResolvedMap},
};
Expand Down Expand Up @@ -200,7 +201,7 @@ async fn create_fs(name: &str, context: &str, watch: bool) -> Result<Vc<Box<dyn
} else {
fs.await?.invalidate();
}
Ok(fs.into())
Ok(Vc::upcast(fs))
}

async fn add_glob_results(
Expand All @@ -212,14 +213,10 @@ async fn add_glob_results(
for entry in result.results.values() {
if let DirectoryEntry::File(path) = entry {
let source = Vc::upcast(FileSource::new(*path));
list.push(
context
.process(
source,
Value::new(turbopack_core::reference_type::ReferenceType::Undefined),
)
.into(),
);
list.push(Vc::upcast(context.process(
source,
Value::new(turbopack_core::reference_type::ReferenceType::Undefined),
)));
}
}
for result in result.inner.values() {
Expand All @@ -237,7 +234,7 @@ async fn add_glob_results(
}

#[turbo_tasks::function]
async fn input_to_modules<'a>(
async fn input_to_modules(
fs: Vc<Box<dyn FileSystem>>,
input: Vec<String>,
exact: bool,
Expand All @@ -251,21 +248,25 @@ async fn input_to_modules<'a>(
.clone()
.map(|p| p.trim_start_matches(&context).to_owned());

let context: Vc<Box<dyn AssetContext>> =
create_module_asset(root, process_cwd, module_options, resolve_options).into();
let context: Vc<Box<dyn AssetContext>> = 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(FileSource::new(root.join(input)));
list.push(
list.push(Vc::upcast(
context
.process(
source,
Value::new(turbopack_core::reference_type::ReferenceType::Undefined),
)
.into(),
);
));
} else {
let glob = Glob::new(input);
add_glob_results(context, root.read_glob(glob, false), &mut list).await?;
Expand Down Expand Up @@ -498,14 +499,15 @@ async fn run<B: Backend + 'static, F: Future<Output = ()>>(
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)
Vc::upcast::<Box<dyn IssueReporter>>(console_ui)
.report_issues(TransientInstance::new(issues), source)
.await?;

Expand All @@ -515,7 +517,7 @@ async fn run<B: Backend + 'static, F: Future<Output = ()>>(
sender.send(output_iter.collect::<Vec<String>>()).await?;
drop(sender);
}
Ok(Nothing::new().into())
Ok(unit().node)
})
});
finish(tt, task).await?;
Expand Down Expand Up @@ -592,7 +594,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 {
Expand Down Expand Up @@ -653,12 +655,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(),
),
];
Expand Down
4 changes: 2 additions & 2 deletions crates/node-file-trace/src/nft_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Asset for NftJsonAsset {
async fn ident(&self) -> Result<Vc<AssetIdent>> {
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)),
))
}

Expand Down Expand Up @@ -59,6 +59,6 @@ impl Asset for NftJsonAsset {
"files": result
});

Ok(File::from(json.to_string()).into())
Ok(AssetContent::file(File::from(json.to_string()).into()))
}
}
2 changes: 1 addition & 1 deletion crates/turbo-tasks-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl<'a> RegisterContext<'a> {

fn process_impl(&mut self, impl_item: ItemImpl) -> Result<()> {
if has_attribute(&impl_item.attrs, "value_impl") {
let struct_ident = get_type_ident(&*impl_item.self_ty).unwrap();
let struct_ident = get_type_ident(&impl_item.self_ty).unwrap();

let trait_ident = impl_item
.trait_
Expand Down
5 changes: 3 additions & 2 deletions crates/turbo-tasks-bytes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#![feature(arbitrary_self_types)]
#![feature(async_fn_in_trait)]

pub mod bytes;
pub mod stream;

use turbo_tasks::Vc;

pub use crate::{
bytes::Bytes,
stream::{Stream, StreamRead},
Expand Down
2 changes: 1 addition & 1 deletion crates/turbo-tasks-env/src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl ProcessEnv for CustomProcessEnv {

#[turbo_tasks::function]
async fn read(&self, name: String) -> Result<Vc<Option<String>>> {
let custom = case_insensitive_read(self.custom, name);
let custom = case_insensitive_read(self.custom, name.clone());
match &*custom.await? {
Some(_) => Ok(custom),
None => Ok(self.prior.read(name)),
Expand Down
5 changes: 3 additions & 2 deletions crates/turbo-tasks-env/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(min_specialization)]
#![feature(arbitrary_self_types)]
#![feature(async_fn_in_trait)]

mod command_line;
mod custom;
Expand Down Expand Up @@ -51,7 +52,7 @@ pub trait ProcessEnv {
fn read_all(self: Vc<Self>) -> Vc<EnvMap>;

/// Reads a single env variable. Ignores casing.
fn read(self: Vc<Self>, name: &str) -> Vc<Option<String>> {
fn read(self: Vc<Self>, name: String) -> Vc<Option<String>> {
case_insensitive_read(self.read_all(), name)
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/turbo-tasks-fetch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(min_specialization)]
#![feature(arbitrary_self_types)]
#![feature(async_fn_in_trait)]

use anyhow::Result;
use turbo_tasks::Vc;
Expand Down
6 changes: 1 addition & 5 deletions crates/turbo-tasks-fetch/tests/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,5 @@ async fn errors_on_404() {
}

fn get_issue_context() -> Vc<FileSystemPath> {
std::convert::Into::<Vc<Box<dyn FileSystem>>>::into(DiskFileSystem::new(
"root".to_owned(),
"/".to_owned(),
))
.root()
DiskFileSystem::new("root".to_owned(), "/".to_owned()).root()
}
9 changes: 4 additions & 5 deletions crates/turbo-tasks-fs/examples/hash_directory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(trivial_bounds)]
#![feature(min_specialization)]

use std::{
collections::BTreeMap,
Expand All @@ -10,7 +9,7 @@ use std::{

use anyhow::Result;
use sha2::{Digest, Sha256};
use turbo_tasks::{util::FormatDuration, Nothing, TurboTasks, UpdateInfo, Vc};
use turbo_tasks::{unit, util::FormatDuration, TurboTasks, UpdateInfo, Vc};
use turbo_tasks_fs::{
register, DirectoryContent, DirectoryEntry, DiskFileSystem, FileContent, FileSystem,
FileSystemPath,
Expand All @@ -35,11 +34,11 @@ async fn main() -> Result<()> {
disk_fs.await?.start_watching()?;

// Smart Pointer cast
let fs: Vc<Box<dyn FileSystem>> = disk_fs.into();
let input = fs.root().join("demo");
let fs: Vc<Box<dyn FileSystem>> = Vc::upcast(disk_fs);
let input = fs.root().join("demo".to_string());
let dir_hash = hash_directory(input);
print_hash(dir_hash).await?;
Ok(Nothing::new().into())
Ok(unit().node)
})
});
tt.wait_task_completion(task, true).await.unwrap();
Expand Down
11 changes: 5 additions & 6 deletions crates/turbo-tasks-fs/examples/hash_glob.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(trivial_bounds)]
#![feature(min_specialization)]

use std::{
collections::BTreeMap,
Expand All @@ -10,7 +9,7 @@ use std::{

use anyhow::Result;
use sha2::{Digest, Sha256};
use turbo_tasks::{util::FormatDuration, Nothing, TurboTasks, UpdateInfo, Vc};
use turbo_tasks::{unit, util::FormatDuration, TurboTasks, UpdateInfo, Vc};
use turbo_tasks_fs::{
glob::Glob, register, DirectoryEntry, DiskFileSystem, FileContent, FileSystem, FileSystemPath,
ReadGlobResult,
Expand All @@ -32,13 +31,13 @@ async fn main() -> Result<()> {
disk_fs.await?.start_watching()?;

// Smart Pointer cast
let fs: Vc<Box<dyn FileSystem>> = disk_fs.into();
let input = fs.root().join("crates");
let glob = Glob::new("**/*.rs");
let fs: Vc<Box<dyn FileSystem>> = Vc::upcast(disk_fs);
let input = fs.root().join("crates".to_string());
let glob = Glob::new("**/*.rs".to_string());
let glob_result = input.read_glob(glob, true);
let dir_hash = hash_glob_result(glob_result);
print_hash(dir_hash).await?;
Ok(Nothing::new().into())
Ok(unit().node)
})
});
tt.wait_task_completion(task, true).await.unwrap();
Expand Down
Loading

0 comments on commit d6edf14

Please sign in to comment.