Skip to content

Commit 61e57e1

Browse files
RuoqingHerbradford
authored andcommitted
misc: Further improve imports styling
By introducing `imports_granularity="Module"` format strategy, effectively groups imports from the same module into one line or block, improving maintainability and readability. Signed-off-by: Ruoqing He <[email protected]>
1 parent 9013d8b commit 61e57e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+360
-515
lines changed

.rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
edition = "2021"
22
group_imports="StdExternalCrate"
3+
imports_granularity="Module"
4+

arch/src/aarch64/fdt.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,20 @@
66
// Use of this source code is governed by a BSD-style license that can be
77
// found in the THIRD-PARTY file.
88

9-
use std::cmp;
109
use std::collections::HashMap;
1110
use std::ffi::CStr;
1211
use std::fmt::Debug;
13-
use std::fs;
1412
use std::path::Path;
15-
use std::result;
16-
use std::str;
1713
use std::sync::{Arc, Mutex};
14+
use std::{cmp, fs, result, str};
1815

1916
use byteorder::{BigEndian, ByteOrder};
2017
use hypervisor::arch::aarch64::gic::Vgic;
2118
use thiserror::Error;
2219
use vm_fdt::{FdtWriter, FdtWriterResult};
2320
use vm_memory::{Address, Bytes, GuestMemory, GuestMemoryError, GuestMemoryRegion};
2421

