From b36f2b56c9c0f58485bf98c799e30d2256704a73 Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Wed, 2 Aug 2023 09:43:35 -0700 Subject: [PATCH] fixup! [2/n] no-context lint: migrate some crates --- crates/turbopack-wasm/src/lib.rs | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/crates/turbopack-wasm/src/lib.rs b/crates/turbopack-wasm/src/lib.rs index f219287105c15..db012caeb2ac9 100644 --- a/crates/turbopack-wasm/src/lib.rs +++ b/crates/turbopack-wasm/src/lib.rs @@ -43,23 +43,26 @@ fn modifier() -> Vc { #[derive(Clone)] pub struct WebAssemblyModuleAsset { pub source: Vc>, - pub context: Vc>, + pub asset_context: Vc>, } #[turbo_tasks::value_impl] impl WebAssemblyModuleAsset { #[turbo_tasks::function] - pub fn new(source: Vc>, context: Vc>) -> Vc { - Self::cell(WebAssemblyModuleAsset { source, context }) + pub fn new(source: Vc>, asset_context: Vc>) -> Vc { + Self::cell(WebAssemblyModuleAsset { + source, + asset_context, + }) } #[turbo_tasks::function] async fn wasm_asset( self: Vc, - context: Vc>, + chunking_context: Vc>, ) -> Result> { Ok(WebAssemblyAsset::cell(WebAssemblyAsset { - context, + chunking_context, source: self.await?.source, })) } @@ -86,11 +89,11 @@ impl ChunkableModule for WebAssemblyModuleAsset { #[turbo_tasks::function] fn as_chunk( self: Vc, - context: Vc>, + chunking_context: Vc>, availability_info: Value, ) -> Vc> { Vc::upcast(EcmascriptChunk::new( - context, + chunking_context, Vc::upcast(self), availability_info, )) @@ -102,12 +105,12 @@ impl EcmascriptChunkPlaceable for WebAssemblyModuleAsset { #[turbo_tasks::function] fn as_chunk_item( self: Vc, - context: Vc>, + chunking_context: Vc>, ) -> Vc> { Vc::upcast(ModuleChunkItem::cell(ModuleChunkItem { module: self, - context, - wasm_asset: self.wasm_asset(Vc::upcast(context)), + chunking_context, + wasm_asset: self.wasm_asset(Vc::upcast(chunking_context)), })) } @@ -131,7 +134,7 @@ impl EcmascriptChunkPlaceable for WebAssemblyModuleAsset { #[turbo_tasks::value] struct WebAssemblyAsset { - context: Vc>, + chunking_context: Vc>, source: Vc>, } @@ -141,7 +144,7 @@ impl OutputAsset for WebAssemblyAsset { async fn ident(&self) -> Result> { let ident = self.source.ident().with_modifier(modifier()); - let asset_path = self.context.chunk_path(ident, ".wasm".to_string()); + let asset_path = self.chunking_context.chunk_path(ident, ".wasm".to_string()); Ok(AssetIdent::from_path(asset_path)) } @@ -158,7 +161,7 @@ impl Asset for WebAssemblyAsset { #[turbo_tasks::value] struct ModuleChunkItem { module: Vc, - context: Vc>, + chunking_context: Vc>, wasm_asset: Vc, } @@ -185,7 +188,7 @@ impl ChunkItem for ModuleChunkItem { impl EcmascriptChunkItem for ModuleChunkItem { #[turbo_tasks::function] fn chunking_context(&self) -> Vc> { - self.context + self.chunking_context } #[turbo_tasks::function] @@ -199,7 +202,7 @@ impl EcmascriptChunkItem for ModuleChunkItem { availability_info: Value, ) -> Result> { let path = self.wasm_asset.ident().path().await?; - let output_root = self.context.output_root().await?; + let output_root = self.chunking_context.output_root().await?; let Some(path) = output_root.get_path_to(&path) else { bail!("WASM asset ident is not relative to output root");