Browse Source

multiboot2: optimize imports

Philipp Schuster 1 year ago
parent
commit
e52d3cad9a

+ 3 - 3
multiboot2/src/boot_loader_name.rs

@@ -1,12 +1,12 @@
-use crate::{Tag, TagTrait, TagType, TagTypeId};
+use crate::{Tag, TagTrait, TagTypeId};
 use core::fmt::{Debug, Formatter};
 use core::mem::size_of;
 use core::str::Utf8Error;
 
 #[cfg(feature = "builder")]
 use {
-    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, alloc::boxed::Box,
-    alloc::vec::Vec,
+    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, crate::TagType,
+    alloc::boxed::Box, alloc::vec::Vec,
 };
 
 const METADATA_SIZE: usize = size_of::<TagTypeId>() + size_of::<u32>();

+ 3 - 4
multiboot2/src/command_line.rs

@@ -1,16 +1,15 @@
 //! Module for [CommandLineTag].
 
-use crate::{Tag, TagTrait, TagType, TagTypeId};
+use crate::{Tag, TagTrait, TagTypeId};
 
-use core::convert::TryInto;
 use core::fmt::{Debug, Formatter};
 use core::mem;
 use core::str;
 
 #[cfg(feature = "builder")]
 use {
-    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, alloc::boxed::Box,
-    alloc::vec::Vec,
+    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, crate::TagType,
+    alloc::boxed::Box, alloc::vec::Vec, core::convert::TryInto,
 };
 
 pub(crate) const METADATA_SIZE: usize = mem::size_of::<TagTypeId>() + mem::size_of::<u32>();

+ 5 - 2
multiboot2/src/elf_sections.rs

@@ -1,11 +1,14 @@
-use crate::{Tag, TagTrait, TagType, TagTypeId};
+use crate::{Tag, TagTrait, TagTypeId};
 
 use core::fmt::{Debug, Formatter};
 use core::mem::size_of;
 use core::str::Utf8Error;
 
 #[cfg(feature = "builder")]
-use {crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, alloc::boxed::Box};
+use {
+    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, crate::TagType,
+    alloc::boxed::Box,
+};
 
 const METADATA_SIZE: usize = size_of::<TagTypeId>() + 4 * size_of::<u32>();
 

+ 4 - 4
multiboot2/src/framebuffer.rs

@@ -1,4 +1,4 @@
-use crate::{Reader, Tag, TagTrait, TagType, TagTypeId};
+use crate::{Reader, Tag, TagTrait, TagTypeId};
 
 use core::fmt::Debug;
 use core::mem::size_of;
@@ -7,8 +7,8 @@ use derive_more::Display;
 
 #[cfg(feature = "builder")]
 use {
-    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, alloc::boxed::Box,
-    alloc::vec::Vec,
+    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, crate::TagType,
+    alloc::boxed::Box, alloc::vec::Vec,
 };
 
 const METADATA_SIZE: usize = size_of::<TagTypeId>()
@@ -205,7 +205,7 @@ impl TryFrom<u8> for FramebufferTypeId {
             0 => Ok(Self::Indexed),
             1 => Ok(Self::RGB),
             2 => Ok(Self::Text),
-            val => Err(UnknownFramebufferType(val))
+            val => Err(UnknownFramebufferType(val)),
         }
     }
 }

+ 5 - 5
multiboot2/src/image_load_addr.rs

@@ -1,9 +1,9 @@
-use core::convert::TryInto;
-use core::mem::size_of;
-
+use crate::tag_type::TagTypeId;
 #[cfg(feature = "builder")]
-use crate::builder::traits::StructAsBytes;
-use crate::tag_type::{TagType, TagTypeId};
+use {
+    crate::builder::traits::StructAsBytes, crate::TagType, core::convert::TryInto,
+    core::mem::size_of,
+};
 
 /// If the image has relocatable header tag, this tag contains the image's
 /// base physical address.

+ 9 - 6
multiboot2/src/rsdp.rs

@@ -8,15 +8,17 @@
 //!
 //! Even though the bootloader should give the address of the real RSDP/XSDT, the checksum and
 //! signature should be manually verified.
-#[cfg(feature = "builder")]
-use crate::builder::traits::StructAsBytes;
-use crate::tag_type::{TagType, TagTypeId};
+//!
 
-use core::convert::TryInto;
-use core::mem::size_of;
+use crate::tag_type::TagTypeId;
 use core::slice;
 use core::str;
 use core::str::Utf8Error;
+#[cfg(feature = "builder")]
+use {
+    crate::builder::traits::StructAsBytes, crate::TagType, core::convert::TryInto,
+    core::mem::size_of,
+};
 
 const RSDPV1_LENGTH: usize = 20;
 
@@ -105,7 +107,8 @@ pub struct RsdpV2Tag {
     revision: u8,
     rsdt_address: u32,
     length: u32,
-    xsdt_address: u64, // This is the PHYSICAL address of the XSDT
+    xsdt_address: u64,
+    // This is the PHYSICAL address of the XSDT
     ext_checksum: u8,
     _reserved: [u8; 3],
 }

+ 5 - 5
multiboot2/src/smbios.rs

@@ -1,10 +1,10 @@
-use crate::{Tag, TagTrait, TagType, TagTypeId};
-
-use core::convert::TryInto;
+use crate::{Tag, TagTrait, TagTypeId};
 use core::fmt::Debug;
-
 #[cfg(feature = "builder")]
-use {crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, alloc::boxed::Box};
+use {
+    crate::builder::boxed_dst_tag, crate::builder::traits::StructAsBytes, crate::TagType,
+    alloc::boxed::Box, core::convert::TryInto,
+};
 
 const METADATA_SIZE: usize = core::mem::size_of::<TagTypeId>()
     + core::mem::size_of::<u32>()