Skip to content

Commit 12a2aec

Browse files
committed
Cleanup include order
Make sure that we consistently use the tree import syntax. Also, consistently order code like: - Global attributes/comments - `use` from `core` - `use` from external crates - `mod` declarations (if applicable) - `use` from current crate - Rest of code This makes the code easier to read/edit. Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 4f2b144 commit 12a2aec

File tree

11 files changed

+49
-42
lines changed

11 files changed

+49
-42
lines changed

src/block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
use core::cell::RefCell;
1616

17-
use crate::virtio::Error as VirtioError;
18-
use crate::virtio::VirtioTransport;
17+
use crate::virtio::{Error as VirtioError, VirtioTransport};
1918

2019
const QUEUE_SIZE: usize = 16;
2120

src/bzimage.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use crate::fat;
16-
use fat::Read;
15+
use crate::fat::{self, Read};
1716

1817
pub enum Error {
1918
FileError,

src/efi/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
const PAGE_SIZE: u64 = 4096;
16-
1715
use r_efi::efi::{AllocateType, MemoryType, PhysicalAddress, Status, VirtualAddress};
1816

17+
const PAGE_SIZE: u64 = 4096;
18+
1919
// Copied from r_efi so we can do Default on it
2020
#[repr(C)]
2121
#[derive(Debug, Copy, Clone)]

src/efi/block.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414

1515
use core::ffi::c_void;
1616

17-
use r_efi::efi::{AllocateType, Guid, MemoryType, Status};
18-
use r_efi::protocols::device_path::Protocol as DevicePathProtocol;
19-
use r_efi::{eficall, eficall_abi};
17+
use r_efi::{
18+
efi::{AllocateType, Guid, MemoryType, Status},
19+
eficall, eficall_abi,
20+
protocols::device_path::Protocol as DevicePathProtocol,
21+
};
2022

2123
pub const PROTOCOL_GUID: Guid = Guid::from_fields(
2224
0x964e_5b21,

src/efi/console.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use r_efi::efi::{Boolean, Char16, Event, Handle, Status};
16-
use r_efi::protocols::simple_text_input::InputKey;
17-
use r_efi::protocols::simple_text_input::Protocol as SimpleTextInputProtocol;
18-
use r_efi::protocols::simple_text_output::Mode as SimpleTextOutputMode;
19-
use r_efi::protocols::simple_text_output::Protocol as SimpleTextOutputProtocol;
15+
use r_efi::{
16+
efi::{Boolean, Char16, Event, Handle, Status},
17+
protocols::{
18+
simple_text_input::{InputKey, Protocol as SimpleTextInputProtocol},
19+
simple_text_output::{Mode as SimpleTextOutputMode, Protocol as SimpleTextOutputProtocol},
20+
},
21+
};
2022

2123
use super::{HandleType, HandleWrapper};
2224

src/efi/file.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414

1515
use core::ffi::c_void;
1616

17-
use r_efi::efi::{AllocateType, Char16, Guid, MemoryType, Status};
18-
use r_efi::protocols::device_path::Protocol as DevicePathProtocol;
19-
use r_efi::protocols::file::Protocol as FileProtocol;
20-
use r_efi::protocols::simple_file_system::Protocol as SimpleFileSystemProtocol;
17+
use r_efi::{
18+
efi::{AllocateType, Char16, Guid, MemoryType, Status},
19+
protocols::{
20+
device_path::Protocol as DevicePathProtocol, file::Protocol as FileProtocol,
21+
simple_file_system::Protocol as SimpleFileSystemProtocol,
22+
},
23+
};
2124

2225
#[repr(C)]
2326
pub struct FileDevicePathProtocol {

src/efi/mod.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,26 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use core::ffi::c_void;
16+
17+
use r_efi::{
18+
efi::{
19+
self, AllocateType, Boolean, CapsuleHeader, Char16, Event, EventNotify, Guid, Handle,
20+
InterfaceType, LocateSearchType, MemoryDescriptor, MemoryType,
21+
OpenProtocolInformationEntry, PhysicalAddress, ResetType, Status, Time, TimeCapabilities,
22+
TimerDelay, Tpl,
23+
},
24+
protocols::{
25+
device_path::Protocol as DevicePathProtocol, loaded_image::Protocol as LoadedImageProtocol,
26+
},
27+
};
28+
use spin::Mutex;
29+
1530
mod alloc;
1631
mod block;
1732
mod console;
1833
mod file;
1934

20-
use spin::Mutex;
21-
22-
use r_efi::efi;
23-
use r_efi::efi::{
24-
AllocateType, Boolean, CapsuleHeader, Char16, Event, EventNotify, Guid, Handle, InterfaceType,
25-
LocateSearchType, MemoryDescriptor, MemoryType, OpenProtocolInformationEntry, PhysicalAddress,
26-
ResetType, Status, Time, TimeCapabilities, TimerDelay, Tpl,
27-
};
28-
29-
use r_efi::protocols::device_path::Protocol as DevicePathProtocol;
30-
use r_efi::protocols::loaded_image::Protocol as LoadedImageProtocol;
31-
32-
use core::ffi::c_void;
33-
3435
use alloc::Allocator;
3536

3637
#[derive(Copy, Clone, PartialEq)]

src/loader.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use crate::bzimage;
16-
use crate::fat;
17-
use fat::Read;
15+
use crate::{
16+
bzimage,
17+
fat::{self, Read},
18+
};
1819

1920
pub struct LoaderConfig {
2021
pub bzimage_path: [u8; 260],

src/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// from Philipp Oppermann
1717

1818
use core::fmt;
19-
use spin::Mutex;
2019

2120
use cpuio::Port;
21+
use spin::Mutex;
2222

2323
pub static LOGGER: Mutex<Logger> = Mutex::new(Logger {
2424
port: unsafe { Port::new(0x3f8) },

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
#![cfg_attr(test, allow(unused_imports, dead_code))]
1919
#![cfg_attr(not(feature = "log-serial"), allow(unused_variables, unused_imports))]
2020

21+
use core::panic::PanicInfo;
22+
2123
#[macro_use]
2224
mod logger;
2325

2426
#[macro_use]
2527
mod common;
2628

27-
use core::panic::PanicInfo;
28-
2929
mod block;
3030
mod bzimage;
3131
mod efi;

0 commit comments

Comments
 (0)