Skip to content

Commit 137dbec

Browse files
authored
Turbopack: chore: Remove some dead MagicAny serialization code from turbo_tasks::value (#85577)
Noticed this was dead while I was looking through how we might integrate bincode. We only ever use `any_serialization` and not `magic_serialization`. In theory, `magic_serialization` is slightly better because it can include the type name in the error message. If we go through with the bincode stuff, I'll replace `any_serialization` and the `MagicAny` serialization with something that doesn't depend on `erased-serde`.
1 parent 1db1762 commit 137dbec

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,18 @@ use std::{
22
any::{Any, type_name},
33
fmt::{self, Debug, Display, Formatter},
44
hash::Hash,
5-
sync::Arc,
65
};
76

87
use auto_hash_map::{AutoMap, AutoSet};
98
use serde::{Deserialize, Serialize};
109
use tracing::Span;
1110

1211
use crate::{
13-
RawVc, VcValueType,
14-
id::TraitTypeId,
15-
macro_helpers::NativeFunction,
16-
magic_any::{AnyDeserializeSeed, MagicAny, MagicAnyDeserializeSeed},
17-
registry,
18-
task::shared_reference::TypedSharedReference,
12+
RawVc, VcValueType, id::TraitTypeId, macro_helpers::NativeFunction,
13+
magic_any::AnyDeserializeSeed, registry, task::shared_reference::TypedSharedReference,
1914
vc::VcCellMode,
2015
};
2116

22-
type MagicSerializationFn = fn(&dyn MagicAny) -> &dyn erased_serde::Serialize;
2317
type AnySerializationFn = fn(&(dyn Any + Sync + Send)) -> &dyn erased_serde::Serialize;
2418
type RawCellFactoryFn = fn(TypedSharedReference) -> RawVc;
2519

@@ -43,7 +37,6 @@ pub struct ValueType {
4337
trait_methods: AutoMap<&'static TraitMethod, &'static NativeFunction>,
4438

4539
/// Functors for serialization
46-
magic_serialization: Option<(MagicSerializationFn, MagicAnyDeserializeSeed)>,
4740
any_serialization: Option<(AnySerializationFn, AnyDeserializeSeed)>,
4841

4942
/// An implementation of
@@ -113,7 +106,6 @@ impl ValueType {
113106
global_name,
114107
traits: AutoSet::new(),
115108
trait_methods: AutoMap::new(),
116-
magic_serialization: None,
117109
any_serialization: None,
118110
raw_cell: <T::CellMode as VcCellMode<T>>::raw_cell,
119111
}
@@ -130,24 +122,11 @@ impl ValueType {
130122
global_name,
131123
traits: AutoSet::new(),
132124
trait_methods: AutoMap::new(),
133-
magic_serialization: None,
134125
any_serialization: Some((any_as_serialize::<T>, AnyDeserializeSeed::new::<T>())),
135126
raw_cell: <T::CellMode as VcCellMode<T>>::raw_cell,
136127
}
137128
}
138129

139-
pub fn magic_as_serializable<'a>(
140-
&self,
141-
arc: &'a Arc<dyn MagicAny>,
142-
) -> Option<&'a dyn erased_serde::Serialize> {
143-
if let Some(s) = self.magic_serialization {
144-
let r: &dyn MagicAny = arc;
145-
Some((s.0)(r))
146-
} else {
147-
None
148-
}
149-
}
150-
151130
pub fn any_as_serializable<'a>(
152131
&self,
153132
arc: &'a triomphe::Arc<dyn Any + Sync + Send>,
@@ -163,10 +142,6 @@ impl ValueType {
163142
self.any_serialization.is_some()
164143
}
165144

166-
pub fn get_magic_deserialize_seed(&self) -> Option<MagicAnyDeserializeSeed> {
167-
self.magic_serialization.map(|s| s.1)
168-
}
169-
170145
pub fn get_any_deserialize_seed(&self) -> Option<AnyDeserializeSeed> {
171146
self.any_serialization.map(|s| s.1)
172147
}

0 commit comments

Comments
 (0)