Unverified Commit 137dbec7 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

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`.
parent 1db1762a
...@@ -2,7 +2,6 @@ use std::{ ...@@ -2,7 +2,6 @@ use std::{
any::{Any, type_name}, any::{Any, type_name},
fmt::{self, Debug, Display, Formatter}, fmt::{self, Debug, Display, Formatter},
hash::Hash, hash::Hash,
sync::Arc,
}; };
use auto_hash_map::{AutoMap, AutoSet}; use auto_hash_map::{AutoMap, AutoSet};
...@@ -10,16 +9,11 @@ use serde::{Deserialize, Serialize}; ...@@ -10,16 +9,11 @@ use serde::{Deserialize, Serialize};
use tracing::Span; use tracing::Span;
use crate::{ use crate::{
RawVc, VcValueType, RawVc, VcValueType, id::TraitTypeId, macro_helpers::NativeFunction,
id::TraitTypeId, magic_any::AnyDeserializeSeed, registry, task::shared_reference::TypedSharedReference,
macro_helpers::NativeFunction,
magic_any::{AnyDeserializeSeed, MagicAny, MagicAnyDeserializeSeed},
registry,
task::shared_reference::TypedSharedReference,
vc::VcCellMode, vc::VcCellMode,
}; };
type MagicSerializationFn = fn(&dyn MagicAny) -> &dyn erased_serde::Serialize;
type AnySerializationFn = fn(&(dyn Any + Sync + Send)) -> &dyn erased_serde::Serialize; type AnySerializationFn = fn(&(dyn Any + Sync + Send)) -> &dyn erased_serde::Serialize;
type RawCellFactoryFn = fn(TypedSharedReference) -> RawVc; type RawCellFactoryFn = fn(TypedSharedReference) -> RawVc;
...@@ -43,7 +37,6 @@ pub struct ValueType { ...@@ -43,7 +37,6 @@ pub struct ValueType {
trait_methods: AutoMap<&'static TraitMethod, &'static NativeFunction>, trait_methods: AutoMap<&'static TraitMethod, &'static NativeFunction>,
/// Functors for serialization /// Functors for serialization
magic_serialization: Option<(MagicSerializationFn, MagicAnyDeserializeSeed)>,
any_serialization: Option<(AnySerializationFn, AnyDeserializeSeed)>, any_serialization: Option<(AnySerializationFn, AnyDeserializeSeed)>,
/// An implementation of /// An implementation of
...@@ -113,7 +106,6 @@ impl ValueType { ...@@ -113,7 +106,6 @@ impl ValueType {
global_name, global_name,
traits: AutoSet::new(), traits: AutoSet::new(),
trait_methods: AutoMap::new(), trait_methods: AutoMap::new(),
magic_serialization: None,
any_serialization: None, any_serialization: None,
raw_cell: <T::CellMode as VcCellMode<T>>::raw_cell, raw_cell: <T::CellMode as VcCellMode<T>>::raw_cell,
} }
...@@ -130,24 +122,11 @@ impl ValueType { ...@@ -130,24 +122,11 @@ impl ValueType {
global_name, global_name,
traits: AutoSet::new(), traits: AutoSet::new(),
trait_methods: AutoMap::new(), trait_methods: AutoMap::new(),
magic_serialization: None,
any_serialization: Some((any_as_serialize::<T>, AnyDeserializeSeed::new::<T>())), any_serialization: Some((any_as_serialize::<T>, AnyDeserializeSeed::new::<T>())),
raw_cell: <T::CellMode as VcCellMode<T>>::raw_cell, raw_cell: <T::CellMode as VcCellMode<T>>::raw_cell,
} }
} }
pub fn magic_as_serializable<'a>(
&self,
arc: &'a Arc<dyn MagicAny>,
) -> Option<&'a dyn erased_serde::Serialize> {
if let Some(s) = self.magic_serialization {
let r: &dyn MagicAny = arc;
Some((s.0)(r))
} else {
None
}
}
pub fn any_as_serializable<'a>( pub fn any_as_serializable<'a>(
&self, &self,
arc: &'a triomphe::Arc<dyn Any + Sync + Send>, arc: &'a triomphe::Arc<dyn Any + Sync + Send>,
...@@ -163,10 +142,6 @@ impl ValueType { ...@@ -163,10 +142,6 @@ impl ValueType {
self.any_serialization.is_some() self.any_serialization.is_some()
} }
pub fn get_magic_deserialize_seed(&self) -> Option<MagicAnyDeserializeSeed> {
self.magic_serialization.map(|s| s.1)
}
pub fn get_any_deserialize_seed(&self) -> Option<AnyDeserializeSeed> { pub fn get_any_deserialize_seed(&self) -> Option<AnyDeserializeSeed> {
self.any_serialization.map(|s| s.1) self.any_serialization.map(|s| s.1)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment