Skip to content

Commit 0e215a1

Browse files
committed
Remove uses of Value<..> instead make the payload a Taskinput
1 parent 321e168 commit 0e215a1

File tree

11 files changed

+37
-40
lines changed

11 files changed

+37
-40
lines changed

crates/next-core/src/next_font/google/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use indoc::formatdoc;
66
use rustc_hash::FxHashMap;
77
use serde::{Deserialize, Serialize};
88
use turbo_rcstr::{RcStr, rcstr};
9-
use turbo_tasks::{Completion, FxIndexMap, ResolvedVc, Value, Vc};
9+
use turbo_tasks::{Completion, FxIndexMap, ResolvedVc, Vc};
1010
use turbo_tasks_bytes::stream::SingleValue;
1111
use turbo_tasks_env::{CommandLineProcessEnv, ProcessEnv};
1212
use turbo_tasks_fetch::{HttpResponseBody, fetch};
@@ -624,7 +624,7 @@ async fn font_options_from_query_map(
624624

625625
let options =
626626
options_from_request(&parse_json_with_source_context(&json)?, &*font_data.await?)?;
627-
Ok(NextFontGoogleOptions::new(Value::new(options)))
627+
Ok(NextFontGoogleOptions::new(options))
628628
}
629629
fn font_file_options_from_query_map(query: &RcStr) -> Result<NextFontGoogleFontFileOptions> {
630630
let query_map = qstring::QString::from(query.as_str());

crates/next-core/src/next_font/google/options.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Context, Result};
22
use serde::{Deserialize, Serialize};
33
use turbo_rcstr::{RcStr, rcstr};
44
use turbo_tasks::{
5-
FxIndexMap, FxIndexSet, NonLocalValue, Value, Vc, fxindexset, trace::TraceRawVcs,
5+
FxIndexMap, FxIndexSet, NonLocalValue, TaskInput, Vc, fxindexset, trace::TraceRawVcs,
66
};
77

