Unverified Commit 3c301acc authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

Turbopack: Remove FileSystemPath::value_to_string in favor of…

Turbopack: Remove FileSystemPath::value_to_string in favor of ValueToStringRef::to_string_ref (#92284)

`FileSystemPath::value_to_string` was just calling `ValueToString::to_string`.

But:
- It's better to call `ValueToStringRef::to_string_ref`
- We don't really get much value from this inherent method except for avoiding a few imports?

I suspect this is left over from when we used to always wrap `FileSystemPath` in `Vc`.
parent 124c4000
......@@ -7,8 +7,8 @@ use rustc_hash::FxHashMap;
use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{
FxIndexMap, FxIndexSet, NonLocalValue, ResolvedVc, TaskInput, TryJoinIterExt, ValueDefault, Vc,
debug::ValueDebugFormat, fxindexmap, trace::TraceRawVcs, turbobail,
FxIndexMap, FxIndexSet, NonLocalValue, ResolvedVc, TaskInput, TryJoinIterExt, ValueDefault,
ValueToStringRef, Vc, debug::ValueDebugFormat, fxindexmap, trace::TraceRawVcs, turbobail,
};
use turbo_tasks_fs::{DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath};
use turbopack_core::issue::{
......@@ -325,7 +325,7 @@ async fn get_directory_tree(
) -> Result<Vc<DirectoryTree>> {
let span = tracing::info_span!(
"read app directory tree",
name = display(dir.value_to_string().await?)
name = display(dir.to_string_ref().await?)
);
get_directory_tree_internal(dir, page_extensions)
.instrument(span)
......
use anyhow::Result;
use indoc::formatdoc;
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, ResolvedVc, Vc};
use turbo_tasks::{FxIndexMap, ResolvedVc, ValueToStringRef, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack::{ModuleAssetContext, transition::Transition};
use turbopack_core::{
......@@ -118,7 +118,7 @@ impl BaseLoaderTreeBuilder {
// Use the original source path, not the transformed module path.
// This is important for MDX files where page.mdx becomes page.mdx.tsx after
// transformation, but the font manifest uses the original source path.
let module_path = path.value_to_string().await?;
let module_path = path.to_string_ref().await?;
Ok(format!(
"[{identifier}, {path}]",
......
use anyhow::Result;
use tracing::Instrument;
use turbo_tasks::{TryFlatJoinIterExt, Vc};
use turbo_tasks::{TryFlatJoinIterExt, ValueToStringRef, Vc};
use turbo_tasks_fs::{FileSystemPath, rebase};
use turbopack_core::{
asset::Asset,
......@@ -54,7 +54,7 @@ pub async fn emit_assets(
async move {
let path = asset.path().owned().await?;
let span = tracing::info_span!("emit asset", name = %path.value_to_string().await?);
let span = tracing::info_span!("emit asset", name = %path.to_string_ref().await?);
async move {
Ok(if path.is_inside_ref(&node_root) {
Some(emit(*asset).as_side_effect().await?)
......
use anyhow::Result;
use tracing::Instrument;
use turbo_rcstr::rcstr;
use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
use turbo_tasks::{
FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToStringRef, Vc,
};
use turbopack_core::{
chunk::{ChunkGroupResult, ChunkingContext, availability_info::AvailabilityInfo},
module::Module,
......@@ -185,7 +187,7 @@ pub async fn get_app_client_references_chunks(
let server_path = server_component.server_path().owned().await?;
let is_layout = server_path.file_stem() == Some("layout");
let server_component_path = server_path.value_to_string().await?;
let server_component_path = server_path.to_string_ref().await?;
let ssr_modules = client_reference_types
.iter()
......
use anyhow::Result;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, Vc, fxindexmap};
use turbo_tasks::{ResolvedVc, ValueToStringRef, Vc, fxindexmap};
use turbo_tasks_fs::FileSystemPath;
use turbopack::ModuleAssetContext;
use turbopack_core::{
......@@ -80,7 +80,7 @@ pub async fn get_app_route_entry(
("VAR_DEFINITION_FILENAME", path.file_stem().unwrap()),
// TODO(alexkirsz) Is this necessary?
("VAR_DEFINITION_BUNDLE_PATH", ""),
("VAR_RESOLVED_PAGE_PATH", &path.value_to_string().await?),
("VAR_RESOLVED_PAGE_PATH", &path.to_string_ref().await?),
("VAR_USERLAND", &inner),
],
[("nextConfigOutput", output_type)],
......
......@@ -7,7 +7,8 @@ use serde::Serialize;
use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{
FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc,
FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString,
ValueToStringRef, Vc,
};
use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbopack_core::{
......@@ -414,8 +415,7 @@ async fn build_manifest(
.source_path()
.await?
.with_extension("")
.value_to_string()
.owned()
.to_string_ref()
.await?;
let entry_js_files = entry_manifest
.entry_js_files
......
use anyhow::Result;
use tracing::Instrument;
use turbo_rcstr::RcStr;
use turbo_tasks::{OptionVcExt, ResolvedVc, TryJoinIterExt, Vc};
use turbo_tasks::{OptionVcExt, ResolvedVc, TryJoinIterExt, ValueToStringRef, Vc};
use turbo_tasks_fs::{
DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath, FileSystemPathOption,
};
......@@ -327,7 +327,7 @@ async fn get_pages_structure_for_directory(
) -> Result<Vc<PagesDirectoryStructure>> {
let span = tracing::info_span!(
"analyze pages structure",
name = display(project_path.value_to_string().await?)
name = display(project_path.to_string_ref().await?)
);
async move {
let page_extensions_raw = &*page_extensions.await?;
......
......@@ -1406,13 +1406,6 @@ pub struct FileSystemPath {
pub path: RcStr,
}
impl FileSystemPath {
/// Mimics `ValueToString::to_string`.
pub fn value_to_string(&self) -> Vc<RcStr> {
<FileSystemPath as ValueToString>::to_string(self.clone().cell())
}
}
impl ValueToStringRef for FileSystemPath {
async fn to_string_ref(&self) -> Result<RcStr> {
turbofmt!("[{}]/{}", self.fs, self.path).await
......
......@@ -6,7 +6,8 @@ use once_cell::sync::Lazy;
use regex::Regex;
use turbo_rcstr::RcStr;
use turbo_tasks::{
NonLocalValue, ReadRef, ResolvedVc, TaskInput, ValueToString, Vc, trace::TraceRawVcs, turbofmt,
NonLocalValue, ReadRef, ResolvedVc, TaskInput, ValueToString, ValueToStringRef, Vc,
trace::TraceRawVcs, turbofmt,
};
use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::{DeterministicHash, Xxh3Hash64Hasher, encode_base38, hash_xxh3_hash64};
......@@ -226,7 +227,7 @@ impl AssetIdent {
let mut name = if let Some(inner) = context_path.get_path_to(path) {
escape_file_path(inner)
} else {
escape_file_path(&self.path.value_to_string().await?)
escape_file_path(&self.path.to_string_ref().await?)
};
let removed_extension = name.ends_with(&*expected_extension);
if removed_extension {
......
......@@ -18,7 +18,7 @@ use turbo_frozenmap::{FrozenMap, FrozenSet};
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{
FxIndexMap, FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, TaskInput, TryFlatJoinIterExt,
TryJoinIterExt, ValueToString, Vc, trace::TraceRawVcs,
TryJoinIterExt, ValueToString, ValueToStringRef, Vc, trace::TraceRawVcs,
};
use turbo_tasks_fs::{FileSystemEntryType, FileSystemPath};
use turbo_unix_path::normalize_request;
......@@ -596,7 +596,7 @@ impl ValueToString for ResolveResult {
result,
" ({ty}, {traced}, {:?})",
if let Some(target) = target {
Some(target.value_to_string().await?)
Some(target.to_string_ref().await?)
} else {
None
}
......@@ -1624,7 +1624,7 @@ pub async fn resolve_inline(
) -> Result<Vc<ResolveResult>> {
let span = tracing::info_span!(
"resolving",
lookup_path = display(lookup_path.value_to_string().await?),
lookup_path = display(lookup_path.to_string_ref().await?),
name = tracing::field::Empty,
reference_type = display(&reference_type),
);
......@@ -1873,7 +1873,7 @@ async fn resolve_internal_inline(
) -> Result<Vc<ResolveResult>> {
let span = tracing::info_span!(
"internal resolving",
lookup_path = display(lookup_path.value_to_string().await?),
lookup_path = display(lookup_path.to_string_ref().await?),
name = tracing::field::Empty
);
if !span.is_disabled() {
......
......@@ -14,7 +14,7 @@ use ref_cast::RefCast;
use regex::Regex;
use swc_sourcemap::{DecodedMap, SourceMap as RegularMap, SourceMapBuilder, SourceMapIndex};
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToStringRef, Vc};
use turbo_tasks_fs::{
File, FileContent, FileSystem, FileSystemPath, VirtualFileSystem,
rope::{Rope, RopeBuilder},
......@@ -380,7 +380,7 @@ impl SourceMap {
) -> Result<(BytesStr, BytesStr)> {
Ok(
if let Some(path) = origin.parent().try_join(&source_request) {
let path_str = path.value_to_string().await?;
let path_str = path.to_string_ref().await?;
let source = format!("{SOURCE_URL_PROTOCOL}///{path_str}");
let source_content = if let Some(source_content) = source_content {
source_content
......@@ -392,7 +392,7 @@ impl SourceMap {
};
(source.into(), source_content)
} else {
let origin_str = origin.value_to_string().await?;
let origin_str = origin.to_string_ref().await?;
static INVALID_REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"(?:^|/)(?:\.\.?(?:/|$))+"#).unwrap());
let source = INVALID_REGEX
......
......@@ -4,7 +4,8 @@ use anyhow::Result;
use rustc_hash::FxHashSet;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{
Completion, FxIndexMap, FxIndexSet, ResolvedVc, State, TryJoinIterExt, Vc, fxindexset,
Completion, FxIndexMap, FxIndexSet, ResolvedVc, State, TryJoinIterExt, ValueToStringRef, Vc,
fxindexset,
};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{
......@@ -286,8 +287,8 @@ impl Introspectable for AssetGraphContentSource {
}
#[turbo_tasks::function]
fn title(&self) -> Vc<RcStr> {
self.root_path.value_to_string()
async fn title(&self) -> Result<Vc<RcStr>> {
Ok(Vc::cell(self.root_path.to_string_ref().await?))
}
#[turbo_tasks::function]
......@@ -353,7 +354,7 @@ impl Introspectable for FullyExpanded {
#[turbo_tasks::function]
async fn title(&self) -> Result<Vc<RcStr>> {
Ok(self.0.await?.root_path.value_to_string())
Ok(Vc::cell(self.0.await?.root_path.to_string_ref().await?))
}
#[turbo_tasks::function]
......
......@@ -3,7 +3,9 @@ use std::{borrow::Cow, fmt::Display, io::Write};
use anyhow::{Context, Result};
use bincode::{Decode, Encode};
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{NonLocalValue, ResolvedVc, TaskInput, TryJoinIterExt, Vc, trace::TraceRawVcs};
use turbo_tasks::{
NonLocalValue, ResolvedVc, TaskInput, TryJoinIterExt, ValueToStringRef, Vc, trace::TraceRawVcs,
};
use turbo_tasks_fs::{FileSystem, FileSystemPath, LinkType, VirtualFileSystem, rope::RopeBuilder};
use turbo_tasks_hash::{encode_hex, hash_xxh3_hash64};
use turbopack_core::{
......@@ -270,7 +272,7 @@ impl Module for CachedExternalModule {
.with_modifier(self.external_type.to_string().into());
if let Some(target) = &self.target {
ident = ident.with_modifier(target.value_to_string().owned().await?);
ident = ident.with_modifier(target.to_string_ref().await?);
}
Ok(ident)
......
......@@ -11,8 +11,8 @@ use serde_with::serde_as;
use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{
Completion, OperationVc, ReadRef, ResolvedVc, TaskInput, TryJoinIterExt, ValueToString, Vc,
trace::TraceRawVcs,
Completion, OperationVc, ReadRef, ResolvedVc, TaskInput, TryJoinIterExt, ValueToString,
ValueToStringRef, Vc, trace::TraceRawVcs,
};
use turbo_tasks_env::ProcessEnv;
use turbo_tasks_fs::{
......@@ -664,14 +664,14 @@ impl EvaluateContext for WebpackLoaderContext {
bail!(
"Resolving {} in {} ends up on a different filesystem",
request.to_string().await?,
lookup_path.value_to_string().await?
lookup_path.to_string_ref().await?
);
}
} else {
bail!(
"Unable to resolve {} in {}",
request.to_string().await?,
lookup_path.value_to_string().await?
lookup_path.to_string_ref().await?
);
}
}
......@@ -702,7 +702,7 @@ impl EvaluateContext for WebpackLoaderContext {
bail!(
"importModule: unable to resolve {} in {}",
request,
lookup_path.value_to_string().await?
lookup_path.to_string_ref().await?
);
};
......
use anyhow::{Context, Result, bail};
use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{FxIndexMap, ResolvedVc, TryJoinIterExt, Upcast, ValueToString, Vc};
use turbo_tasks::{
FxIndexMap, ResolvedVc, TryJoinIterExt, Upcast, ValueToString, ValueToStringRef, Vc,
};
use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::HashAlgorithm;
use turbopack_core::{
......@@ -577,7 +579,7 @@ impl ChunkingContext for NodeJsChunkingContext {
) -> Result<Vc<EntryChunkGroupResult>> {
let span = tracing::info_span!(
"chunking",
name = display(path.value_to_string().await?),
name = display(path.to_string_ref().await?),
chunking_type = "entry",
);
async move {
......
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