mirror of
https://github.com/swc-project/swc.git
synced 2024-11-29 11:47:21 +03:00
185d6f55b3
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
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
//! Test that `#[span]` and `#[fold]` can be used at same time.
|
|
use serde::{Deserialize, Serialize};
|
|
use swc_common::{ast_node, Span, Spanned};
|
|
|
|
#[ast_node("Class")]
|
|
// See https://github.com/rust-lang/rust/issues/44925
|
|
pub struct Class {
|
|
#[span]
|
|
pub has_span: HasSpan,
|
|
pub s: String,
|
|
}
|
|
|
|
#[ast_node("Tuple")]
|
|
pub struct Tuple(#[span] HasSpan, usize, usize);
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Spanned, Serialize, Deserialize)]
|
|
#[cfg_attr(
|
|
any(feature = "rkyv-impl"),
|
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
|
)]
|
|
#[cfg_attr(
|
|
any(feature = "rkyv-impl"),
|
|
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,
|
|
}
|
|
|
|
#[ast_node]
|
|
pub enum Node {
|
|
#[tag("Class")]
|
|
Class(Class),
|
|
#[tag("Tuple")]
|
|
Tuple(Tuple),
|
|
}
|