Skip to content

Commit 841c4e9

Browse files
committed
codemod(turbopack): Rewrite self: Vc<Self> as &self in trivial cases
1 parent 74d2136 commit 841c4e9

File tree

71 files changed

+301
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+301
-335
lines changed

crates/next-api/src/middleware.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ impl MiddlewareEndpoint {
255255
}
256256

257257
#[turbo_tasks::function]
258-
async fn userland_module(self: Vc<Self>) -> Result<Vc<Box<dyn Module>>> {
259-
let this = self.await?;
258+
async fn userland_module(&self) -> Result<Vc<Box<dyn Module>>> {
259+
let this = self;
260260

261261
Ok(this
262262
.asset_context

crates/next-api/src/pages.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ impl PageEndpoint {
640640
}
641641

642642
#[turbo_tasks::function]
643-
async fn source(self: Vc<Self>) -> Result<Vc<Box<dyn Source>>> {
644-
let this = self.await?;
643+
async fn source(&self) -> Result<Vc<Box<dyn Source>>> {
644+
let this = self;
645645
Ok(Vc::upcast(FileSource::new(this.page.project_path())))
646646
}
647647

@@ -946,10 +946,10 @@ impl PageEndpoint {
946946

947947
#[turbo_tasks::function]
948948
async fn pages_manifest(
949-
self: Vc<Self>,
949+
&self,
950950
entry_chunk: Vc<Box<dyn OutputAsset>>,
951951
) -> Result<Vc<Box<dyn OutputAsset>>> {
952-
let this = self.await?;
952+
let this = self;
953953
let node_root = this.pages_project.project().node_root();
954954
let chunk_path = entry_chunk.ident().path().await?;
955955

@@ -991,10 +991,10 @@ impl PageEndpoint {
991991

992992
#[turbo_tasks::function]
993993
async fn build_manifest(
994-
self: Vc<Self>,
994+
&self,
995995
client_chunks: Vc<OutputAssets>,
996996
) -> Result<Vc<Box<dyn OutputAsset>>> {
997-
let this = self.await?;
997+
let this = self;
998998
let node_root = this.pages_project.project().node_root();
999999
let client_relative_path = this.pages_project.project().client_relative_path();
10001000
let client_relative_path_ref = client_relative_path.await?;

crates/next-api/src/project.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ impl ProjectContainer {
301301
#[turbo_tasks::value_impl]
302302
impl ProjectContainer {
303303
#[turbo_tasks::function]
304-
pub async fn project(self: Vc<Self>) -> Result<Vc<Project>> {
305-
let this = self.await?;
304+
pub async fn project(&self) -> Result<Vc<Project>> {
305+
let this = self;
306306

307307
let env_map: Vc<EnvMap>;
308308
let next_config;
@@ -385,11 +385,11 @@ impl ProjectContainer {
385385
/// disabled, this will always return [`OptionSourceMap::none`].
386386
#[turbo_tasks::function]
387387
pub async fn get_source_map(
388-
self: Vc<Self>,
388+
&self,
389389
file_path: Vc<FileSystemPath>,
390390
section: Option<RcStr>,
391391
) -> Result<Vc<OptionSourceMap>> {
392-
Ok(if let Some(map) = self.await?.versioned_content_map {
392+
Ok(if let Some(map) = self.versioned_content_map {
393393
map.get_source_map(file_path, section)
394394
} else {
395395
OptionSourceMap::none()
@@ -517,8 +517,8 @@ impl Project {
517517
}
518518

519519
#[turbo_tasks::function]
520-
async fn project_fs(self: Vc<Self>) -> Result<Vc<DiskFileSystem>> {
521-
let this = self.await?;
520+
async fn project_fs(&self) -> Result<Vc<DiskFileSystem>> {
521+
let this = self;
522522
let disk_fs = DiskFileSystem::new(
523523
PROJECT_FILESYSTEM_NAME.into(),
524524
this.root_path.clone(),
@@ -537,15 +537,15 @@ impl Project {
537537
}
538538

539539
#[turbo_tasks::function]
540-
pub async fn output_fs(self: Vc<Self>) -> Result<Vc<DiskFileSystem>> {
541-
let this = self.await?;
540+
pub async fn output_fs(&self) -> Result<Vc<DiskFileSystem>> {
541+
let this = self;
542542
let disk_fs = DiskFileSystem::new("output".into(), this.project_path.clone(), vec![]);
543543
Ok(disk_fs)
544544
}
545545

546546
#[turbo_tasks::function]
547-
pub async fn dist_dir(self: Vc<Self>) -> Result<Vc<RcStr>> {
548-
Ok(Vc::cell(self.await?.dist_dir.clone()))
547+
pub async fn dist_dir(&self) -> Result<Vc<RcStr>> {
548+
Ok(Vc::cell(self.dist_dir.clone()))
549549
}
550550

551551
#[turbo_tasks::function]
@@ -589,23 +589,23 @@ impl Project {
589589
}
590590

591591
#[turbo_tasks::function]
592-
pub(super) async fn env(self: Vc<Self>) -> Result<Vc<Box<dyn ProcessEnv>>> {
593-
Ok(self.await?.env)
592+
pub(super) async fn env(&self) -> Result<Vc<Box<dyn ProcessEnv>>> {
593+
Ok(self.env)
594594
}
595595

596596
#[turbo_tasks::function]
597-
pub(super) async fn next_config(self: Vc<Self>) -> Result<Vc<NextConfig>> {
598-
Ok(self.await?.next_config)
597+
pub(super) async fn next_config(&self) -> Result<Vc<NextConfig>> {
598+
Ok(self.next_config)
599599
}
600600

601601
#[turbo_tasks::function]
602-
pub(super) async fn next_mode(self: Vc<Self>) -> Result<Vc<NextMode>> {
603-
Ok(self.await?.mode)
602+
pub(super) async fn next_mode(&self) -> Result<Vc<NextMode>> {
603+
Ok(self.mode)
604604
}
605605

606606
#[turbo_tasks::function]
607-
pub(super) async fn js_config(self: Vc<Self>) -> Result<Vc<JsConfig>> {
608-
Ok(self.await?.js_config)
607+
pub(super) async fn js_config(&self) -> Result<Vc<JsConfig>> {
608+
Ok(self.js_config)
609609
}
610610

611611
#[turbo_tasks::function]

crates/next-api/src/versioned_content_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl VersionedContentMap {
9595
/// operation. When assets change, map_path_to_op is updated.
9696
#[turbo_tasks::function]
9797
async fn compute_entry(
98-
self: Vc<Self>,
98+
&self,
9999
assets_operation: Vc<OutputAssetsOperation>,
100100
node_root: Vc<FileSystemPath>,
101101
client_relative_path: Vc<FileSystemPath>,
@@ -118,7 +118,7 @@ impl VersionedContentMap {
118118
}
119119
let entries = get_entries(assets).await.unwrap_or_default();
120120

121-
self.await?.map_path_to_op.update_conditionally(|map| {
121+
self.map_path_to_op.update_conditionally(|map| {
122122
let mut changed = false;
123123

124124
// get current map's keys, subtract keys that don't exist in operation

crates/next-core/src/app_structure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ struct DuplicateParallelRouteIssue {
732732
#[turbo_tasks::value_impl]
733733
impl Issue for DuplicateParallelRouteIssue {
734734
#[turbo_tasks::function]
735-
async fn file_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
736-
let this = self.await?;
735+
async fn file_path(&self) -> Result<Vc<FileSystemPath>> {
736+
let this = self;
737737
Ok(this.app_dir.join(this.page.to_string().into()))
738738
}
739739

crates/next-core/src/next_client/runtime_entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ pub struct RuntimeEntries(Vec<Vc<RuntimeEntry>>);
6969
impl RuntimeEntries {
7070
#[turbo_tasks::function]
7171
pub async fn resolve_entries(
72-
self: Vc<Self>,
72+
&self,
7373
asset_context: Vc<Box<dyn AssetContext>>,
7474
) -> Result<Vc<EvaluatableAssets>> {
7575
let mut runtime_entries = Vec::new();
7676

77-
for reference in &self.await? {
77+
for reference in &self.0 {
7878
let resolved_entries = reference.resolve_entry(asset_context).await?;
7979
runtime_entries.extend(&resolved_entries);
8080
}

0 commit comments

Comments
 (0)