Remove static_assertions

This commit is contained in:
Ruihan Li
2025-03-03 10:40:40 +08:00
committed by Tate, Hongliang Tian
parent 0c028a7d8c
commit 9e1c939a3f
18 changed files with 31 additions and 33 deletions

11
Cargo.lock generated
View File

@ -85,7 +85,6 @@ dependencies = [
"ostd",
"smoltcp",
"spin",
"static_assertions",
"takeable",
]
@ -100,7 +99,6 @@ dependencies = [
"log",
"ostd",
"spin",
"static_assertions",
]
[[package]]
@ -162,7 +160,6 @@ dependencies = [
"ostd-pod",
"postcard",
"serde",
"static_assertions",
]
[[package]]
@ -219,7 +216,6 @@ dependencies = [
"rand",
"riscv",
"spin",
"static_assertions",
"takeable",
"tdx-guest",
"time",
@ -1296,7 +1292,6 @@ dependencies = [
"sbi-rt",
"smallvec",
"spin",
"static_assertions",
"tdx-guest",
"unwinding",
"volatile 0.6.1",
@ -1632,12 +1627,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.10.0"

View File

@ -52,7 +52,6 @@ rand = { version = "0.8.5", default-features = false, features = [
"small_rng",
"std_rng",
] }
static_assertions = "1.1.0"
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e" }
getset = "0.1.2"
takeable = "0.2.2"

View File

@ -12,7 +12,6 @@ align_ext = { path = "../../../ostd/libs/align_ext" }
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
component = { path = "../../libs/comp-sys/component" }
log = "0.4"
static_assertions = "1.1.0"
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
[lints]

View File

@ -5,8 +5,7 @@ use core::{
ops::{Add, Sub},
};
use ostd::Pod;
use static_assertions::const_assert;
use ostd::{const_assert, Pod};
/// The block index used in the filesystem.
pub type Bid = BlockId<BLOCK_SIZE>;

View File

@ -26,7 +26,6 @@ log = "0.4"
lru = "0.12.3"
postcard = "1.0.6"
serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] }
static_assertions = "1.1.0"
[lints]
workspace = true

View File