25-
use super::super::DeviceType;
26-
use super::super::GuestMemoryMmap;
27-
use super::super::InitramfsConfig;
22+
use super::super::{DeviceType, GuestMemoryMmap, InitramfsConfig};
2823
use super::layout::{
2924
IRQ_BASE, MEM_32BIT_DEVICES_SIZE, MEM_32BIT_DEVICES_START, MEM_PCI_IO_SIZE, MEM_PCI_IO_START,
3025
PCI_HIGH_BASE, PCI_MMIO_CONFIG_SIZE_PER_SEGMENT,

arch/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
extern crate log;
1212

1313
use std::collections::BTreeMap;
14-
use std::fmt;
15-
use std::result;
1614
use std::sync::Arc;
15+
use std::{fmt, result};
1716

1817
use serde::{Deserialize, Serialize};
1918
use thiserror::Error;

arch/src/x86_64/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ use vm_memory::{
2727
GuestMemoryRegion, GuestUsize,
2828
};
2929

30-
use crate::GuestMemoryMmap;
31-
use crate::InitramfsConfig;
32-
use crate::RegionType;
30+
use crate::{GuestMemoryMmap, InitramfsConfig, RegionType};
3331
mod smbios;
3432
use std::arch::x86_64;
3533
#[cfg(feature = "tdx")]

arch/src/x86_64/mptable.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
// Use of this source code is governed by a BSD-style license that can be
66
// found in the LICENSE-BSD-3-Clause file.
77

8-
use std::mem;
9-
use std::result;
10-
use std::slice;
8+
use std::{mem, result, slice};
119

1210
use libc::c_uchar;
1311
use thiserror::Error;
@@ -306,9 +304,8 @@ pub fn setup_mptable(
306304

307305
#[cfg(test)]
308306
mod tests {
309-
use vm_memory::{
310-
bitmap::BitmapSlice, GuestUsize, VolatileMemoryError, VolatileSlice, WriteVolatile,
311-
};
307+
use vm_memory::bitmap::BitmapSlice;
308+
use vm_memory::{GuestUsize, VolatileMemoryError, VolatileSlice, WriteVolatile};
312309

313310
use super::*;
314311
use crate::layout::MPTABLE_START;

arch/src/x86_64/smbios.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
//
77
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
88

9-
use std::mem;
10-
use std::result;
11-
use std::slice;
9+
use std::{mem, result, slice};
1210

1311
use thiserror::Error;
1412
use uuid::Uuid;
15-
use vm_memory::ByteValued;
16-
use vm_memory::{Address, Bytes, GuestAddress};
13+
use vm_memory::{Address, ByteValued, Bytes, GuestAddress};
1714

1815
use crate::layout::SMBIOS_START;
1916
use crate::GuestMemoryMmap;

block/src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,16 @@ pub mod vhdx;
3131
pub mod vhdx_sync;
3232

3333
use std::alloc::{alloc_zeroed, dealloc, Layout};
34-
use std::cmp;
3534
use std::collections::VecDeque;
3635
use std::fmt::Debug;
3736
use std::fs::File;
3837
use std::io::{self, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write};
3938
use std::os::linux::fs::MetadataExt;
4039
use std::os::unix::io::AsRawFd;
4140
use std::path::Path;
42-
use std::result;
43-
use std::sync::Arc;
44-
use std::sync::MutexGuard;
41+
use std::sync::{Arc, MutexGuard};
4542
use std::time::Instant;
43+
use std::{cmp, result};
4644

4745
#[cfg(feature = "io_uring")]
4846
use io_uring::{opcode, IoUring, Probe};
@@ -52,14 +50,13 @@ use smallvec::SmallVec;
5250
use thiserror::Error;
5351
use virtio_bindings::virtio_blk::*;
5452
use virtio_queue::DescriptorChain;
53+
use vm_memory::bitmap::Bitmap;
5554
use vm_memory::{
56-
bitmap::Bitmap, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError,
57-
GuestMemoryLoadGuard,
55+
ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryError, GuestMemoryLoadGuard,
5856
};
5957
use vm_virtio::{AccessPlatform, Translatable};
60-
use vmm_sys_util::aio;
6158
use vmm_sys_util::eventfd::EventFd;
62-
use vmm_sys_util::{ioctl_io_nr, ioctl_ioc_nr};
59+
use vmm_sys_util::{aio, ioctl_io_nr, ioctl_ioc_nr};
6360

6461
use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult};
6562
use crate::fixed_vhd::FixedVhd;

block/src/qcow/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
1919
use libc::{EINVAL, ENOSPC, ENOTSUP};
2020
use remain::sorted;
2121
use thiserror::Error;
22-
use vmm_sys_util::{
23-
file_traits::FileSetLen, file_traits::FileSync, seek_hole::SeekHole, write_zeroes::PunchHole,
24-
write_zeroes::WriteZeroesAt,
25-
};
22+
use vmm_sys_util::file_traits::{FileSetLen, FileSync};
23+
use vmm_sys_util::seek_hole::SeekHole;
24+
use vmm_sys_util::write_zeroes::{PunchHole, WriteZeroesAt};
2625

26+
use crate::qcow::qcow_raw_file::QcowRawFile;
2727
pub use crate::qcow::raw_file::RawFile;
28-
use crate::qcow::{
29-
qcow_raw_file::QcowRawFile,
30-
refcount::RefCount,
31-
vec_cache::{CacheMap, Cacheable, VecCache},
32-
};
28+
use crate::qcow::refcount::RefCount;
29+
use crate::qcow::vec_cache::{CacheMap, Cacheable, VecCache};
3330
use crate::BlockBackend;
3431

3532
/// Nesting depth limit for disk formats that can open other disk files.

block/src/qcow/raw_file.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use std::os::unix::io::{AsRawFd, RawFd};
1515
use std::slice;
1616

1717
use libc::c_void;
18-
use vmm_sys_util::{seek_hole::SeekHole, write_zeroes::PunchHole, write_zeroes::WriteZeroesAt};
18+
use vmm_sys_util::seek_hole::SeekHole;
19+
use vmm_sys_util::write_zeroes::{PunchHole, WriteZeroesAt};
1920

2021
use crate::BlockBackend;
2122

block/src/qcow/refcount.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ use std::io;
99
use libc::EINVAL;
1010
use thiserror::Error;
1111

12-
use crate::qcow::{
13-
qcow_raw_file::QcowRawFile,
14-
vec_cache::{CacheMap, Cacheable, VecCache},
15-
};
12+
use crate::qcow::qcow_raw_file::QcowRawFile;
13+
use crate::qcow::vec_cache::{CacheMap, Cacheable, VecCache};
1614

1715
#[derive(Debug, Error)]
1816
pub enum Error {

0 commit comments

Comments
 (0)