Skip to content

Commit 12ae262

Browse files
authored
Rust edition 2018 + formatting + clippy (#84)
* Rust edition 2018 + formatting (closes #83) * fix imports in tests * fixed future compiler error in tests * clippy code quality improvements * removed unused impl of non-public struct
1 parent 5204fe8 commit 12ae262

File tree

9 files changed

+155
-164
lines changed

9 files changed

+155
-164
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ authors = ["Philipp Oppermann <dev@phil-opp.com>", "Calvin Lee <cyrus296@gmail.c
55
license = "MIT/Apache-2.0"
66
description = "An experimental Multiboot 2 crate for ELF-64/32 kernels."
77
repository = "https://github.com/rust-osdev/multiboot2-elf64"
8+
edition = "2018"
89

910
[dependencies]
1011
bitflags = "1"

src/elf_sections.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use header::Tag;
2-
use core::fmt::{Formatter, Debug};
1+
use crate::header::Tag;
2+
use core::fmt::{Debug, Formatter};
33

44
/// This tag contains section header table from an ELF kernel.
55
///
@@ -114,7 +114,7 @@ impl Default for ElfSectionIter {
114114
remaining_sections: 0,
115115
entry_size: 0,
116116
string_section: core::ptr::null(),
117-
offset: 0
117+
offset: 0,
118118
}
119119
}
120120
}
@@ -318,7 +318,7 @@ impl ElfSectionInner for ElfSectionInner64 {
318318
}
319319

320320
fn addralign(&self) -> u64 {
321-
self.addralign.into()
321+
self.addralign
322322
}
323323
}
324324

src/framebuffer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use crate::header::Tag;
2+
use crate::Reader;
13
use core::slice;
2-
use header::Tag;
3-
use Reader;
44

55
/// The VBE Framebuffer information Tag.
66
#[derive(Debug, PartialEq)]
@@ -78,7 +78,7 @@ pub struct FramebufferColor {
7878
pub blue: u8,
7979
}
8080

81-
pub fn framebuffer_tag<'a>(tag: &'a Tag) -> FramebufferTag<'a> {
81+
pub fn framebuffer_tag(tag: &Tag) -> FramebufferTag {
8282
let mut reader = Reader::new(tag as *const Tag);
8383
reader.skip(8);
8484
let address = reader.read_u64();

src/header.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use core::marker::PhantomData;
21
use core::fmt::{Debug, Formatter};
3-
use core::cmp::Ordering;
2+
use core::marker::PhantomData;
43

54
/// Magic number that a multiboot2-compliant boot loader will store in `eax` register
65
/// right before handoff to the payload (the kernel). This value can be used to check,
@@ -63,21 +62,6 @@ impl PartialEq<TagType> for TagType {
6362
}
6463
}
6564

66-
impl PartialOrd<u32> for TagType {
67-
fn partial_cmp(&self, other: &u32) -> Option<Ordering> {
68-
let num = *self as u32;
69-
Some(
70-
if num < *other {
71-
Ordering::Less
72-
} else if num == *other {
73-
Ordering::Equal
74-
} else {
75-
Ordering::Greater
76-
}
77-
)
78-
}
79-
}
80-
8165
/// All tags that could passed via the Multiboot2 information structure to a payload/program/kernel.
8266
/// Better not confuse this with the Multiboot2 header tags. They are something different.
8367
#[derive(Clone, Copy)]
@@ -119,7 +103,10 @@ impl<'a> Iterator for TagIter<'a> {
119103

120104
fn next(&mut self) -> Option<&'a Tag> {
121105
match unsafe { &*self.current } {
122-
&Tag { typ: TagType::End, size: 8 } => None, // end tag
106+
&Tag {
107+
typ: TagType::End,
108+
size: 8,
109+
} => None, // end tag
123110
tag => {
124111
// go to next tag
125112
let mut tag_addr = self.current as usize;

0 commit comments

Comments
 (0)