Unverified Commit 3651a450 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

refactor(turbopack-core): Remove remaining "local" value type opt-outs in turbopack-core (#74706)

parent e1afc920
......@@ -123,7 +123,7 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin {
.emit();
return Ok(ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(Vc::cell(
ResolveResult::primary(ResolveResultItem::Error(ResolvedVc::cell(
format!("Font file not found: Can't resolve {}'", font_path)
.into(),
)))
......
......@@ -146,7 +146,7 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin {
.emit();
ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(Vc::cell(
ResolveResult::primary(ResolveResultItem::Error(ResolvedVc::cell(
self.message.join("\n").into(),
)))
.cell(),
......
......@@ -100,7 +100,7 @@ impl ModuleResolveResultItem {
}
}
#[turbo_tasks::value(shared, local)]
#[turbo_tasks::value(shared)]
#[derive(Clone, Debug)]
pub struct ModuleResolveResult {
pub primary: FxIndexMap<RequestKey, ModuleResolveResultItem>,
......@@ -414,7 +414,7 @@ impl Display for ExternalType {
}
}
#[turbo_tasks::value(shared, local)]
#[turbo_tasks::value(shared)]
#[derive(Clone)]
pub enum ResolveResultItem {
Source(ResolvedVc<Box<dyn Source>>),
......@@ -425,7 +425,7 @@ pub enum ResolveResultItem {
traced: ExternalTraced,
},
Ignore,
Error(Vc<RcStr>),
Error(ResolvedVc<RcStr>),
Empty,
Custom(u8),
}
......@@ -473,7 +473,7 @@ impl RequestKey {
}
}
#[turbo_tasks::value(shared, local)]
#[turbo_tasks::value(shared)]
#[derive(Clone)]
pub struct ResolveResult {
pub primary: FxIndexMap<RequestKey, ResolveResultItem>,
......@@ -721,9 +721,7 @@ impl ResolveResult {
}
ResolveResultItem::Ignore => ModuleResolveResultItem::Ignore,
ResolveResultItem::Empty => ModuleResolveResultItem::Empty,
ResolveResultItem::Error(e) => {
ModuleResolveResultItem::Error(e.to_resolved().await?)
}
ResolveResultItem::Error(e) => ModuleResolveResultItem::Error(e),
ResolveResultItem::Custom(u8) => {
ModuleResolveResultItem::Custom(u8)
}
......@@ -1418,7 +1416,10 @@ pub async fn resolve_raw(
path: Vc<Pattern>,
force_in_lookup_dir: bool,
) -> Result<Vc<ResolveResult>> {
async fn to_result(request: &str, path: Vc<FileSystemPath>) -> Result<Vc<ResolveResult>> {
async fn to_result(
request: &str,
path: ResolvedVc<FileSystemPath>,
) -> Result<Vc<ResolveResult>> {
let RealPathResult { path, symlinks } = &*path.realpath_with_links().await?;
Ok(ResolveResult::source_with_affecting_sources(
RequestKey::new(request.into()),
......@@ -1771,7 +1772,7 @@ async fn resolve_internal_inline(
results.push(
resolved(
RequestKey::new(matched_pattern.clone()),
*path,
**path,
lookup_path,
request,
options_value,
......@@ -1784,7 +1785,7 @@ async fn resolve_internal_inline(
}
PatternMatch::Directory(matched_pattern, path) => {
results.push(
resolve_into_folder(*path, options)
resolve_into_folder(**path, options)
.with_request(matched_pattern.clone()),
);
}
......@@ -2186,7 +2187,7 @@ async fn resolve_relative_request(
results.push(
resolved(
RequestKey::new(matched_pattern.into()),
*path,
**path,
lookup_path,
request,
options_value,
......@@ -2203,7 +2204,7 @@ async fn resolve_relative_request(
results.push(
resolved(
RequestKey::new(matched_pattern.into()),
*path,
**path,
lookup_path,
request,
options_value,
......@@ -2226,7 +2227,7 @@ async fn resolve_relative_request(
results.push(
resolved(
RequestKey::new(matched_pattern.into()),
*path,
**path,
lookup_path,
request,
options_value,
......@@ -2244,7 +2245,7 @@ async fn resolve_relative_request(
results.push(
resolved(
RequestKey::new(matched_pattern.clone()),
*path,
**path,
lookup_path,
request,
options_value,
......@@ -2260,7 +2261,8 @@ async fn resolve_relative_request(
// Directory matches must be resolved AFTER file matches
for m in matches.iter() {
if let PatternMatch::Directory(matched_pattern, path) = m {
results.push(resolve_into_folder(*path, options).with_request(matched_pattern.clone()));
results
.push(resolve_into_folder(**path, options).with_request(matched_pattern.clone()));
}
}
......
......@@ -11,7 +11,8 @@ use serde::{Deserialize, Serialize};
use tracing::Instrument;
use turbo_rcstr::RcStr;
use turbo_tasks::{
debug::ValueDebugFormat, trace::TraceRawVcs, ResolvedVc, Value, ValueToString, Vc,
debug::ValueDebugFormat, trace::TraceRawVcs, NonLocalValue, ResolvedVc, Value, ValueToString,
Vc,
};
use turbo_tasks_fs::{
util::normalize_path, DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath,
......@@ -1300,14 +1301,24 @@ impl ValueToString for Pattern {
}
}
#[derive(Debug, PartialEq, Eq, Clone, TraceRawVcs, Serialize, Deserialize, ValueDebugFormat)]
#[derive(
Debug,
PartialEq,
Eq,
Clone,
TraceRawVcs,
Serialize,
Deserialize,
ValueDebugFormat,
NonLocalValue,
)]
pub enum PatternMatch {
File(RcStr, Vc<FileSystemPath>),
Directory(RcStr, Vc<FileSystemPath>),
File(RcStr, ResolvedVc<FileSystemPath>),
Directory(RcStr, ResolvedVc<FileSystemPath>),
}
impl PatternMatch {
pub fn path(&self) -> Vc<FileSystemPath> {
pub fn path(&self) -> ResolvedVc<FileSystemPath> {
match *self {
PatternMatch::File(_, path) | PatternMatch::Directory(_, path) => path,
}
......@@ -1322,7 +1333,7 @@ impl PatternMatch {
// TODO this isn't super efficient
// avoid storing a large list of matches
#[turbo_tasks::value(transparent, local)]
#[turbo_tasks::value(transparent)]
pub struct PatternMatches(Vec<PatternMatch>);
/// Find all files or directories that match the provided `pattern` with the
......@@ -1356,12 +1367,12 @@ pub async fn read_matches(
for (index, (str, until_end)) in constants.into_iter().enumerate() {
if until_end {
if handled.insert(str) {
if let Some(fs_path) = &*if force_in_lookup_dir {
let fs_path = *if force_in_lookup_dir {
lookup_dir.try_join_inside(str.into()).await?
} else {
lookup_dir.try_join(str.into()).await?
} {
let fs_path = fs_path.resolve().await?;
};
if let Some(fs_path) = fs_path {
// This explicit deref of `context` is necessary
#[allow(clippy::explicit_auto_deref)]
let should_match = !force_in_lookup_dir
......@@ -1453,7 +1464,10 @@ pub async fn read_matches(
if let Some(pos) = pat.match_position(&prefix) {
results.push((
pos,
PatternMatch::Directory(prefix.clone().into(), lookup_dir.parent()),
PatternMatch::Directory(
prefix.clone().into(),
lookup_dir.parent().to_resolved().await?,
),
));
}
......@@ -1462,7 +1476,10 @@ pub async fn read_matches(
if let Some(pos) = pat.match_position(&prefix) {
results.push((
pos,
PatternMatch::Directory(prefix.clone().into(), lookup_dir.parent()),
PatternMatch::Directory(
prefix.clone().into(),
lookup_dir.parent().to_resolved().await?,
),
));
}
if let Some(pos) = pat.could_match_position(&prefix) {
......@@ -1481,14 +1498,14 @@ pub async fn read_matches(
if let Some(pos) = pat.match_position(&prefix) {
results.push((
pos,
PatternMatch::Directory(prefix.clone().into(), *lookup_dir),
PatternMatch::Directory(prefix.clone().into(), lookup_dir),
));
}
prefix.pop();
}
if prefix.is_empty() {
if let Some(pos) = pat.match_position("./") {
results.push((pos, PatternMatch::Directory("./".into(), *lookup_dir)));
results.push((pos, PatternMatch::Directory("./".into(), lookup_dir)));
}
if let Some(pos) = pat.could_match_position("./") {
nested.push((pos, read_matches(*lookup_dir, "./".into(), false, pattern)));
......@@ -1525,7 +1542,7 @@ pub async fn read_matches(
if let Some(pos) = pat.match_position(&prefix) {
results.push((
pos,
PatternMatch::File(prefix.clone().into(), **path),
PatternMatch::File(prefix.clone().into(), *path),
));
}
prefix.truncate(len)
......@@ -1540,7 +1557,7 @@ pub async fn read_matches(
if let Some(pos) = pat.match_position(&prefix) {
results.push((
pos,
PatternMatch::Directory(prefix.clone().into(), **path),
PatternMatch::Directory(prefix.clone().into(), *path),
));
}
prefix.push('/');
......@@ -1548,7 +1565,7 @@ pub async fn read_matches(
if let Some(pos) = pat.match_position(&prefix) {
results.push((
pos,
PatternMatch::Directory(prefix.clone().into(), **path),
PatternMatch::Directory(prefix.clone().into(), *path),
));
}
if let Some(pos) = pat.could_match_position(&prefix) {
......@@ -1575,16 +1592,13 @@ pub async fn read_matches(
pos,
PatternMatch::Directory(
prefix.clone().into(),
**fs_path,
*fs_path,
),
));
} else {
results.push((
pos,
PatternMatch::File(
prefix.clone().into(),
**fs_path,
),
PatternMatch::File(prefix.clone().into(), *fs_path),
));
}
}
......@@ -1599,7 +1613,7 @@ pub async fn read_matches(
pos,
PatternMatch::Directory(
prefix.clone().into(),
**fs_path,
*fs_path,
),
));
}
......@@ -1614,7 +1628,7 @@ pub async fn read_matches(
pos,
PatternMatch::Directory(
prefix.clone().into(),
**fs_path,
*fs_path,
),
));
}
......
......@@ -836,9 +836,7 @@ impl AssetContext for ModuleAssetContext {
}
ResolveResultItem::Ignore => ModuleResolveResultItem::Ignore,
ResolveResultItem::Empty => ModuleResolveResultItem::Empty,
ResolveResultItem::Error(e) => {
ModuleResolveResultItem::Error(e.to_resolved().await?)
}
ResolveResultItem::Error(e) => ModuleResolveResultItem::Error(e),
ResolveResultItem::Custom(u8) => ModuleResolveResultItem::Custom(u8),
})
}
......
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