Skip to content

Commit 384af89

Browse files
committed
chore: Remove static_assertions dependency
`static_assertions` seems unmaintained, and anyway `assert!()` is usable in `const` contexts since Rust 1.57.0: https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html#panic-in-const-contexts So simply use the suggested method instead. Also the `rustversion` dependency is no longer needed because rust-lang/rust#94075 already landed in stable.
1 parent c68a4b0 commit 384af89

File tree

6 files changed

+12
-32
lines changed

6 files changed

+12
-32
lines changed

Cargo.lock

-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ lzma-rs = {version = "0.3.0", optional = true }
4545
dasp = { git = "https://github.com/RustAudio/dasp", rev = "f05a703", features = ["interpolate", "interpolate-linear", "signal"], optional = true }
4646
symphonia = { version = "0.5.2", default-features = false, features = ["mp3"], optional = true }
4747
enumset = "1.0.12"
48-
static_assertions = "1.1.0"
49-
rustversion = "1.0.12"
5048
bytemuck = "1.13.1"
5149
clap = { version = "4.1.11", features = ["derive"], optional=true }
5250
realfft = "3.2.0"

core/src/avm2/error.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::avm2::Activation;
33
use crate::avm2::AvmString;
44
use crate::avm2::Multiname;
55
use crate::avm2::Value;
6+
use std::mem::size_of;
67

78
use super::ClassObject;
89

@@ -34,17 +35,11 @@ impl<'gc> Error<'gc> {
3435
}
3536

3637
// This type is used very frequently, so make sure it doesn't unexpectedly grow.
37-
// For now, we only test on Nightly, since a new niche optimization was recently
38-
// added (https://github.com/rust-lang/rust/pull/94075) that shrinks the size
39-
// relative to stable.
38+
#[cfg(target_family = "wasm")]
39+
const _: () = assert!(size_of::<Result<Value<'_>, Error<'_>>>() == 24);
4040

41-
#[rustversion::nightly]
42-
#[cfg(target_arch = "wasm32")]
43-
static_assertions::assert_eq_size!(Result<Value<'_>, Error<'_>>, [u8; 24]);
44-
45-
#[rustversion::nightly]
4641
#[cfg(target_pointer_width = "64")]
47-
static_assertions::assert_eq_size!(Result<Value<'_>, Error<'_>>, [u8; 32]);
42+
const _: () = assert!(size_of::<Result<Value<'_>, Error<'_>>>() == 32);
4843

4944
#[inline(never)]
5045
#[cold]

core/src/avm2/value.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::ecma_conversions::{f64_to_wrapping_i32, f64_to_wrapping_u32};
1313
use crate::string::{AvmString, WStr};
1414
use gc_arena::{Collect, GcCell, MutationContext};
1515
use std::cell::Ref;
16+
use std::mem::size_of;
1617
use swf::avm2::types::{DefaultValue as AbcDefaultValue, Index};
1718

1819
use super::e4x::E4XNode;
@@ -49,16 +50,11 @@ pub enum Value<'gc> {
4950
}
5051

5152
// This type is used very frequently, so make sure it doesn't unexpectedly grow.
52-
// For now, we only test on Nightly, since a new niche optimization was recently
53-
// added (https://github.com/rust-lang/rust/pull/94075) that shrinks the size
54-
// relative to stable.
53+
#[cfg(target_family = "wasm")]
54+
const _: () = assert!(size_of::<Value<'_>>() == 16);
5555

56-
#[cfg(target_arch = "wasm32")]
57-
static_assertions::assert_eq_size!(Value<'_>, [u8; 16]);
58-
59-
#[rustversion::nightly]
6056
#[cfg(target_pointer_width = "64")]
61-
static_assertions::assert_eq_size!(Value<'_>, [u8; 24]);
57+
const _: () = assert!(size_of::<Value<'_>>() == 24);
6258

6359
impl<'gc> From<AvmString<'gc>> for Value<'gc> {
6460
fn from(string: AvmString<'gc>) -> Self {

wstr/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ homepage.workspace = true
66
license.workspace = true
77
repository.workspace = true
88
version.workspace = true
9-
10-
[dependencies]
11-
static_assertions = "1.1.0"

wstr/src/buf.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use alloc::borrow::ToOwned;
22
use alloc::string::String;
33
use alloc::vec::Vec;
44
use core::fmt;
5-
use core::mem::{self, ManuallyDrop};
5+
use core::mem::{self, size_of, ManuallyDrop};
66
use core::ops::{Deref, DerefMut};
77
use core::ptr::NonNull;
8-
use static_assertions::assert_eq_size;
98

109
use super::utils::{encode_raw_utf16, split_ascii_prefix, split_ascii_prefix_bytes, DecodeAvmUtf8};
1110
use super::{ptr, Units, WStr, MAX_STRING_LEN};
@@ -17,11 +16,11 @@ pub struct WString {
1716
capacity: u32,
1817
}
1918

20-
#[cfg(target_pointer_width = "32")]
21-
assert_eq_size!(WString, [u8; 12]);
19+
#[cfg(target_family = "wasm")]
20+
const _: () = assert!(size_of::<WString>() == 12);
2221

2322
#[cfg(target_pointer_width = "64")]
24-
assert_eq_size!(WString, [u8; 16]);
23+
const _: () = assert!(size_of::<WString>() == 16);
2524

2625
impl WString {
2726
/// Creates a new empty `WString`.

0 commit comments

Comments
 (0)