Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ impl AppProject {
None,
ResolveErrorMode::Error,
)
.resolve()
.to_resolved()
.await?
.first_module()
.await?
Expand Down
4 changes: 2 additions & 2 deletions crates/next-api/src/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ async fn parse_actions(module: ResolvedVc<Box<dyn Module>>) -> Result<Vc<OptionA
return Ok(Vc::cell(None));
}

let original_parsed = ecmascript_asset.parse_original().resolve().await?;
let original_parsed = *ecmascript_asset.parse_original().to_resolved().await?;

let ParseResult::Ok {
program: original,
Expand All @@ -364,7 +364,7 @@ async fn parse_actions(module: ResolvedVc<Box<dyn Module>>) -> Result<Vc<OptionA
return Ok(Vc::cell(None));
};

let fragment = ecmascript_asset.failsafe_parse().resolve().await?;
let fragment = *ecmascript_asset.failsafe_parse().to_resolved().await?;

if fragment != original_parsed {
let ParseResult::Ok {
Expand Down
4 changes: 2 additions & 2 deletions crates/next-core/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub async fn emit_assets(
async fn emit(asset: Vc<Box<dyn OutputAsset>>) -> Result<()> {
asset
.content()
.resolve()
.to_resolved()
.await?
.write(asset.path().owned().await?)
.as_side_effect()
Expand All @@ -103,7 +103,7 @@ async fn emit_rebase(
.await?;
let content = asset.content();
content
.resolve()
.to_resolved()
.await?
.write(path)
.as_side_effect()
Expand Down
3 changes: 2 additions & 1 deletion crates/next-core/src/next_app/app_client_shared_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ pub async fn get_app_client_shared_chunk_group(
module_graph,
AvailabilityInfo::root(),
)
.resolve()
.to_resolved()
.await
.map(|r| *r)
}
.instrument(span)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/next_client/runtime_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl RuntimeEntry {
None,
ResolveErrorMode::Error,
)
.resolve()
.to_resolved()
.await?
.primary_modules()
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/next_server/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl AfterResolvePlugin for ExternalCjsModulesResolvePlugin {
// have an extension in the request we try to append ".js"
// automatically
request_str.push_str(".js");
request = request.append_path(rcstr!(".js")).resolve().await?;
request = *request.append_path(rcstr!(".js")).to_resolved().await?;
continue;
}
// this can't resolve with node.js from the original location, so bundle it
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-backend/fuzz/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn actual_operation(spec: Arc<Vec<TaskSpec>>, iterations: usize) {
for i in 0..iterations {
let spec = spec.clone();
tt.run(async move {
let it = create_state().resolve().await?;
let it = *create_state().to_resolved().await?;
it.await?.set(i);
let task = run_task(spec.clone(), it, 0);
task.strongly_consistent().await?;
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-backend/tests/all_in_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async fn test_all_in_one_operation(nonce: u32) -> Result<Vc<()>> {

let b_erased_other: Vc<Box<dyn Add>> = Vc::upcast(Vc::<NumberB>::cell(10));
let c_erased_invalid: Vc<Box<dyn Add>> = a_erased.add(b_erased_other);
assert!(c_erased_invalid.resolve().await.is_err());
assert!(c_erased_invalid.to_resolved().await.is_err());

Ok(Vc::cell(()))
}
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-backend/tests/bug2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async fn test_graph_bug_operation(nonce: u32) -> Result<Vc<()>> {
},
];

let it = create_iteration().resolve().await?;
let it = *create_iteration().to_resolved().await?;
it.await?.set(0);
println!("🚀 Initial");
let task = run_task(Arc::new(spec), it, 0);
Expand Down
4 changes: 2 additions & 2 deletions turbopack/crates/turbo-tasks-backend/tests/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ static REGISTRATION: Registration = register!();
async fn test_hidden_mutate() {
run_once(&REGISTRATION, || async {
unmark_top_level_task_may_leak_eventually_consistent_state();
let input = create_input().resolve().await?;
let input = *create_input().to_resolved().await?;
input.await?.state.set(1);
let changing_value = compute(input);
assert_eq!(changing_value.await?.value, 1);

let changing_value_resolved = changing_value.resolve().await?;
let changing_value_resolved = *changing_value.to_resolved().await?;
let read_input = read_input(changing_value_resolved);
let static_immutable = immutable_fn(changing_value_resolved);
let read_self = changing_value_resolved.read_self();
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-backend/tests/recompute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async fn compute2(input: Vc<ChangingInput>) -> Result<Vc<u32>> {
async fn recompute_dependency() {
run(&REGISTRATION, || async {
unmark_top_level_task_may_leak_eventually_consistent_state();
let input = get_dependency_input().resolve().await?;
let input = *get_dependency_input().to_resolved().await?;
// Reset state to 1 at the start of each iteration (important for multi-run tests)
input.await?.state.set(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ static REGISTRATION: Registration = register!();
async fn recompute() {
run_once(&REGISTRATION, || async {
unmark_top_level_task_may_leak_eventually_consistent_state();
let input = ChangingInput::new(1).resolve().await?;
let input2 = ChangingInput::new(2).resolve().await?;
let input = *ChangingInput::new(1).to_resolved().await?;
let input2 = *ChangingInput::new(2).to_resolved().await?;
input.await?.state.set(1);
input2.await?.state.set(1000);
let output = compute(input, input2, 1);
Expand Down
10 changes: 6 additions & 4 deletions turbopack/crates/turbo-tasks-backend/tests/task_statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,16 @@ async fn test_dyn_trait_methods() -> Result<()> {
enable_stats();
for i in 0..10 {
let wvc: Vc<Box<dyn Doublable>> = Vc::upcast(wrap(i));
let _ = tokio::try_join!(wvc.double().resolve(), wvc.double().resolve()).unwrap();
let _ = tokio::try_join!(wvc.double_vc().resolve(), wvc.double_vc().resolve()).unwrap();
let _ =
tokio::try_join!(wvc.double().to_resolved(), wvc.double().to_resolved()).unwrap();
let _ = tokio::try_join!(wvc.double_vc().to_resolved(), wvc.double_vc().to_resolved())
.unwrap();
}
// use cached results
for i in 0..5 {
let wvc: Vc<Box<dyn Doublable>> = Vc::upcast(wrap(i));
let _ = wvc.double().resolve().await.unwrap();
let _ = wvc.double_vc().resolve().await.unwrap();
let _ = wvc.double().to_resolved().await.unwrap();
let _ = wvc.double_vc().to_resolved().await.unwrap();
}
// use cached results without dynamic dispatch
for i in 0..2 {
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks/src/raw_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl RawVc {
ReadRawVcFuture::new(self, None)
}

/// See [`crate::Vc::resolve`].
/// See [`crate::Vc::to_resolved`].
pub(crate) async fn resolve(self) -> Result<RawVc> {
self.resolve_inner(ReadOutputOptions {
consistency: ReadConsistency::Eventual,
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks/src/task/task_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ where
}

async fn resolve_input(&self) -> Result<Self> {
Vc::resolve(*self).await
Ok(*(*self).to_resolved().await?)
}
}

Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks/src/vc/cell_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ where
/// [`SharedReference`][crate::task::SharedReference].
///
/// This is used in APIs that already have a `SharedReference`, such as in
/// [`ReadRef::cell`][crate::ReadRef::cell] or in [`Vc::resolve`] when
/// [`ReadRef::cell`][crate::ReadRef::cell] or in [`Vc::to_resolved`] when
/// resolving a local [`Vc`]. This avoids unnecessary cloning.
fn raw_cell(value: TypedSharedReference) -> RawVc;
}
Expand Down
18 changes: 6 additions & 12 deletions turbopack/crates/turbo-tasks/src/vc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ where
{
/// Returns a debug identifier for this `Vc`.
pub async fn debug_identifier(vc: Self) -> Result<String> {
let resolved = vc.resolve().await?;
let raw_vc: RawVc = resolved.node;
let resolved = vc.to_resolved().await?;
let raw_vc: RawVc = resolved.node.node;
if let RawVc::TaskCell(task_id, CellId { type_id, index }) = raw_vc {
let value_ty = registry::get_value_type(type_id);
Ok(format!("{}#{}: {}", value_ty.ty.name, index, task_id))
Expand Down Expand Up @@ -337,21 +337,15 @@ where
Ok(())
}

/// Do not use this: Use [`Vc::to_resolved`] instead. If you must have a resolved [`Vc`] type
/// and not a [`ResolvedVc`] type, simply deref the result of [`Vc::to_resolved`].
pub async fn resolve(self) -> Result<Vc<T>> {
Ok(Self {
node: self.node.resolve().await?,
_t: PhantomData,
})
}

/// Resolve the reference until it points to a cell directly, and wrap the
/// result in a [`ResolvedVc`], which statically guarantees that the
/// [`Vc`] was resolved.
pub async fn to_resolved(self) -> Result<ResolvedVc<T>> {
Ok(ResolvedVc {
node: self.resolve().await?,
node: Vc {
node: self.node.resolve().await?,
_t: PhantomData,
},
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl EcmascriptDevChunkListContent {
if let Some(mergeable) =
ResolvedVc::try_sidecast::<Box<dyn MergeableVersionedContent>>(*chunk_content)
{
let merger = mergeable.get_merger().resolve().await?;
let merger = mergeable.get_merger().to_resolved().await?;
by_merger.entry(merger).or_default().push(*chunk_content);
} else {
by_path.insert(
Expand All @@ -125,7 +125,7 @@ impl EcmascriptDevChunkListContent {
.map(|(merger, contents)| (merger, Vc::cell(contents)))
.map(async |(merger, contents)| {
Ok((
merger.to_resolved().await?,
merger,
merger.merge(contents).version().into_trait_ref().await?,
))
})
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-cli-utils/src/runtime_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl RuntimeEntry {
None,
ResolveErrorMode::Error,
)
.resolve()
.to_resolved()
.await?
.primary_modules()
.await?;
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub async fn create_web_entry_source(
Ok(origin
.resolve_asset(request, origin.resolve_options(), ty)
.await?
.resolve()
.to_resolved()
.await?
.primary_modules()
.await?
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-core/src/introspect/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub async fn children_from_module_references(

for &module in reference
.resolve_reference()
.resolve()
.to_resolved()
.await?
.primary_modules()
.await?
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-core/src/reference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub async fn primary_referenced_modules(module: Vc<Box<dyn Module>>) -> Result<V
.map(|reference| async {
reference
.resolve_reference()
.resolve()
.to_resolved()
.await?
.primary_modules()
.owned()
Expand Down
Loading
Loading