Add size assertions for Result<Value, Error> and Value
This commit is contained in:
parent
93b7de2fe6
commit
e99c7fa4af
|
@ -3100,9 +3100,11 @@ dependencies = [
|
|||
"ruffle_render",
|
||||
"ruffle_video",
|
||||
"ruffle_wstr",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"smallvec",
|
||||
"static_assertions",
|
||||
"swf",
|
||||
"symphonia",
|
||||
"thiserror",
|
||||
|
@ -3355,6 +3357,12 @@ dependencies = [
|
|||
"transpose",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.10"
|
||||
|
|
|
@ -43,6 +43,8 @@ lzma-rs = {version = "0.2.0", optional = true }
|
|||
dasp = { git = "https://github.com/RustAudio/dasp", rev = "f05a703", features = ["interpolate", "interpolate-linear", "signal"], optional = true }
|
||||
symphonia = { version = "0.5.1", default-features = false, features = ["mp3"], optional = true }
|
||||
enumset = "1.0.11"
|
||||
static_assertions = "1.1.0"
|
||||
rustversion = "1.0.9"
|
||||
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies.futures]
|
||||
version = "0.3.24"
|
||||
|
|
|
@ -18,6 +18,19 @@ pub enum Error<'gc> {
|
|||
RustError(Box<dyn std::error::Error>),
|
||||
}
|
||||
|
||||
// This type is used very frequently, so make sure it doesn't unexpectedly grow.
|
||||
// For now, we only test on Nightly, since a new niche optimization was recently
|
||||
// added (https://github.com/rust-lang/rust/pull/94075) that shrinks the size
|
||||
// relative to stable.
|
||||
|
||||
#[rustversion::nightly]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
static_assertions::assert_eq_size!(Result<Value<'_>, Error<'_>>, [u8; 24]);
|
||||
|
||||
#[rustversion::nightly]
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
static_assertions::assert_eq_size!(Result<Value<'_>, Error<'_>>, [u8; 32]);
|
||||
|
||||
#[inline(never)]
|
||||
#[cold]
|
||||
pub fn range_error<'gc>(
|
||||
|
|
|
@ -45,6 +45,18 @@ pub enum Value<'gc> {
|
|||
Object(Object<'gc>),
|
||||
}
|
||||
|
||||
// This type is used very frequently, so make sure it doesn't unexpectedly grow.
|
||||
// For now, we only test on Nightly, since a new niche optimization was recently
|
||||
// added (https://github.com/rust-lang/rust/pull/94075) that shrinks the size
|
||||
// relative to stable.
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
static_assertions::assert_eq_size!(Value<'_>, [u8; 16]);
|
||||
|
||||
#[rustversion::nightly]
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
static_assertions::assert_eq_size!(Value<'_>, [u8; 24]);
|
||||
|
||||
impl<'gc> From<AvmString<'gc>> for Value<'gc> {
|
||||
fn from(string: AvmString<'gc>) -> Self {
|
||||
Value::String(string)
|
||||
|
|
Loading…
Reference in New Issue