88
use super::request::{NextFontRequest, OneOrManyStrings};
@@ -12,7 +12,7 @@ const ALLOWED_DISPLAY_VALUES: &[&str] = &["auto", "block", "swap", "fallback", "
1212
pub(super) type FontData = FxIndexMap<RcStr, FontDataEntry>;
1313

1414
#[turbo_tasks::value(serialization = "auto_for_input")]
15-
#[derive(Clone, Debug, PartialOrd, Ord, Hash)]
15+
#[derive(Clone, Debug, PartialOrd, Ord, Hash, TaskInput)]
1616
pub(super) struct NextFontGoogleOptions {
1717
/// Name of the requested font from Google. Contains literal spaces.
1818
pub font_family: RcStr,
@@ -38,8 +38,8 @@ impl NextFontGoogleOptions {
3838
#[turbo_tasks::value_impl]
3939
impl NextFontGoogleOptions {
4040
#[turbo_tasks::function]
41-
pub fn new(options: Value<NextFontGoogleOptions>) -> Vc<NextFontGoogleOptions> {
42-
Self::cell(options.into_value())
41+
pub fn new(options: NextFontGoogleOptions) -> Vc<NextFontGoogleOptions> {
42+
Self::cell(options)
4343
}
4444
}
4545

@@ -55,6 +55,7 @@ impl NextFontGoogleOptions {
5555
Deserialize,
5656
TraceRawVcs,
5757
NonLocalValue,
58+
TaskInput,
5859
)]
5960
pub(super) enum FontWeights {
6061
Variable,

crates/next-core/src/next_font/local/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use font_fallback::FontFallbackResult;
33
use indoc::formatdoc;
44
use serde::{Deserialize, Serialize};
55
use turbo_rcstr::{RcStr, rcstr};
6-
use turbo_tasks::{ResolvedVc, Value, Vc};
6+
use turbo_tasks::{ResolvedVc, Vc};
77
use turbo_tasks_fs::{
88
FileContent, FileSystemPath, glob::Glob, json::parse_json_with_source_context,
99
};
@@ -226,7 +226,7 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin {
226226
path,
227227
preload,
228228
has_size_adjust: size_adjust,
229-
} = font_file_options_from_query_map(query).await?;
229+
} = font_file_options_from_query_map(query)?;
230230

231231
let (filename, ext) = split_extension(&path);
232232
let ext = ext.with_context(|| format!("font {} needs an extension", &path))?;
@@ -303,11 +303,10 @@ fn font_options_from_query_map(query: RcStr) -> Result<Vc<NextFontLocalOptions>>
303303
bail!("Expected one entry");
304304
};
305305

306-
options_from_request(&parse_json_with_source_context(&json)?)
307-
.map(|o| NextFontLocalOptions::new(Value::new(o)))
306+
options_from_request(&parse_json_with_source_context(&json)?).map(NextFontLocalOptions::new)
308307
}
309308

310-
async fn font_file_options_from_query_map(query: &RcStr) -> Result<NextFontLocalFontFileOptions> {
309+
fn font_file_options_from_query_map(query: &RcStr) -> Result<NextFontLocalFontFileOptions> {
311310
let query_map = qstring::QString::from(query.as_str());
312311

313312
if query_map.len() != 1 {

crates/next-core/src/next_font/local/options.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{fmt::Display, str::FromStr};
33
use anyhow::{Context, Result};
44
use serde::{Deserialize, Serialize};
55
use turbo_rcstr::RcStr;
6-
use turbo_tasks::{NonLocalValue, Value, Vc, trace::TraceRawVcs};
6+
use turbo_tasks::{NonLocalValue, TaskInput, Vc, trace::TraceRawVcs};
77

88
use super::request::{
99
AdjustFontFallback, NextFontLocalRequest, NextFontLocalRequestArguments, SrcDescriptor,
@@ -13,7 +13,7 @@ use super::request::{
1313
/// A normalized, Vc-friendly struct derived from validating and transforming
1414
/// [[NextFontLocalRequest]]
1515
#[turbo_tasks::value(serialization = "auto_for_input")]
16-
#[derive(Clone, Debug, PartialOrd, Ord, Hash)]
16+
#[derive(Clone, Debug, PartialOrd, Ord, Hash, TaskInput)]
1717
pub(super) struct NextFontLocalOptions {
1818
pub fonts: FontDescriptors,
1919
pub default_weight: Option<FontWeight>,
@@ -43,8 +43,8 @@ impl NextFontLocalOptions {
4343
#[turbo_tasks::value_impl]
4444
impl NextFontLocalOptions {
4545
#[turbo_tasks::function]
46-
pub fn new(options: Value<NextFontLocalOptions>) -> Vc<NextFontLocalOptions> {
47-
Self::cell(options.into_value())
46+
pub fn new(options: NextFontLocalOptions) -> Vc<NextFontLocalOptions> {
47+
Self::cell(options)
4848
}
4949
}
5050

@@ -62,6 +62,7 @@ impl NextFontLocalOptions {
6262
Serialize,
6363
TraceRawVcs,
6464
NonLocalValue,
65+
TaskInput,
6566
)]
6667
pub(super) struct FontDescriptor {
6768
pub weight: Option<FontWeight>,
@@ -103,6 +104,7 @@ impl FontDescriptor {
103104
Serialize,
104105
TraceRawVcs,
105106
NonLocalValue,
107+
TaskInput,
106108
)]
107109
pub(super) enum FontDescriptors {
108110
/// `One` is a special case when the user did not provide a `src` field and
@@ -125,6 +127,7 @@ pub(super) enum FontDescriptors {
125127
Hash,
126128
TraceRawVcs,
127129
NonLocalValue,
130+
TaskInput,
128131
)]
129132
pub(super) enum FontWeight {
130133
Variable(RcStr, RcStr),

crates/next-core/src/next_font/local/request.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde::{Deserialize, Serialize};
22
use turbo_rcstr::RcStr;
3-
use turbo_tasks::{NonLocalValue, trace::TraceRawVcs};
3+
use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs};
44

55
/// The top-most structure encoded into the query param in requests to
66
/// `next/font/local` generated by the next/font swc transform. e.g.
@@ -58,6 +58,7 @@ pub(super) struct SrcDescriptor {
5858
Serialize,
5959
TraceRawVcs,
6060
NonLocalValue,
61+
TaskInput,
6162
)]
6263
pub(super) enum AdjustFontFallback {
6364
Arial,

crates/next-core/src/next_image/module.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Result;
2-
use turbo_tasks::{ResolvedVc, TaskInput, Value, Vc, fxindexmap};
2+
use turbo_tasks::{ResolvedVc, TaskInput, Vc, fxindexmap};
33
use turbopack::{ModuleAssetContext, module_options::CustomModuleType};
44
use turbopack_core::{
55
context::AssetContext, module::Module, reference_type::ReferenceType, resolve::ModulePart,
@@ -58,9 +58,9 @@ impl StructuredImageModuleType {
5858
}
5959

6060
#[turbo_tasks::function]
61-
pub fn new(blur_placeholder_mode: Value<BlurPlaceholderMode>) -> Vc<Self> {
61+
pub fn new(blur_placeholder_mode: BlurPlaceholderMode) -> Vc<Self> {
6262
StructuredImageModuleType::cell(StructuredImageModuleType {
63-
blur_placeholder_mode: blur_placeholder_mode.into_value(),
63+
blur_placeholder_mode,
6464
})
6565
}
6666
}

crates/next-core/src/next_shared/transforms/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub use next_lint::get_next_lint_transform_rule;
3333
pub use next_strip_page_exports::get_next_pages_transforms_rule;
3434
pub use next_track_dynamic_imports::get_next_track_dynamic_imports_transform_rule;
3535
pub use server_actions::get_server_actions_transform_rule;
36-
use turbo_tasks::{ReadRef, ResolvedVc, Value};
36+
use turbo_tasks::{ReadRef, ResolvedVc};
3737
use turbo_tasks_fs::FileSystemPath;
3838
use turbopack::module_options::{ModuleRule, ModuleRuleEffect, ModuleType, RuleCondition};
3939
use turbopack_core::reference_type::{ReferenceType, UrlReferenceSubType};
@@ -67,7 +67,7 @@ pub async fn get_next_image_rule() -> Result<ModuleRule> {
6767
]),
6868
vec![ModuleRuleEffect::ModuleType(ModuleType::Custom(
6969
ResolvedVc::upcast(
70-
StructuredImageModuleType::new(Value::new(BlurPlaceholderMode::DataUrl))
70+
StructuredImageModuleType::new(BlurPlaceholderMode::DataUrl)
7171
.to_resolved()
7272
.await?,
7373
),

turbopack/crates/turbopack-css/src/references/compose.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
22
use turbo_rcstr::RcStr;
3-
use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc};
3+
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
44
use turbopack_core::{
55
chunk::ChunkableModuleReference,
66
reference::ModuleReference,
@@ -37,7 +37,7 @@ impl ModuleReference for CssModuleComposeReference {
3737
css_resolve(
3838
*self.origin,
3939
*self.request,
40-
Value::new(CssReferenceSubType::Compose),
40+
CssReferenceSubType::Compose,
4141
// TODO: add real issue source, currently impossible because `CssClassName` doesn't
4242
// contain the source span
4343
// https://docs.rs/swc_css_modules/0.21.16/swc_css_modules/enum.CssClassName.html

turbopack/crates/turbopack-css/src/references/import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use lightningcss::{
55
traits::ToCss,
66
};
77
use turbo_rcstr::RcStr;
8-
use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc};
8+
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
99
use turbopack_core::{
1010
chunk::{ChunkableModuleReference, ChunkingContext},
1111
issue::IssueSource,
@@ -138,7 +138,7 @@ impl ModuleReference for ImportAssetReference {
138138
Ok(css_resolve(
139139
*self.origin,
140140
*self.request,
141-
Value::new(CssReferenceSubType::AtImport(import_context)),
141+
CssReferenceSubType::AtImport(import_context),
142142
Some(self.issue_source.clone()),
143143
))
144144
}

turbopack/crates/turbopack-css/src/references/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use lightningcss::{
88
visitor::{Visit, Visitor},
99
};
1010
use turbo_rcstr::RcStr;
11-
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Value, Vc};
11+
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
1212
use turbopack_core::{
1313
issue::IssueSource,
1414
reference::ModuleReference,
@@ -177,14 +177,8 @@ impl Visitor<'_> for ModuleReferencesVisitor<'_> {
177177
pub fn css_resolve(
178178
origin: Vc<Box<dyn ResolveOrigin>>,
179179
request: Vc<Request>,
180-
ty: Value<CssReferenceSubType>,
180+
ty: CssReferenceSubType,
181181
issue_source: Option<IssueSource>,
182182
) -> Vc<ModuleResolveResult> {
183-
url_resolve(
184-
origin,
185-
request,
186-
ReferenceType::Css(ty.into_value()),
187-
issue_source,
188-
false,
189-
)
183+
url_resolve(origin, request, ReferenceType::Css(ty), issue_source, false)
190184
}

turbopack/crates/turbopack-tests/tests/execution.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
1313
use tracing_subscriber::{Registry, layer::SubscriberExt, util::SubscriberInitExt};
1414
use turbo_rcstr::{RcStr, rcstr};
1515
use turbo_tasks::{
16-
Completion, NonLocalValue, OperationVc, ResolvedVc, TryJoinIterExt, TurboTasks, Value, Vc,
16+
Completion, NonLocalValue, OperationVc, ResolvedVc, TaskInput, TryJoinIterExt, TurboTasks, Vc,
1717
apply_effects, debug::ValueDebugFormat, fxindexmap, trace::TraceRawVcs,
1818
};
1919
use turbo_tasks_backend::{BackendOptions, TurboTasksBackend, noop_backing_storage};
@@ -74,7 +74,7 @@ struct JsResult {
7474
}
7575

7676
#[turbo_tasks::value]
77-
#[derive(Copy, Clone, Debug, Hash)]
77+
#[derive(Copy, Clone, Debug, Hash, TaskInput)]
7878
enum IssueSnapshotMode {
7979
Snapshots,
8080
NoSnapshots,
@@ -200,8 +200,7 @@ async fn run(resource: PathBuf, snapshot_mode: IssueSnapshotMode) -> Result<JsRe
200200
));
201201
let result = tt
202202
.run_once(async move {
203-
let emit_op =
204-
run_inner_operation(resource.to_str().unwrap().into(), Value::new(snapshot_mode));
203+
let emit_op = run_inner_operation(resource.to_str().unwrap().into(), snapshot_mode);
205204
let result = emit_op.read_strongly_consistent().owned().await?;
206205
apply_effects(emit_op).await?;
207206

@@ -217,11 +216,11 @@ async fn run(resource: PathBuf, snapshot_mode: IssueSnapshotMode) -> Result<JsRe
217216
#[turbo_tasks::function(operation)]
218217
async fn run_inner_operation(
219218
resource: RcStr,
220-
snapshot_mode: Value<IssueSnapshotMode>,
219+
snapshot_mode: IssueSnapshotMode,
221220
) -> Result<Vc<JsResult>> {
222221
let prepared_test = prepare_test(resource).to_resolved().await?;
223222
let run_result_op = run_test_operation(prepared_test);
224-
if *snapshot_mode == IssueSnapshotMode::Snapshots {
223+
if snapshot_mode == IssueSnapshotMode::Snapshots {
225224
snapshot_issues(*prepared_test, run_result_op).await?;
226225
}
227226

0 commit comments

Comments
 (0)