Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove static_assertions dependency #10348

Merged
merged 1 commit into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ lzma-rs = {version = "0.3.0", optional = true }
dasp = { git = "https://github.com/RustAudio/dasp", rev = "f05a703", features = ["interpolate", "interpolate-linear", "signal"], optional = true }
symphonia = { version = "0.5.2", default-features = false, features = ["mp3"], optional = true }
enumset = "1.0.12"
static_assertions = "1.1.0"
rustversion = "1.0.12"
bytemuck = "1.13.1"
clap = { version = "4.1.11", features = ["derive"], optional=true }
realfft = "3.2.0"
Expand Down
13 changes: 4 additions & 9 deletions core/src/avm2/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::avm2::Activation;
use crate::avm2::AvmString;
use crate::avm2::Multiname;
use crate::avm2::Value;
use std::mem::size_of;

use super::ClassObject;

Expand Down Expand Up @@ -34,17 +35,11 @@ impl<'gc> Error<'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_family = "wasm")]
const _: () = assert!(size_of::<Result<Value<'_>, Error<'_>>>() == 24);

#[rustversion::nightly]
#[cfg(target_arch = "wasm32")]
relrelb marked this conversation as resolved.
Show resolved Hide resolved
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]);
const _: () = assert!(size_of::<Result<Value<'_>, Error<'_>>>() == 32);

#[inline(never)]
#[cold]
Expand Down
12 changes: 4 additions & 8 deletions core/src/avm2/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::ecma_conversions::{f64_to_wrapping_i32, f64_to_wrapping_u32};
use crate::string::{AvmString, WStr};
use gc_arena::{Collect, GcCell, MutationContext};
use std::cell::Ref;
use std::mem::size_of;
use swf::avm2::types::{DefaultValue as AbcDefaultValue, Index};

use super::e4x::E4XNode;
Expand Down Expand Up @@ -49,16 +50,11 @@ pub enum Value<'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_family = "wasm")]
const _: () = assert!(size_of::<Value<'_>>() == 16);

#[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]);
const _: () = assert!(size_of::<Value<'_>>() == 24);

impl<'gc> From<AvmString<'gc>> for Value<'gc> {
fn from(string: AvmString<'gc>) -> Self {
Expand Down
3 changes: 0 additions & 3 deletions wstr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ homepage.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
static_assertions = "1.1.0"
9 changes: 4 additions & 5 deletions wstr/src/buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use alloc::borrow::ToOwned;
use alloc::string::String;
use alloc::vec::Vec;
use core::fmt;
use core::mem::{self, ManuallyDrop};
use core::mem::{self, size_of, ManuallyDrop};
use core::ops::{Deref, DerefMut};
use core::ptr::NonNull;
use static_assertions::assert_eq_size;

use super::utils::{encode_raw_utf16, split_ascii_prefix, split_ascii_prefix_bytes, DecodeAvmUtf8};
use super::{ptr, Units, WStr, MAX_STRING_LEN};
Expand All @@ -17,11 +16,11 @@ pub struct WString {
capacity: u32,
}

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

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

impl WString {
/// Creates a new empty `WString`.
Expand Down