Skip to content

Commit 38d0a44

Browse files
committed
Remove the _for_input options from turbo_tasks::value and the TypedForInput trait.
Now that `Value` is dead it appears there is no need for these.
1 parent 6a94b9b commit 38d0a44

File tree

18 files changed

+44
-80
lines changed

18 files changed

+44
-80
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use anyhow::Result;
2-
use turbo_tasks::{ResolvedVc, TaskInput, Vc, fxindexmap};
2+
use serde::{Deserialize, Serialize};
3+
use turbo_tasks::{NonLocalValue, ResolvedVc, TaskInput, Vc, fxindexmap, trace::TraceRawVcs};
34
use turbopack::{ModuleAssetContext, module_options::CustomModuleType};
45
use turbopack_core::{
56
context::AssetContext, module::Module, reference_type::ReferenceType, resolve::ModulePart,
@@ -9,8 +10,21 @@ use turbopack_static::ecma::StaticUrlJsModule;
910

1011
use super::source_asset::StructuredImageFileSource;
1112

12-
#[turbo_tasks::value(serialization = "auto_for_input")]
13-
#[derive(Clone, Copy, Debug, PartialOrd, Ord, Hash, TaskInput)]
13+
#[derive(
14+
Eq,
15+
PartialEq,
16+
Clone,
17+
Copy,
18+
Debug,
19+
PartialOrd,
20+
Ord,
21+
Hash,
22+
TaskInput,
23+
TraceRawVcs,
24+
NonLocalValue,
25+
Serialize,
26+
Deserialize,
27+
)]
1428
pub enum BlurPlaceholderMode {
1529
/// Do not generate a blur placeholder at all.
1630
None,

turbopack/crates/turbo-tasks-macros/src/value_macro.rs

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ impl TryFrom<LitStr> for CellMode {
7272
enum SerializationMode {
7373
None,
7474
Auto,
75-
AutoForInput,
7675
Custom,
77-
CustomForInput,
7876
}
7977

8078
impl Parse for SerializationMode {
@@ -91,13 +89,10 @@ impl TryFrom<LitStr> for SerializationMode {
9189
match lit.value().as_str() {
9290
"none" => Ok(SerializationMode::None),
9391
"auto" => Ok(SerializationMode::Auto),
94-
"auto_for_input" => Ok(SerializationMode::AutoForInput),
9592
"custom" => Ok(SerializationMode::Custom),
96-
"custom_for_input" => Ok(SerializationMode::CustomForInput),
9793
_ => Err(Error::new_spanned(
9894
&lit,
99-
"expected \"none\", \"auto\", \"auto_for_input\", \"custom\" or \
100-
\"custom_for_input\"",
95+
"expected \"none\", \"auto\", or \"custom\"",
10196
)),
10297
}
10398
}
@@ -358,17 +353,14 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
358353
#[shrink_to_fit(crate = "turbo_tasks::macro_helpers::shrink_to_fit")]
359354
}];
360355
match serialization_mode {
361-
SerializationMode::Auto | SerializationMode::AutoForInput => {
362-
struct_attributes.push(quote! {
363-
#[derive(
364-
turbo_tasks::macro_helpers::serde::Serialize,
365-
turbo_tasks::macro_helpers::serde::Deserialize,
366-
)]
367-
#[serde(crate = "turbo_tasks::macro_helpers::serde")]
368-
})
369-
}
370-
SerializationMode::None | SerializationMode::Custom | SerializationMode::CustomForInput => {
371-
}
356+
SerializationMode::Auto => struct_attributes.push(quote! {
357+
#[derive(
358+
turbo_tasks::macro_helpers::serde::Serialize,
359+
turbo_tasks::macro_helpers::serde::Deserialize,
360+
)]
361+
#[serde(crate = "turbo_tasks::macro_helpers::serde")]
362+
}),
363+
SerializationMode::None | SerializationMode::Custom => {}
372364
};
373365
if inner_type.is_some() {
374366
// Transparent structs have their own manual `ValueDebug` implementation.
@@ -404,18 +396,6 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
404396
turbo_tasks::ValueType::new_with_any_serialization::<#ident>()
405397
}
406398
}
407-
SerializationMode::AutoForInput | SerializationMode::CustomForInput => {
408-
quote! {
409-
turbo_tasks::ValueType::new_with_magic_serialization::<#ident>()
410-
}
411-
}
412-
};
413-
414-
let for_input_marker = match serialization_mode {
415-
SerializationMode::None | SerializationMode::Auto | SerializationMode::Custom => quote! {},
416-
SerializationMode::AutoForInput | SerializationMode::CustomForInput => quote! {
417-
impl turbo_tasks::TypedForInput for #ident {}
418-
},
419399
};
420400

