diff --git a/crates/oxc_allocator/src/boxed.rs b/crates/oxc_allocator/src/boxed.rs index 1932cd32d8a97..03eabaaff0fac 100644 --- a/crates/oxc_allocator/src/boxed.rs +++ b/crates/oxc_allocator/src/boxed.rs @@ -182,15 +182,9 @@ impl Debug for Box<'_, T> { // } #[cfg(any(feature = "serialize", test))] -impl Serialize for Box<'_, T> -where - T: Serialize, -{ - fn serialize(&self, s: S) -> Result - where - S: Serializer, - { - self.deref().serialize(s) +impl Serialize for Box<'_, T> { + fn serialize(&self, serializer: S) -> Result { + self.deref().serialize(serializer) } } diff --git a/crates/oxc_allocator/src/serialize.rs b/crates/oxc_allocator/src/serialize.rs deleted file mode 100644 index 584ded1e1b3a6..0000000000000 --- a/crates/oxc_allocator/src/serialize.rs +++ /dev/null @@ -1,31 +0,0 @@ -use serde::{ser::SerializeSeq, Serialize, Serializer}; - -use crate::Box; - -impl<'alloc, T> Serialize for Box<'alloc, T> -where - T: Serialize, -{ - fn serialize(&self, s: S) -> Result - where - S: Serializer, - { - self.0.serialize(s) - } -} - -impl<'alloc, T> Serialize for Vec<'alloc, T> -where - T: Serialize, -{ - fn serialize(&self, s: S) -> Result - where - S: Serializer, - { - let mut seq = s.serialize_seq(Some(self.0.len()))?; - for e in self.0.iter() { - seq.serialize_element(e)?; - } - seq.end() - } -} diff --git a/crates/oxc_allocator/src/vec.rs b/crates/oxc_allocator/src/vec.rs index 5ff17ce1400f5..2ab4493c3f7d7 100644 --- a/crates/oxc_allocator/src/vec.rs +++ b/crates/oxc_allocator/src/vec.rs @@ -18,7 +18,7 @@ use std::{ use allocator_api2::vec::Vec as InnerVec; use bumpalo::Bump; #[cfg(any(feature = "serialize", test))] -use serde::{ser::SerializeSeq, Serialize, Serializer}; +use serde::{Serialize, Serializer}; use crate::{Allocator, Box}; @@ -273,19 +273,9 @@ where } #[cfg(any(feature = "serialize", test))] -impl Serialize for Vec<'_, T> -where - T: Serialize, -{ - fn serialize(&self, s: S) -> Result - where - S: Serializer, - { - let mut seq = s.serialize_seq(Some(self.0.len()))?; - for e in self.0.iter() { - seq.serialize_element(e)?; - } - seq.end() +impl Serialize for Vec<'_, T> { + fn serialize(&self, serializer: S) -> Result { + self.as_slice().serialize(serializer) } } diff --git a/crates/oxc_linter/src/config/overrides.rs b/crates/oxc_linter/src/config/overrides.rs index 86b8919efa345..b625e4326aa8d 100644 --- a/crates/oxc_linter/src/config/overrides.rs +++ b/crates/oxc_linter/src/config/overrides.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, ops::Deref, path::Path}; use nonmax::NonMaxU32; use schemars::{gen, schema::Schema, JsonSchema}; -use serde::{de, ser, Deserialize, Serialize}; +use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use oxc_index::{Idx, IndexVec}; @@ -126,20 +126,14 @@ impl GlobSet { } } -impl ser::Serialize for GlobSet { - fn serialize(&self, serializer: S) -> Result - where - S: ser::Serializer, - { +impl Serialize for GlobSet { + fn serialize(&self, serializer: S) -> Result { self.raw.serialize(serializer) } } -impl<'de> de::Deserialize<'de> for GlobSet { - fn deserialize(deserializer: D) -> Result - where - D: de::Deserializer<'de>, - { +impl<'de> Deserialize<'de> for GlobSet { + fn deserialize>(deserializer: D) -> Result { let globs = Vec::::deserialize(deserializer)?; Self::new(globs).map_err(de::Error::custom) } diff --git a/crates/oxc_linter/src/config/rules.rs b/crates/oxc_linter/src/config/rules.rs index b46a27b2aa66d..a5e72eb250f4b 100644 --- a/crates/oxc_linter/src/config/rules.rs +++ b/crates/oxc_linter/src/config/rules.rs @@ -5,7 +5,7 @@ use schemars::{gen::SchemaGenerator, schema::Schema, JsonSchema}; use serde::{ de::{self, Deserializer, Visitor}, ser::SerializeMap, - Deserialize, Serialize, + Deserialize, Serialize, Serializer, }; use oxc_diagnostics::{Error, OxcDiagnostic}; @@ -206,10 +206,7 @@ impl JsonSchema for OxlintRules { } impl Serialize for OxlintRules { - fn serialize(&self, s: S) -> Result - where - S: serde::Serializer, - { + fn serialize(&self, s: S) -> Result { let mut rules = s.serialize_map(Some(self.rules.len()))?; for rule in &self.rules { diff --git a/crates/oxc_linter/src/config/settings/next.rs b/crates/oxc_linter/src/config/settings/next.rs index 52e00d05b848c..0fa0255c5f889 100644 --- a/crates/oxc_linter/src/config/settings/next.rs +++ b/crates/oxc_linter/src/config/settings/next.rs @@ -53,10 +53,7 @@ impl Default for OneOrMany { } impl Serialize for OneOrMany { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { + fn serialize(&self, serializer: S) -> Result { match self { Self::One(val) => val.serialize(serializer), Self::Many(vec) => vec.serialize(serializer),