Skip to content

Commit 54edbd6

Browse files
committed
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.
1 parent 1935428 commit 54edbd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+125
-223
lines changed

Cargo.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ rustix = { version = "0.35.6", features = ["mm", "param"] }
4646
wasmtime = { path = "crates/wasmtime", version = "0.40.0" }
4747
env_logger = "0.9.0"
4848
filecheck = "0.5.0"
49-
more-asserts = "0.2.1"
5049
tempfile = "3.1.0"
5150
test-programs = { path = "crates/test-programs" }
5251
wasmtime-runtime = { path = "crates/runtime" }

crates/cache/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@ rustix = { version = "0.35.6", features = ["process"] }
3232
[dev-dependencies]
3333
filetime = "0.2.7"
3434
once_cell = "1.12.0"
35-
more-asserts = "0.2.1"
3635
pretty_env_logger = "0.4.0"
3736
tempfile = "3"

crates/cache/src/worker/tests.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::*;
22
use crate::config::tests::test_prolog;
3-
use more_asserts::{assert_ge, assert_gt, assert_lt};
43
use std::iter::repeat;
54
use std::process;
65
// load_config! comes from crate::cache(::config::tests);
@@ -150,10 +149,7 @@ fn test_on_get_recompress_with_mod_file() {
150149
let scenarios = [(4, false), (7, true), (2, false)];
151150

152151
let mut usages = start_stats.usages;
153-
assert_lt!(
154-
usages,
155-
cache_config.optimized_compression_usage_counter_threshold()
156-
);
152+
assert!(usages < cache_config.optimized_compression_usage_counter_threshold());
157153
let mut tested_higher_opt_compr_lvl = false;
158154
for (times_used, lower_compr_lvl) in &scenarios {
159155
for _ in 0..*times_used {
@@ -180,19 +176,13 @@ fn test_on_get_recompress_with_mod_file() {
180176
assert_eq!(decoded_data, mod_data.as_bytes());
181177

182178
if *lower_compr_lvl {
183-
assert_ge!(
184-
usages,
185-
cache_config.optimized_compression_usage_counter_threshold()
186-
);
179+
assert!(usages >= cache_config.optimized_compression_usage_counter_threshold());
187180
tested_higher_opt_compr_lvl = true;
188181
stats.compression_level -= 1;
189182
assert!(write_stats_file(&stats_file, &stats));
190183
}
191184
}
192-
assert_ge!(
193-
usages,
194-
cache_config.optimized_compression_usage_counter_threshold()
195-
);
185+
assert!(usages >= cache_config.optimized_compression_usage_counter_threshold());
196186
assert!(tested_higher_opt_compr_lvl);
197187
}
198188

@@ -428,7 +418,7 @@ fn test_on_update_cleanup_limits_trash_locks() {
428418
"past",
429419
&Duration::from_secs(secs_ago),
430420
);
431-
assert_gt!(secs_ago, 0);
421+
assert!(secs_ago > 0);
432422
secs_ago -= 1;
433423
}
434424

crates/cranelift/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ wasmparser = "0.87.0"
2323
target-lexicon = "0.12"
2424
gimli = { version = "0.26.0", default-features = false, features = ['read', 'std'] }
2525
object = { version = "0.29.0", default-features = false, features = ['write'] }
26-
more-asserts = "0.2.1"
2726
thiserror = "1.0.4"
2827

2928
[features]

crates/cranelift/src/debug/transform/address_transform.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::{CompiledFunctions, FunctionAddressMap};
22
use gimli::write;
3-
use more_asserts::assert_le;
43
use std::collections::BTreeMap;
54
use std::iter::FromIterator;
65
use wasmtime_environ::{DefinedFuncIndex, EntityRef, FilePos, PrimaryMap, WasmFileInfo};
@@ -87,13 +86,10 @@ fn build_function_lookup(
8786
ft: &FunctionAddressMap,
8887
code_section_offset: u64,
8988
) -> (WasmAddress, WasmAddress, FuncLookup) {
90-
assert_le!(
91-
code_section_offset,
92-
ft.start_srcloc.file_offset().unwrap().into()
93-
);
89+
assert!(code_section_offset <= ft.start_srcloc.file_offset().unwrap().into());
9490
let fn_start = get_wasm_code_offset(ft.start_srcloc, code_section_offset);
9591
let fn_end = get_wasm_code_offset(ft.end_srcloc, code_section_offset);
96-
assert_le!(fn_start, fn_end);
92+
assert!(fn_start <= fn_end);
9793

9894
// Build ranges of continuous source locations. The new ranges starts when
9995
// non-descending order is interrupted. Assuming the same origin location can
@@ -111,8 +107,8 @@ fn build_function_lookup(
111107
}
112108

113109
let offset = get_wasm_code_offset(t.srcloc, code_section_offset);
114-
assert_le!(fn_start, offset);
115-
assert_le!(offset, fn_end);
110+
assert!(fn_start <= offset);
111+
assert!(offset <= fn_end);
116112

117113
let inst_gen_start = t.code_offset as usize;
118114
let inst_gen_end = match ft.instructions.get(i + 1) {
@@ -213,7 +209,7 @@ fn build_function_addr_map(
213209
if cfg!(debug_assertions) {
214210
// fn_map is sorted by the generated field -- see FunctionAddressMap::instructions.
215211
for i in 1..fn_map.len() {
216-
assert_le!(fn_map[i - 1].generated, fn_map[i].generated);
212+
assert!(fn_map[i - 1].generated <= fn_map[i].generated);
217213
}
218214
}
219215

crates/cranelift/src/debug/transform/expression.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use cranelift_codegen::isa::TargetIsa;
66
use cranelift_codegen::ValueLabelsRanges;
77
use cranelift_wasm::get_vmctx_value_label;
88
use gimli::{self, write, Expression, Operation, Reader, ReaderOffset, X86_64};
9-
use more_asserts::{assert_le, assert_lt};
109
use std::cmp::PartialEq;
1110
use std::collections::{HashMap, HashSet};
1211
use std::hash::{Hash, Hasher};
@@ -687,7 +686,7 @@ impl<'a, 'b> ValueLabelRangesBuilder<'a, 'b> {
687686
if range_start == range_end {
688687
continue;
689688
}
690-
assert_lt!(range_start, range_end);
689+
assert!(range_start < range_end);
691690

692691
// Find acceptable scope of ranges to intersect with.
693692
let i = match ranges.binary_search_by(|s| s.start.cmp(&range_start)) {
@@ -716,7 +715,7 @@ impl<'a, 'b> ValueLabelRangesBuilder<'a, 'b> {
716715
tail.start = range_end;
717716
ranges.insert(i + 1, tail);
718717
}
719-
assert_le!(ranges[i].end, range_end);
718+
assert!(ranges[i].end <= range_end);
720719
if range_start <= ranges[i].start {
721720
ranges[i].label_location.insert(label, loc);
722721
continue;

crates/cranelift/src/debug/transform/line_program.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use gimli::{
66
write, DebugLine, DebugLineOffset, DebugLineStr, DebugStr, DebugStrOffsets,
77
DebuggingInformationEntry, LineEncoding, Unit,
88
};
9-
use more_asserts::assert_le;
109
use wasmtime_environ::{DefinedFuncIndex, EntityRef};
1110

1211
#[derive(Debug)]
@@ -93,7 +92,7 @@ where
9392
if let Ok(program) = program {
9493
let header = program.header();
9594
let file_index_base = if header.version() < 5 { 1 } else { 0 };
96-
assert_le!(header.version(), 5, "not supported 6");
95+
assert!(header.version() <= 5, "not supported 6");
9796
let line_encoding = LineEncoding {
9897
minimum_instruction_length: header.minimum_instruction_length(),
9998
maximum_operations_per_instruction: header.maximum_operations_per_instruction(),

crates/cranelift/src/debug/transform/range_info_builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::address_transform::AddressTransform;
22
use super::{DebugInputContext, Reader};
33
use anyhow::Error;
44
use gimli::{write, AttributeValue, DebuggingInformationEntry, RangeListsOffset, Unit};
5-
use more_asserts::assert_lt;
65
use wasmtime_environ::{DefinedFuncIndex, EntityRef};
76

87
pub(crate) enum RangeInfoBuilder {
@@ -206,7 +205,7 @@ impl RangeInfoBuilder {
206205
if let RangeInfoBuilder::Ranges(ranges) = self {
207206
let mut range_list = Vec::new();
208207
for (begin, end) in ranges {
209-
assert_lt!(begin, end);
208+
assert!(begin < end);
210209
range_list.extend(addr_tr.translate_ranges(*begin, *end).map(|tr| {
211210
write::Range::StartLength {
212211
begin: tr.0,

crates/environ/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ indexmap = { version = "1.0.2", features = ["serde-1"] }
1919
thiserror = "1.0.4"
2020
serde = { version = "1.0.94", features = ["derive"] }
2121
log = { version = "0.4.8", default-features = false }
22-
more-asserts = "0.2.1"
2322
gimli = { version = "0.26.0", default-features = false, features = ['read'] }
2423
object = { version = "0.29.0", default-features = false, features = ['read_core', 'write_core', 'elf'] }
2524
target-lexicon = "0.12"

crates/environ/src/vmoffsets.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use crate::{
2626
GlobalIndex, MemoryIndex, Module, TableIndex,
2727
};
2828
use cranelift_entity::packed_option::ReservedValue;
29-
use more_asserts::assert_lt;
3029
use std::convert::TryFrom;
3130
use wasmtime_types::OwnedMemoryIndex;
3231

@@ -671,61 +670,61 @@ impl<P: PtrSize> VMOffsets<P> {
671670
/// Return the offset to `VMFunctionImport` index `index`.
672671
#[inline]
673672
pub fn vmctx_vmfunction_import(&self, index: FuncIndex) -> u32 {
674-
assert_lt!(index.as_u32(), self.num_imported_functions);
673+
assert!(index.as_u32() < self.num_imported_functions);
675674
self.vmctx_imported_functions_begin()
676675
+ index.as_u32() * u32::from(self.size_of_vmfunction_import())
677676
}
678677

679678
/// Return the offset to `VMTableImport` index `index`.
680679
#[inline]
681680
pub fn vmctx_vmtable_import(&self, index: TableIndex) -> u32 {
682-
assert_lt!(index.as_u32(), self.num_imported_tables);
681+
assert!(index.as_u32() < self.num_imported_tables);
683682
self.vmctx_imported_tables_begin()
684683
+ index.as_u32() * u32::from(self.size_of_vmtable_import())
685684
}
686685

687686
/// Return the offset to `VMMemoryImport` index `index`.
688687
#[inline]
689688
pub fn vmctx_vmmemory_import(&self, index: MemoryIndex) -> u32 {
690-
assert_lt!(index.as_u32(), self.num_imported_memories);
689+
assert!(index.as_u32() < self.num_imported_memories);
691690
self.vmctx_imported_memories_begin()
692691
+ index.as_u32() * u32::from(self.size_of_vmmemory_import())
693692
}
694693

695694
/// Return the offset to `VMGlobalImport` index `index`.
696695
#[inline]
697696
pub fn vmctx_vmglobal_import(&self, index: GlobalIndex) -> u32 {
698-
assert_lt!(index.as_u32(), self.num_imported_globals);
697+
assert!(index.as_u32() < self.num_imported_globals);
699698
self.vmctx_imported_globals_begin()
700699
+ index.as_u32() * u32::from(self.size_of_vmglobal_import())
701700
}
702701

703702
/// Return the offset to `VMTableDefinition` index `index`.
704703
#[inline]
705704
pub fn vmctx_vmtable_definition(&self, index: DefinedTableIndex) -> u32 {
706-
assert_lt!(index.as_u32(), self.num_defined_tables);
705+
assert!(index.as_u32() < self.num_defined_tables);
707706
self.vmctx_tables_begin() + index.as_u32() * u32::from(self.size_of_vmtable_definition())
708707
}
709708

710709
/// Return the offset to the `*mut VMMemoryDefinition` at index `index`.
711710
#[inline]
712711
pub fn vmctx_vmmemory_pointer(&self, index: DefinedMemoryIndex) -> u32 {
713-
assert_lt!(index.as_u32(), self.num_defined_memories);
712+
assert!(index.as_u32() < self.num_defined_memories);
714713
self.vmctx_memories_begin() + index.as_u32() * u32::from(self.size_of_vmmemory_pointer())
715714
}
716715

717716
/// Return the offset to the owned `VMMemoryDefinition` at index `index`.
718717
#[inline]
719718
pub fn vmctx_vmmemory_definition(&self, index: OwnedMemoryIndex) -> u32 {
720-
assert_lt!(index.as_u32(), self.num_owned_memories);
719+
assert!(index.as_u32() < self.num_owned_memories);
721720
self.vmctx_owned_memories_begin()
722721
+ index.as_u32() * u32::from(self.size_of_vmmemory_definition())
723722
}
724723

725724
/// Return the offset to the `VMGlobalDefinition` index `index`.
726725
#[inline]
727726
pub fn vmctx_vmglobal_definition(&self, index: DefinedGlobalIndex) -> u32 {
728-
assert_lt!(index.as_u32(), self.num_defined_globals);
727+
assert!(index.as_u32() < self.num_defined_globals);
729728
self.vmctx_globals_begin()
730729
+ index.as_u32() * u32::from(self.ptr.size_of_vmglobal_definition())
731730
}
@@ -735,7 +734,7 @@ impl<P: PtrSize> VMOffsets<P> {
735734
#[inline]
736735
pub fn vmctx_anyfunc(&self, index: AnyfuncIndex) -> u32 {
737736
assert!(!index.is_reserved_value());
738-
assert_lt!(index.as_u32(), self.num_escaped_funcs);
737+
assert!(index.as_u32() < self.num_escaped_funcs);
739738
self.vmctx_anyfuncs_begin()
740739
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
741740
}

crates/runtime/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ log = "0.4.8"
1919
memoffset = "0.6.0"
2020
indexmap = "1.0.2"
2121
thiserror = "1.0.4"
22-
more-asserts = "0.2.1"
2322
cfg-if = "1.0"
2423
backtrace = { version = "0.3.61" }
2524
rand = "0.8.3"

crates/runtime/src/instance.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::{
1616
};
1717
use anyhow::Error;
1818
use memoffset::offset_of;
19-
use more_asserts::assert_lt;
2019
use std::alloc::Layout;
2120
use std::any::Any;
2221
use std::convert::TryFrom;
@@ -364,7 +363,7 @@ impl Instance {
364363
)
365364
.unwrap(),
366365
);
367-
assert_lt!(index.index(), self.tables.len());
366+
assert!(index.index() < self.tables.len());
368367
index
369368
}
370369

crates/runtime/src/memory.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::MemoryImageSlot;
99
use crate::Store;
1010
use anyhow::Error;
1111
use anyhow::{bail, format_err, Result};
12-
use more_asserts::{assert_ge, assert_le};
1312
use std::convert::TryFrom;
1413
use std::sync::atomic::Ordering;
1514
use std::sync::{Arc, RwLock};
@@ -214,7 +213,7 @@ impl MmapMemory {
214213
// of the two is, the `maximum` given or the `bound` specified for
215214
// this memory.
216215
MemoryStyle::Static { bound } => {
217-
assert_ge!(bound, plan.memory.minimum);
216+
assert!(bound >= plan.memory.minimum);
218217
let bound_bytes =
219218
usize::try_from(bound.checked_mul(WASM_PAGE_SIZE_U64).unwrap()).unwrap();
220219
maximum = Some(bound_bytes.min(maximum.unwrap_or(usize::MAX)));
@@ -662,7 +661,7 @@ impl Memory {
662661
} else {
663662
WASM32_MAX_PAGES
664663
};
665-
assert_le!(plan.memory.minimum, absolute_max);
664+
assert!(plan.memory.minimum <= absolute_max);
666665
assert!(plan.memory.maximum.is_none() || plan.memory.maximum.unwrap() <= absolute_max);
667666

668667
// This is the absolute possible maximum that the module can try to

0 commit comments

Comments
 (0)