Skip to content

Commit 3a2d17e

Browse files
committed
Fixed CI errors
1 parent 5bb8536 commit 3a2d17e

1 file changed

Lines changed: 24 additions & 25 deletions

File tree

multiboot2/src/elf_sections.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ impl ElfSection<'_> {
223223
}
224224

225225
/// Returns the full section header in a type agnostic format.
226-
pub fn section_raw(&self) -> SectionHeader {
226+
#[must_use]
227+
pub const fn section_raw(&self) -> SectionHeader {
227228
self.inner.0
228229
}
229230

@@ -311,34 +312,32 @@ struct SectionHeaderWrapper(SectionHeader);
311312

312313
impl PartialOrd for SectionHeaderWrapper {
313314
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
314-
macro_rules! actual_partial_comparison {
315-
($field:ident) => {
316-
match self.0.$field.partial_cmp(&other.0.$field) {
317-
Some(Ordering::Equal) => {} // fall though
318-
Some(result) => return Some(result),
319-
None => unreachable!(), // All fields implement Ord and so cannot return `None`
320-
}
321-
};
322-
}
323-
324-
actual_partial_comparison!(sh_name);
325-
actual_partial_comparison!(sh_type);
326-
actual_partial_comparison!(sh_flags);
327-
actual_partial_comparison!(sh_addr);
328-
actual_partial_comparison!(sh_offset);
329-
actual_partial_comparison!(sh_size);
330-
actual_partial_comparison!(sh_link);
331-
actual_partial_comparison!(sh_info);
332-
actual_partial_comparison!(sh_addralign);
333-
actual_partial_comparison!(sh_entsize);
334-
Some(Ordering::Equal)
315+
Some(self.cmp(other))
335316
}
336317
}
337318

338319
impl Ord for SectionHeaderWrapper {
339320
fn cmp(&self, other: &Self) -> Ordering {
340-
// Should partial_cmp call this instead?
341-
self.partial_cmp(other).unwrap()
321+
// Compares one field, returns if not equal
322+
macro_rules! partial {
323+
($field:ident) => {
324+
match self.0.$field.cmp(&other.0.$field) {
325+
Ordering::Equal => {}
326+
result => return result,
327+
}
328+
};
329+
}
330+
partial!(sh_name);
331+
partial!(sh_type);
332+
partial!(sh_flags);
333+
partial!(sh_addr);
334+
partial!(sh_offset);
335+
partial!(sh_size);
336+
partial!(sh_link);
337+
partial!(sh_info);
338+
partial!(sh_addralign);
339+
partial!(sh_entsize);
340+
Ordering::Equal
342341
}
343342
}
344343

@@ -384,7 +383,7 @@ impl Eq for ShPointer {}
384383

385384
impl PartialOrd for ShPointer {
386385
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
387-
unsafe { self.elf64.partial_cmp(&other.elf64) }
386+
Some(self.cmp(other))
388387
}
389388
}
390389

0 commit comments

Comments
 (0)