@ -2,13 +2,13 @@
//! The layer of untrusted block I/O.
use static_assertions::assert_eq_size;
mod block_buf;
mod block_log;
mod block_ring;
mod block_set;
use ostd::const_assert;
pub use self::{
block_buf::{Buf, BufMut, BufRef},
block_log::{BlockLog, MemLog},
@ -20,5 +20,5 @@ pub type BlockId = usize;
pub const BLOCK_SIZE: usize = 0x1000;
pub const BID_SIZE: usize = core::mem::size_of::<BlockId>();
// This definition of BlockId assumes the target architecture is 64-bit
assert_eq_size!(usize, u64);
// This definition of `BlockId` assumes the target architecture is 64-bit.
const_assert!(BID_SIZE == 8);

View File

@ -3,9 +3,9 @@
use alloc::vec;
use core::{any::Any, mem::size_of};
use ostd::const_assert;
use ostd_pod::Pod;
use serde::{Deserialize, Serialize};
use static_assertions::const_assert;
use super::{Iv, Key, Mac};
use crate::{

View File

@ -19,7 +19,6 @@ smoltcp = { git = "https://github.com/asterinas/smoltcp", tag = "r_2024-11-08_f0
"socket-tcp",
] }
spin = "0.9.4"
static_assertions = "1.1.0"
takeable = "0.2.2"
[lints]

View File

@ -7,8 +7,8 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec};
use core::net::Ipv4Addr;
use jhash::{jhash_1vals, jhash_3vals};
use ostd::const_assert;
use smoltcp::wire::{IpAddress, IpEndpoint, IpListenEndpoint};
use static_assertions::const_assert;
use crate::{
ext::Ext,

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
use id_alloc::IdAlloc;
use ostd::mm::UntypedMem;
use ostd::{const_assert, mm::UntypedMem};
use super::{
block_ptr::Ext2Bid,

View File

@ -7,7 +7,7 @@ use alloc::{borrow::ToOwned, rc::Rc};
use core::sync::atomic::{AtomicUsize, Ordering};
use inherit_methods_macro::inherit_methods;
use ostd::mm::UntypedMem;
use ostd::{const_assert, mm::UntypedMem};
use super::{
block_ptr::{BidPath, BlockPtrs, Ext2Bid, BID_SIZE, MAX_BLOCK_PTRS},

View File

@ -16,7 +16,6 @@ pub(super) use ostd::{
mm::{Frame, FrameAllocOptions, Segment, USegment, VmIo},
sync::{RwMutex, RwMutexReadGuard, RwMutexWriteGuard},
};
pub(super) use static_assertions::const_assert;
pub(super) use super::utils::{Dirty, IsPowerOf};
pub(super) use crate::{

View File

@ -1,5 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
use ostd::const_assert;
use super::{inode::RawInode, prelude::*};
/// The magic number of Ext2.

View File

@ -35,7 +35,6 @@ ostd-test = { version = "0.11.3", path = "libs/ostd-test" }
ostd-pod = { git = "https://github.com/asterinas/ostd-pod", rev = "c4644be", version = "0.1.1" }
spin = "0.9.4"
smallvec = "1.13.2"
static_assertions = "1.1.0"
unwinding = { version = "0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
volatile = "0.6.1"
xarray = { git = "https://github.com/asterinas/xarray", version = "0.1.0" }

View File

@ -5,9 +5,9 @@
use core::sync::atomic::{AtomicU64, Ordering};
use smallvec::SmallVec;
use static_assertions::const_assert_eq;
use super::{num_cpus, CpuId};
use crate::const_assert;
/// A subset of all CPUs in the system.
#[derive(Clone, Debug, Default)]
@ -159,7 +159,7 @@ pub struct AtomicCpuSet {
}
type AtomicInnerPart = AtomicU64;
const_assert_eq!(core::mem::size_of::<AtomicInnerPart>() * 8, BITS_PER_PART);
const_assert!(core::mem::size_of::<AtomicInnerPart>() * 8 == BITS_PER_PART);
impl AtomicCpuSet {
/// Creates a new `AtomicCpuSet` with an initial value.

View File

@ -24,7 +24,6 @@
#![warn(missing_docs)]
extern crate alloc;
extern crate static_assertions;
pub mod arch;
pub mod boot;

View File

@ -49,11 +49,11 @@ use core::{
use align_ext::AlignExt;
use log::info;
use static_assertions::const_assert_eq;
use super::{allocator, Segment};
use crate::{
arch::mm::PagingConsts,
const_assert,
mm::{
kspace::LINEAR_MAPPING_BASE_VADDR, paddr_to_vaddr, page_size, page_table::boot_pt,
CachePolicy, Infallible, Paddr, PageFlags, PageProperty, PrivilegedPageFlags, Vaddr,
@ -124,8 +124,8 @@ pub(super) const REF_COUNT_MAX: u64 = i64::MAX as u64;
type FrameMetaVtablePtr = core::ptr::DynMetadata<dyn AnyFrameMeta>;
const_assert_eq!(PAGE_SIZE % META_SLOT_SIZE, 0);
const_assert_eq!(size_of::<MetaSlot>(), META_SLOT_SIZE);
const_assert!(PAGE_SIZE % META_SLOT_SIZE == 0);
const_assert!(size_of::<MetaSlot>() == META_SLOT_SIZE);
/// All frame metadata types must implement this trait.
///

View File

@ -1,5 +1,20 @@
// SPDX-License-Identifier: MPL-2.0
/// Asserts that a boolean expression is `true` at compile-time.
///
/// Rust provides [`const` blocks], which can be used flexibly within methods, but cannot be used
/// directly at the top level. This macro serves as a helper to perform compile-time assertions
/// outside of methods.
///
/// [`const` blocks]: https://doc.rust-lang.org/reference/expressions/block-expr.html#const-blocks
//
// TODO: Introduce `const_assert_eq!()` once `assert_eq!()` can be used in the `const` context.
#[macro_export]
macro_rules! const_assert {
($cond:expr $(,)?) => { const _: () = assert!($cond); };
($cond:expr, $($arg:tt)+) => { const _: () = assert!($cond, $($arg)*); };
}
/// A marker trait that represents a type has the same size as `T`.
///
/// # Safety