Skip to content

Commit 57af460

Browse files
committed
Fix wasm build && cargo clippy --fix
1 parent 4e3d403 commit 57af460

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

objdiff-core/src/obj/mdebug.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use alloc::vec::Vec;
2+
13
use anyhow::{Context, Result, bail, ensure};
24
use object::{Endianness, Object, ObjectSection};
35

@@ -154,16 +156,16 @@ pub(super) fn parse_line_info_mdebug(
154156
fn assign_lines(sections: &mut [Section], base_address: u64, lines: &[i32]) {
155157
let mut address = base_address;
156158
for &line in lines {
157-
if line >= 0 {
158-
if let Some(section) = find_code_section(sections, address) {
159-
section.line_info.insert(address, line as u32);
160-
}
159+
if line >= 0
160+
&& let Some(section) = find_code_section(sections, address)
161+
{
162+
section.line_info.insert(address, line as u32);
161163
}
162164
address = address.wrapping_add(4);
163165
}
164166
}
165167

166-
fn find_code_section<'a>(sections: &'a mut [Section], address: u64) -> Option<&'a mut Section> {
168+
fn find_code_section(sections: &mut [Section], address: u64) -> Option<&mut Section> {
167169
sections.iter_mut().find(|section| {
168170
section.kind == SectionKind::Code
169171
&& address >= section.address
@@ -195,12 +197,12 @@ fn decode_delta(
195197
}
196198
}
197199

198-
fn slice_at<'a>(
199-
data: &'a [u8],
200+
fn slice_at(
201+
data: &[u8],
200202
offset: u32,
201203
size: u32,
202204
section_file_offset: Option<usize>,
203-
) -> Result<&'a [u8]> {
205+
) -> Result<&[u8]> {
204206
let size = size as usize;
205207
if size == 0 {
206208
ensure!(
@@ -355,7 +357,7 @@ struct SymbolEntry {
355357
}
356358

357359
fn parse_symbols(data: &[u8], endianness: Endianness) -> Result<Vec<SymbolEntry>> {
358-
ensure!(data.len() % SYMR_SIZE == 0, "symbol table misaligned");
360+
ensure!(data.len().is_multiple_of(SYMR_SIZE), "symbol table misaligned");
359361
let mut symbols = Vec::with_capacity(data.len() / SYMR_SIZE);
360362
let mut cursor = 0;
361363
while cursor + SYMR_SIZE <= data.len() {

0 commit comments

Comments
 (0)