From ceaea32278bc6eafcc838961309d38ff9959e71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Juli=C3=A1n=20Espina?= Date: Wed, 29 Mar 2023 22:36:29 +0000 Subject: [PATCH] Fix deserialization of `SpecEdition` (#2762) `boa_tester` wasn't deserializing `SpecEdition` correcly. This was because the attribute `serde(untagged)` just removes the u8 tag instead of trying to deserialize as a number. This PR fixes this using the `serde_repr` crate. This needs #2763 to be merged for it to pass CI. --- Cargo.lock | 12 ++++++++++++ boa_tester/Cargo.toml | 1 + boa_tester/src/edition.rs | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 430836c34f..f49c8c3aef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -522,6 +522,7 @@ dependencies = [ "regex", "serde", "serde_json", + "serde_repr", "serde_yaml", "toml 0.7.3", ] @@ -3616,6 +3617,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.11", +] + [[package]] name = "serde_spanned" version = "0.6.1" diff --git a/boa_tester/Cargo.toml b/boa_tester/Cargo.toml index 3ad26465b2..68c80ceb17 100644 --- a/boa_tester/Cargo.toml +++ b/boa_tester/Cargo.toml @@ -28,6 +28,7 @@ toml = "0.7.3" color-eyre = "0.6.2" phf = { version = "0.11.1", features = ["macros"] } comfy-table = "6.1.4" +serde_repr = "0.1.12" [features] default = ["intl"] diff --git a/boa_tester/src/edition.rs b/boa_tester/src/edition.rs index a9ea532708..38cd0fd538 100644 --- a/boa_tester/src/edition.rs +++ b/boa_tester/src/edition.rs @@ -5,7 +5,7 @@ use std::fmt::Display; -use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; use crate::read::{MetaData, TestFlag}; @@ -270,11 +270,11 @@ static FEATURE_EDITION: phf::Map<&'static str, SpecEdition> = phf::phf_map! { PartialOrd, Ord, Default, - Serialize, - Deserialize, + Serialize_repr, + Deserialize_repr, clap::ValueEnum, )] -#[serde(untagged)] +#[repr(u8)] pub(crate) enum SpecEdition { /// ECMAScript 5.1 Edition ///