421401
let value_debug_impl = if inner_type.is_some() {
@@ -462,8 +442,6 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
462442

463443
#value_type_and_register_code
464444

465-
#for_input_marker
466-
467445
#value_debug_impl
468446
};
469447

turbopack/crates/turbo-tasks-testing/tests/all_in_one.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ async fn all_in_one() {
6363
.unwrap()
6464
}
6565

66-
#[turbo_tasks::value(transparent, serialization = "auto_for_input")]
66+
#[turbo_tasks::value(transparent)]
6767
#[derive(Debug, Clone, Hash)]
6868
struct MyTransparentValue(u32);
6969

70-
#[turbo_tasks::value(shared, serialization = "auto_for_input")]
70+
#[turbo_tasks::value(shared)]
7171
#[derive(Debug, Clone, Hash, TaskInput)]
7272
enum MyEnumValue {
7373
Yeah(u32),

turbopack/crates/turbo-tasks/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ pub use value::{TransientInstance, TransientValue};
127127
pub use value_type::{TraitMethod, TraitType, ValueType};
128128
pub use vc::{
129129
Dynamic, NonLocalValue, OperationValue, OperationVc, OptionVcExt, ReadVcFuture, ResolvedVc,
130-
TypedForInput, Upcast, ValueDefault, Vc, VcCast, VcCellNewMode, VcCellSharedMode,
131-
VcDefaultRead, VcRead, VcTransparentRead, VcValueTrait, VcValueTraitCast, VcValueType,
132-
VcValueTypeCast,
130+
Upcast, ValueDefault, Vc, VcCast, VcCellNewMode, VcCellSharedMode, VcDefaultRead, VcRead,
131+
VcTransparentRead, VcValueTrait, VcValueTraitCast, VcValueType, VcValueTypeCast,
133132
};
134133

135134
pub type SliceMap<K, V> = Box<[(K, V)]>;
@@ -239,11 +238,8 @@ macro_rules! fxindexset {
239238
/// required for persistent caching of tasks to disk.
240239
///
241240
/// - **`"auto"` *(default)*:** Derives the serialization traits and enables serialization.
242-
/// - **`"auto_for_input"`:** Same as `"auto"`, but also adds the marker trait [`TypedForInput`].
243241
/// - **`"custom"`:** Prevents deriving the serialization traits, but still enables serialization
244242
/// (you must manually implement [`serde::Serialize`] and [`serde::Deserialize`]).
245-
/// - **`"custom_for_input"`:** Same as `"custom"`, but also adds the marker trait
246-
/// [`TypedForInput`].
247243
/// - **`"none"`:** Disables serialization and prevents deriving the traits.
248244
///
249245
/// ## `shared`

turbopack/crates/turbo-tasks/src/value_type.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,6 @@ impl ValueType {
115115
}
116116
}
117117

118-
/// This is internally used by `#[turbo_tasks::value]`
119-
pub fn new_with_magic_serialization<
120-
T: VcValueType + Debug + Eq + Hash + Serialize + for<'de> Deserialize<'de> + TraceRawVcs,
121-
>() -> Self {
122-
Self {
123-
name: std::any::type_name::<T>().to_string(),
124-
traits: AutoSet::new(),
125-
trait_methods: AutoMap::new(),
126-
magic_serialization: Some((
127-
<dyn MagicAny>::as_serialize::<T>,
128-
MagicAnyDeserializeSeed::new::<T>(),
129-
)),
130-
any_serialization: Some((any_as_serialize::<T>, AnyDeserializeSeed::new::<T>())),
131-
raw_cell: <T::CellMode as VcCellMode<T>>::raw_cell,
132-
}
133-
}
134-
135118
/// This is internally used by `#[turbo_tasks::value]`
136119
pub fn new_with_any_serialization<
137120
T: VcValueType + Any + Serialize + for<'de> Deserialize<'de>,

turbopack/crates/turbo-tasks/src/vc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub use self::{
2828
operation::{OperationValue, OperationVc},
2929
read::{ReadOwnedVcFuture, ReadVcFuture, VcDefaultRead, VcRead, VcTransparentRead},
3030
resolved::ResolvedVc,
31-
traits::{Dynamic, TypedForInput, Upcast, VcValueTrait, VcValueType},
31+
traits::{Dynamic, Upcast, VcValueTrait, VcValueType},
3232
};
3333
use crate::{
3434
CellId, RawVc, ResolveTypeError,

turbopack/crates/turbo-tasks/src/vc/traits.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,3 @@ where
5454
T: VcValueTrait + ?Sized,
5555
{
5656
}
57-
58-
/// Marker trait that a turbo_tasks::value is prepared for serialization as
59-
/// [`Value<...>`][crate::Value] input.
60-
///
61-
/// Either use [`#[turbo_tasks::value(serialization = "auto_for_input")]`][macro@crate::value] or
62-
/// avoid [`Value<...>`][crate::Value] in favor of a real [Vc][crate::Vc].
63-
pub trait TypedForInput: VcValueType {}

turbopack/crates/turbopack-browser/src/chunking_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl BrowserChunkingContextBuilder {
171171
/// It also uses a chunking heuristic that is incremental and cacheable.
172172
/// It splits "node_modules" separately as these are less likely to change
173173
/// during development
174-
#[turbo_tasks::value(serialization = "auto_for_input")]
174+
#[turbo_tasks::value]
175175
#[derive(Debug, Clone, Hash, TaskInput)]
176176
pub struct BrowserChunkingContext {
177177
name: Option<RcStr>,

turbopack/crates/turbopack-core/src/compile_time_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl From<serde_json::Value> for CompileTimeDefineValue {
139139
}
140140
}
141141

142-
#[turbo_tasks::value(serialization = "auto_for_input")]
142+
#[turbo_tasks::value]
143143
#[derive(Debug, Clone, Hash)]
144144
pub enum DefineableNameSegment {
145145
Name(RcStr),

turbopack/crates/turbopack-core/src/environment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Environment {
5151
}
5252
}
5353

54-
#[turbo_tasks::value(serialization = "auto_for_input")]
54+
#[turbo_tasks::value]
5555
#[derive(Debug, Hash, Clone, Copy, TaskInput)]
5656
pub enum ExecutionEnvironment {
5757
NodeJsBuildTime(ResolvedVc<NodeJsEnvironment>),

turbopack/crates/turbopack-core/src/resolve/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pub enum ResolveResultItem {
483483
/// other factors like exports conditions that can affect resolting and become
484484
/// part of the key (assuming the condition is unknown at compile time)
485485
#[derive(Clone, Debug, Default, Hash)]
486-
#[turbo_tasks::value(serialization = "auto_for_input")]
486+
#[turbo_tasks::value]
487487
pub struct RequestKey {
488488
pub request: Option<RcStr>,
489489
pub conditions: BTreeMap<String, bool>,

turbopack/crates/turbopack-core/src/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt::Display;
33
use serde::{Deserialize, Serialize};
44
use turbo_tasks::{NonLocalValue, Vc, trace::TraceRawVcs};
55

6-
#[turbo_tasks::value(shared, serialization = "auto_for_input")]
6+
#[turbo_tasks::value(shared)]
77
#[derive(Hash, Debug, Copy, Clone)]
88
pub struct CompileTarget {
99
/// <https://nodejs.org/api/os.html#osarch>

turbopack/crates/turbopack-dev-server/src/source/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl ContentSourceDataFilter {
322322
/// Describes additional information that need to be sent to requests to
323323
/// ContentSource. By sending these information ContentSource responses are
324324
/// cached-keyed by them and they can access them.
325-
#[turbo_tasks::value(shared, serialization = "auto_for_input")]
325+
#[turbo_tasks::value(shared)]
326326
#[derive(Debug, Default, Clone, Hash)]
327327
pub struct ContentSourceDataVary {
328328
pub method: bool,

turbopack/crates/turbopack-ecmascript/src/analyzer/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::{
2323
tree_shake::{PartId, find_turbopack_part_id_in_asserts},
2424
};
2525

26-
#[turbo_tasks::value(serialization = "auto_for_input")]
26+
#[turbo_tasks::value]
2727
#[derive(Default, Debug, Clone, Hash)]
2828
pub struct ImportAnnotations {
2929
// TODO store this in more structured way

turbopack/crates/turbopack-ecmascript/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub enum TreeShakingMode {
157157
#[turbo_tasks::value(transparent)]
158158
pub struct OptionTreeShaking(pub Option<TreeShakingMode>);
159159

160-
#[turbo_tasks::value(shared, serialization = "auto_for_input")]
160+
#[turbo_tasks::value(shared)]
161161
#[derive(Hash, Debug, Default, Copy, Clone)]
162162
pub struct EcmascriptOptions {
163163
pub refresh: bool,
@@ -185,7 +185,7 @@ pub struct EcmascriptOptions {
185185
pub keep_last_successful_parse: bool,
186186
}
187187

188-
#[turbo_tasks::value(serialization = "auto_for_input")]
188+
#[turbo_tasks::value]
189189
#[derive(Hash, Debug, Copy, Clone, TaskInput)]
190190
pub enum EcmascriptModuleAssetType {
191191
/// Module with EcmaScript code

turbopack/crates/turbopack-ecmascript/src/transform/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use turbopack_core::{
2626
issue::{Issue, IssueSeverity, IssueStage, StyledString},
2727
};
2828

29-
#[turbo_tasks::value(serialization = "auto_for_input")]
29+
#[turbo_tasks::value]
3030
#[derive(Debug, Clone, Hash)]
3131
pub enum EcmascriptInputTransform {
3232
Plugin(ResolvedVc<TransformPlugin>),
@@ -88,7 +88,7 @@ impl CustomTransformer for TransformPlugin {
8888
}
8989
}
9090

91-
#[turbo_tasks::value(transparent, serialization = "auto_for_input")]
91+
#[turbo_tasks::value(transparent)]
9292
#[derive(Debug, Clone, Hash)]
9393
pub struct EcmascriptInputTransforms(Vec<EcmascriptInputTransform>);
9494

turbopack/crates/turbopack-nodejs/src/chunking_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl NodeJsChunkingContextBuilder {
9696
}
9797

9898
/// A chunking context for build mode.
99-
#[turbo_tasks::value(serialization = "auto_for_input")]
99+
#[turbo_tasks::value]
100100
#[derive(Debug, Clone, Hash, TaskInput)]
101101
pub struct NodeJsChunkingContext {
102102
/// The root path of the project

turbopack/crates/turbopack/src/module_options/module_rule.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub enum ModuleRuleEffect {
7676
Ignore,
7777
}
7878

79-
#[turbo_tasks::value(serialization = "auto_for_input", shared)]
79+
#[turbo_tasks::value(shared)]
8080
#[derive(Hash, Debug, Copy, Clone)]
8181
pub enum ModuleType {
8282
Ecmascript {

0 commit comments

Comments
 (0)