fix(ast): Add archive(check_bytes) to all relevant AST types (#9574)
Some checks failed
CI / Cargo fmt (push) Has been cancelled
CI / Cargo clippy (push) Has been cancelled
CI / Check license of dependencies (push) Has been cancelled
CI / Check (macos-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / Test wasm (binding_core_wasm) (push) Has been cancelled
CI / Test wasm (binding_minifier_wasm) (push) Has been cancelled
CI / Test wasm (binding_typescript_wasm) (push) Has been cancelled
CI / List crates (push) Has been cancelled
CI / Test node bindings - ${{ matrix.os }} (macos-latest) (push) Has been cancelled
CI / Test node bindings - ${{ matrix.os }} (windows-latest) (push) Has been cancelled
CI / Test with @swc/cli (push) Has been cancelled
CI / Miri (better_scoped_tls) (push) Has been cancelled
CI / Miri (string_enum) (push) Has been cancelled
CI / Miri (swc) (push) Has been cancelled
CI / Miri (swc_bundler) (push) Has been cancelled
CI / Miri (swc_ecma_codegen) (push) Has been cancelled
CI / Miri (swc_ecma_minifier) (push) Has been cancelled
Benchmark / Bench everything (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (push) Has been cancelled
CI / Done (push) Has been cancelled

**Description:**

1. all struct that support rkyv add `archive(check_bytes)`
2. all recursive struct that support rkyv add check_bytes bound

this PR will fix the error reported in https://github.com/swc-project/swc/pull/9562
This commit is contained in:
jinrui 2024-09-20 15:46:05 +08:00 committed by GitHub
parent 04016e9687
commit 185d6f55b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,8 @@
---
swc_core: patch
swc_common: patch
swc_ecma_ast: patch
swc_html_ast: patch
---
fix: all struct that support rkyv add `archive(check_bytes)`

View File

@ -23,9 +23,15 @@ pub struct Tuple(#[span] HasSpan, usize, usize);
archive(bound(serialize = "__S: rkyv::ser::Serializer + rkyv::ser::ScratchSpace"))
)]
#[cfg_attr(feature = "rkyv-impl", archive(check_bytes))]
#[cfg_attr(
feature = "rkyv-impl",
archive_attr(check_bytes(bound = "__C: rkyv::validation::ArchiveContext, <__C as \
rkyv::Fallible>::Error: std::error::Error"))
)]
#[cfg_attr(feature = "rkyv-impl", archive_attr(repr(C)))]
pub struct HasSpan {
#[cfg_attr(feature = "__rkyv", omit_bounds)]
#[cfg_attr(feature = "__rkyv", archive_attr(omit_bounds))]
pub span: Span,
}

View File

@ -1277,15 +1277,22 @@ impl Take for Import {
archive(bound(serialize = "__S: rkyv::ser::ScratchSpace + rkyv::ser::Serializer"))
)]
#[cfg_attr(feature = "rkyv-impl", archive(check_bytes))]
#[cfg_attr(
feature = "rkyv-impl",
archive_attr(check_bytes(bound = "__C: rkyv::validation::ArchiveContext, <__C as \
rkyv::Fallible>::Error: std::error::Error"))
)]
#[cfg_attr(feature = "rkyv-impl", archive_attr(repr(C)))]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub struct ExprOrSpread {
#[cfg_attr(feature = "serde-impl", serde(default))]
#[cfg_attr(feature = "__rkyv", omit_bounds)]
#[cfg_attr(feature = "__rkyv", archive_attr(omit_bounds))]
pub spread: Option<Span>,
#[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
#[cfg_attr(feature = "__rkyv", omit_bounds)]
#[cfg_attr(feature = "__rkyv", archive_attr(omit_bounds))]
pub expr: Box<Expr>,
}

View File

@ -24,15 +24,22 @@ use crate::{typescript::TsTypeAnn, Expr};
archive(bound(serialize = "__S: rkyv::ser::ScratchSpace + rkyv::ser::Serializer"))
)]
#[cfg_attr(feature = "rkyv-impl", archive(check_bytes))]
#[cfg_attr(
feature = "rkyv-impl",
archive_attr(check_bytes(bound = "__C: rkyv::validation::ArchiveContext, <__C as \
rkyv::Fallible>::Error: std::error::Error"))
)]
#[cfg_attr(feature = "rkyv-impl", archive_attr(repr(C)))]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub struct BindingIdent {
#[cfg_attr(feature = "serde-impl", serde(flatten))]
#[cfg_attr(feature = "__rkyv", omit_bounds)]
#[cfg_attr(feature = "__rkyv", archive_attr(omit_bounds))]
pub id: Ident,
#[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
#[cfg_attr(feature = "__rkyv", omit_bounds)]
#[cfg_attr(feature = "__rkyv", archive_attr(omit_bounds))]
pub type_ann: Option<Box<TsTypeAnn>>,
}

View File

@ -23,6 +23,7 @@ pub struct DocumentFragment {
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
)]
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
#[cfg_attr(
feature = "rkyv",
archive(bound(serialize = "__S: rkyv::ser::ScratchSpace + rkyv::ser::Serializer"))
@ -75,6 +76,7 @@ impl EqIgnoreSpan for DocumentType {
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
)]
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
#[cfg_attr(
feature = "rkyv",
archive(bound(serialize = "__S: rkyv::ser::ScratchSpace + rkyv::ser::Serializer"))

View File

@ -29,6 +29,7 @@ pub struct AttributeToken {
feature = "rkyv",
archive(bound(serialize = "__S: rkyv::ser::ScratchSpace + rkyv::ser::Serializer"))
)]
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum Raw {
Same,
@ -44,6 +45,7 @@ pub enum Raw {
feature = "rkyv",
archive(bound(serialize = "__S: rkyv::ser::ScratchSpace + rkyv::ser::Serializer"))
)]
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum Token {
Doctype {