Remove dependency on more-asserts (#4408)

* Remove dependency on `more-asserts`

In my recent adventures to do a bit of gardening on our dependencies I
noticed that there's a new major version for the `more-asserts` crate.
Instead of updating to this though I've opted to instead remove the
dependency since I don't think we heavily lean on this crate and
otherwise one-off prints are probably sufficient to avoid the need for
pulling in a whole crate for this.

* Remove exemption for `more-asserts`
This commit is contained in:
Alex Crichton
2022-07-26 11:47:33 -05:00
committed by GitHub
parent 1183191d7d
commit 1321c234e5
42 changed files with 125 additions and 227 deletions

View File

@@ -16,7 +16,6 @@ use crate::{
};
use anyhow::Error;
use memoffset::offset_of;
use more_asserts::assert_lt;
use std::alloc::Layout;
use std::any::Any;
use std::convert::TryFrom;
@@ -364,7 +363,7 @@ impl Instance {
)
.unwrap(),
);
assert_lt!(index.index(), self.tables.len());
assert!(index.index() < self.tables.len());
index
}

View File

@@ -9,7 +9,6 @@ use crate::MemoryImageSlot;
use crate::Store;
use anyhow::Error;
use anyhow::{bail, format_err, Result};
use more_asserts::{assert_ge, assert_le};
use std::convert::TryFrom;
use std::sync::atomic::Ordering;
use std::sync::{Arc, RwLock};
@@ -214,7 +213,7 @@ impl MmapMemory {
// of the two is, the `maximum` given or the `bound` specified for
// this memory.
MemoryStyle::Static { bound } => {
assert_ge!(bound, plan.memory.minimum);
assert!(bound >= plan.memory.minimum);
let bound_bytes =
usize::try_from(bound.checked_mul(WASM_PAGE_SIZE_U64).unwrap()).unwrap();
maximum = Some(bound_bytes.min(maximum.unwrap_or(usize::MAX)));
@@ -662,7 +661,7 @@ impl Memory {
} else {
WASM32_MAX_PAGES
};
assert_le!(plan.memory.minimum, absolute_max);
assert!(plan.memory.minimum <= absolute_max);
assert!(plan.memory.maximum.is_none() || plan.memory.maximum.unwrap() <= absolute_max);
// This is the absolute possible maximum that the module can try to

View File

@@ -3,7 +3,6 @@
use anyhow::anyhow;
use anyhow::{Context, Result};
use more_asserts::assert_le;
use std::convert::TryFrom;
use std::fs::File;
use std::ops::Range;
@@ -160,7 +159,7 @@ impl Mmap {
#[cfg(not(target_os = "windows"))]
pub fn accessible_reserved(accessible_size: usize, mapping_size: usize) -> Result<Self> {
let page_size = crate::page_size();
assert_le!(accessible_size, mapping_size);
assert!(accessible_size <= mapping_size);
assert_eq!(mapping_size & (page_size - 1), 0);
assert_eq!(accessible_size & (page_size - 1), 0);
@@ -228,7 +227,7 @@ impl Mmap {
}
let page_size = crate::page_size();
assert_le!(accessible_size, mapping_size);
assert!(accessible_size <= mapping_size);
assert_eq!(mapping_size & (page_size - 1), 0);
assert_eq!(accessible_size & (page_size - 1), 0);
@@ -284,8 +283,8 @@ impl Mmap {
let page_size = crate::page_size();
assert_eq!(start & (page_size - 1), 0);
assert_eq!(len & (page_size - 1), 0);
assert_le!(len, self.len);
assert_le!(start, self.len - len);
assert!(len <= self.len);
assert!(start <= self.len - len);
// Commit the accessible size.
let ptr = self.ptr as *mut u8;
@@ -313,8 +312,8 @@ impl Mmap {
let page_size = crate::page_size();
assert_eq!(start & (page_size - 1), 0);
assert_eq!(len & (page_size - 1), 0);
assert_le!(len, self.len);
assert_le!(start, self.len - len);
assert!(len <= self.len);
assert!(start <= self.len - len);
// Commit the accessible size.
let ptr = self.ptr as *const u8;

View File

@@ -332,17 +332,16 @@ pub struct VMGlobalDefinition {
mod test_vmglobal_definition {
use super::VMGlobalDefinition;
use crate::externref::VMExternRef;
use more_asserts::assert_ge;
use std::mem::{align_of, size_of};
use wasmtime_environ::{Module, PtrSize, VMOffsets};
#[test]
fn check_vmglobal_definition_alignment() {
assert_ge!(align_of::<VMGlobalDefinition>(), align_of::<i32>());
assert_ge!(align_of::<VMGlobalDefinition>(), align_of::<i64>());
assert_ge!(align_of::<VMGlobalDefinition>(), align_of::<f32>());
assert_ge!(align_of::<VMGlobalDefinition>(), align_of::<f64>());
assert_ge!(align_of::<VMGlobalDefinition>(), align_of::<[u8; 16]>());
assert!(align_of::<VMGlobalDefinition>() >= align_of::<i32>());
assert!(align_of::<VMGlobalDefinition>() >= align_of::<i64>());
assert!(align_of::<VMGlobalDefinition>() >= align_of::<f32>());
assert!(align_of::<VMGlobalDefinition>() >= align_of::<f64>());
assert!(align_of::<VMGlobalDefinition>() >= align_of::<[u8; 16]>());
}
#[test]