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

@@ -1,6 +1,5 @@
use crate::{CompiledFunctions, FunctionAddressMap};
use gimli::write;
use more_asserts::assert_le;
use std::collections::BTreeMap;
use std::iter::FromIterator;
use wasmtime_environ::{DefinedFuncIndex, EntityRef, FilePos, PrimaryMap, WasmFileInfo};
@@ -87,13 +86,10 @@ fn build_function_lookup(
ft: &FunctionAddressMap,
code_section_offset: u64,
) -> (WasmAddress, WasmAddress, FuncLookup) {
assert_le!(
code_section_offset,
ft.start_srcloc.file_offset().unwrap().into()
);
assert!(code_section_offset <= ft.start_srcloc.file_offset().unwrap().into());
let fn_start = get_wasm_code_offset(ft.start_srcloc, code_section_offset);
let fn_end = get_wasm_code_offset(ft.end_srcloc, code_section_offset);
assert_le!(fn_start, fn_end);
assert!(fn_start <= fn_end);
// Build ranges of continuous source locations. The new ranges starts when
// non-descending order is interrupted. Assuming the same origin location can
@@ -111,8 +107,8 @@ fn build_function_lookup(
}
let offset = get_wasm_code_offset(t.srcloc, code_section_offset);
assert_le!(fn_start, offset);
assert_le!(offset, fn_end);
assert!(fn_start <= offset);
assert!(offset <= fn_end);
let inst_gen_start = t.code_offset as usize;
let inst_gen_end = match ft.instructions.get(i + 1) {
@@ -213,7 +209,7 @@ fn build_function_addr_map(
if cfg!(debug_assertions) {
// fn_map is sorted by the generated field -- see FunctionAddressMap::instructions.
for i in 1..fn_map.len() {
assert_le!(fn_map[i - 1].generated, fn_map[i].generated);
assert!(fn_map[i - 1].generated <= fn_map[i].generated);
}
}

View File

@@ -6,7 +6,6 @@ use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::ValueLabelsRanges;
use cranelift_wasm::get_vmctx_value_label;
use gimli::{self, write, Expression, Operation, Reader, ReaderOffset, X86_64};
use more_asserts::{assert_le, assert_lt};
use std::cmp::PartialEq;
use std::collections::{HashMap, HashSet};
use std::hash::{Hash, Hasher};
@@ -687,7 +686,7 @@ impl<'a, 'b> ValueLabelRangesBuilder<'a, 'b> {
if range_start == range_end {
continue;
}
assert_lt!(range_start, range_end);
assert!(range_start < range_end);
// Find acceptable scope of ranges to intersect with.
let i = match ranges.binary_search_by(|s| s.start.cmp(&range_start)) {
@@ -716,7 +715,7 @@ impl<'a, 'b> ValueLabelRangesBuilder<'a, 'b> {
tail.start = range_end;
ranges.insert(i + 1, tail);
}
assert_le!(ranges[i].end, range_end);
assert!(ranges[i].end <= range_end);
if range_start <= ranges[i].start {
ranges[i].label_location.insert(label, loc);
continue;

View File

@@ -6,7 +6,6 @@ use gimli::{
write, DebugLine, DebugLineOffset, DebugLineStr, DebugStr, DebugStrOffsets,
DebuggingInformationEntry, LineEncoding, Unit,
};
use more_asserts::assert_le;
use wasmtime_environ::{DefinedFuncIndex, EntityRef};
#[derive(Debug)]
@@ -93,7 +92,7 @@ where
if let Ok(program) = program {
let header = program.header();
let file_index_base = if header.version() < 5 { 1 } else { 0 };
assert_le!(header.version(), 5, "not supported 6");
assert!(header.version() <= 5, "not supported 6");
let line_encoding = LineEncoding {
minimum_instruction_length: header.minimum_instruction_length(),
maximum_operations_per_instruction: header.maximum_operations_per_instruction(),

View File

@@ -2,7 +2,6 @@ use super::address_transform::AddressTransform;
use super::{DebugInputContext, Reader};
use anyhow::Error;
use gimli::{write, AttributeValue, DebuggingInformationEntry, RangeListsOffset, Unit};
use more_asserts::assert_lt;
use wasmtime_environ::{DefinedFuncIndex, EntityRef};
pub(crate) enum RangeInfoBuilder {
@@ -206,7 +205,7 @@ impl RangeInfoBuilder {
if let RangeInfoBuilder::Ranges(ranges) = self {
let mut range_list = Vec::new();
for (begin, end) in ranges {
assert_lt!(begin, end);
assert!(begin < end);
range_list.extend(addr_tr.translate_ranges(*begin, *end).map(|tr| {
write::Range::StartLength {
begin: tr.0,