Skip to content

Commit 0965ccf

Browse files
committed
rustfmt: format doc comments
Fixes #1321. Signed-off-by: Diana Popa <[email protected]>
1 parent cd29c64 commit 0965ccf

File tree

9 files changed

+54
-65
lines changed

9 files changed

+54
-65
lines changed

src/api_server/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ impl ApiServer {
109109
/// # Example
110110
///
111111
/// ```
112-
/// use mmds::MAX_DATA_STORE_SIZE;
113112
/// use api_server::ApiServer;
113+
/// use logger::ProcessTimeReporter;
114+
/// use mmds::MAX_DATA_STORE_SIZE;
114115
/// use mmds::MMDS;
116+
/// use std::env::consts::ARCH;
115117
/// use std::{
116118
/// convert::TryInto, io::Read, io::Write, os::unix::net::UnixStream, path::PathBuf,
117119
/// sync::mpsc::channel, thread, time::Duration,
118120
/// };
119-
/// use std::env::consts::ARCH;
120121
/// use utils::{eventfd::EventFd, tempfile::TempFile};
121-
/// use logger::ProcessTimeReporter;
122122
/// use vmm::rpc_interface::VmmData;
123123
/// use vmm::seccomp_filters::{get_filters, SeccompConfig};
124124
/// use vmm::vmm_config::instance_info::InstanceInfo;

src/cpuid/src/bit_helper.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ pub trait BitRangeExt<T> {
4444
/// use cpuid::bit_helper::*;
4545
///
4646
/// let range = BitRange {
47-
/// msb_index: 7,
48-
/// lsb_index: 3,
47+
/// msb_index: 7,
48+
/// lsb_index: 3,
4949
/// };
5050
/// println!("binary value: {:b}", range.get_mask());
5151
/// ```

src/logger/src/logger.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//! ## Example for logging to stdout/stderr
2121
//!
2222
//! ```
23-
//! use logger::{warn, error, LOGGER};
23+
//! use logger::{error, warn, LOGGER};
2424
//! use std::ops::Deref;
2525
//!
2626
//! // Optionally do an initial configuration for the logger.
@@ -35,17 +35,14 @@
3535
//!
3636
//! ```
3737
//! use libc::c_char;
38+
//! use logger::{error, warn, LOGGER};
3839
//! use std::io::Cursor;
39-
//! use logger::{warn, error, LOGGER};
4040
//!
4141
//! let mut logs = Cursor::new(vec![0; 15]);
4242
//!
4343
//! // Initialize the logger to log to a FIFO that was created beforehand.
4444
//! assert!(LOGGER
45-
//! .init(
46-
//! "Running Firecracker v.x".to_string(),
47-
//! Box::new(logs),
48-
//! )
45+
//! .init("Running Firecracker v.x".to_string(), Box::new(logs),)
4946
//! .is_ok());
5047
//! // The following messages should appear in the in-memory buffer `logs`.
5148
//! warn!("this is a warning");
@@ -305,9 +302,9 @@ impl Logger {
305302
/// use std::ops::Deref;
306303
///
307304
/// LOGGER
308-
/// .deref()
309-
/// .configure(Some("MY-INSTANCE".to_string()))
310-
/// .unwrap();
305+
/// .deref()
306+
/// .configure(Some("MY-INSTANCE".to_string()))
307+
/// .unwrap();
311308
/// ```
312309
pub fn configure(&self, instance_id: Option<String>) -> Result<()> {
313310
self.init
@@ -341,10 +338,7 @@ impl Logger {
341338
///
342339
/// let mut logs = Cursor::new(vec![0; 15]);
343340
///
344-
/// LOGGER.init(
345-
/// "Running Firecracker v.x".to_string(),
346-
/// Box::new(logs),
347-
/// );
341+
/// LOGGER.init("Running Firecracker v.x".to_string(), Box::new(logs));
348342
/// ```
349343
pub fn init(&self, header: String, log_dest: Box<dyn Write + Send>) -> Result<()> {
350344
self.init

src/mmds/src/data_store.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl Mmds {
226226
/// "key2" : "value3"
227227
/// "key3" : "value3"
228228
/// }
229-
///```
229+
/// ```
230230
///
231231
/// IMDS formatted JSON object:
232232
/// ```text

src/net_gen/src/iff.rs

+39-39
Original file line numberDiff line numberDiff line change
@@ -2727,45 +2727,45 @@ pub const net_device_flags_IFF_PORTSEL: net_device_flags = 8192;
27272727
pub const net_device_flags_IFF_AUTOMEDIA: net_device_flags = 16384;
27282728
pub const net_device_flags_IFF_DYNAMIC: net_device_flags = 32768;
27292729
/**
2730-
** enum net_device_flags - &struct net_device flags
2731-
**
2732-
** These are the &struct net_device flags, they can be set by drivers, the
2733-
** kernel and some can be triggered by userspace. Userspace can query and
2734-
** set these flags using userspace utilities but there is also a sysfs
2735-
** entry available for all dev flags which can be queried and set. These flags
2736-
** are shared for all types of net_devices. The sysfs entries are available
2737-
** via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs
2738-
** are annotated below, note that only a few flags can be toggled and some
2739-
** other flags are always preserved from the original net_device flags
2740-
** even if you try to set them via sysfs. Flags which are always preserved
2741-
** are kept under the flag grouping @IFF_VOLATILE. Flags which are __volatile__
2742-
** are annotated below as such.
2743-
**
2744-
** You should have a pretty good reason to be extending these flags.
2745-
**
2746-
** @IFF_UP: interface is up. Can be toggled through sysfs.
2747-
** @IFF_BROADCAST: broadcast address valid. Volatile.
2748-
** @IFF_DEBUG: turn on debugging. Can be toggled through sysfs.
2749-
** @IFF_LOOPBACK: is a loopback net. Volatile.
2750-
** @IFF_POINTOPOINT: interface is has p-p link. Volatile.
2751-
** @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs.
2752-
** Volatile.
2753-
** @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile.
2754-
** @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile.
2755-
** @IFF_PROMISC: receive all packets. Can be toggled through sysfs.
2756-
** @IFF_ALLMULTI: receive all multicast packets. Can be toggled through
2757-
** sysfs.
2758-
** @IFF_MASTER: master of a load balancer. Volatile.
2759-
** @IFF_SLAVE: slave of a load balancer. Volatile.
2760-
** @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs.
2761-
** @IFF_PORTSEL: can set media type. Can be toggled through sysfs.
2762-
** @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs.
2763-
** @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled
2764-
** through sysfs.
2765-
** @IFF_LOWER_UP: driver signals L1 up. Volatile.
2766-
** @IFF_DORMANT: driver signals dormant. Volatile.
2767-
** @IFF_ECHO: echo sent packets. Volatile.
2768-
**/
2730+
* enum net_device_flags - &struct net_device flags
2731+
*
2732+
* These are the &struct net_device flags, they can be set by drivers, the
2733+
* kernel and some can be triggered by userspace. Userspace can query and
2734+
* set these flags using userspace utilities but there is also a sysfs
2735+
* entry available for all dev flags which can be queried and set. These flags
2736+
* are shared for all types of net_devices. The sysfs entries are available
2737+
* via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs
2738+
* are annotated below, note that only a few flags can be toggled and some
2739+
* other flags are always preserved from the original net_device flags
2740+
* even if you try to set them via sysfs. Flags which are always preserved
2741+
* are kept under the flag grouping @IFF_VOLATILE. Flags which are __volatile__
2742+
* are annotated below as such.
2743+
*
2744+
* You should have a pretty good reason to be extending these flags.
2745+
*
2746+
* @IFF_UP: interface is up. Can be toggled through sysfs.
2747+
* @IFF_BROADCAST: broadcast address valid. Volatile.
2748+
* @IFF_DEBUG: turn on debugging. Can be toggled through sysfs.
2749+
* @IFF_LOOPBACK: is a loopback net. Volatile.
2750+
* @IFF_POINTOPOINT: interface is has p-p link. Volatile.
2751+
* @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs.
2752+
* Volatile.
2753+
* @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile.
2754+
* @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile.
2755+
* @IFF_PROMISC: receive all packets. Can be toggled through sysfs.
2756+
* @IFF_ALLMULTI: receive all multicast packets. Can be toggled through
2757+
* sysfs.
2758+
* @IFF_MASTER: master of a load balancer. Volatile.
2759+
* @IFF_SLAVE: slave of a load balancer. Volatile.
2760+
* @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs.
2761+
* @IFF_PORTSEL: can set media type. Can be toggled through sysfs.
2762+
* @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs.
2763+
* @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled
2764+
* through sysfs.
2765+
* @IFF_LOWER_UP: driver signals L1 up. Volatile.
2766+
* @IFF_DORMANT: driver signals dormant. Volatile.
2767+
* @IFF_ECHO: echo sent packets. Volatile.
2768+
*/
27692769
pub type net_device_flags = ::std::os::raw::c_uint;
27702770
pub const IF_OPER_UNKNOWN: _bindgen_ty_4 = 0;
27712771
pub const IF_OPER_NOTPRESENT: _bindgen_ty_4 = 1;

src/snapshot/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//! primitives types (currently we use versionize that uses serde bincode as a backend). The current
2525
//! implementation does not have any logic dependent on it.
2626
//! - **the data version** which refers to the state.
27-
//!
2827
mod persist;
2928
pub use crate::persist::Persist;
3029

src/utils/src/net/ipv4addr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::net::Ipv4Addr;
1111
/// use utils::net::ipv4addr::is_link_local_valid;
1212
///
1313
/// is_link_local_valid(Ipv4Addr::new(169, 254, 1, 1));
14-
///
1514
pub fn is_link_local_valid(ipv4_addr: Ipv4Addr) -> bool {
1615
match ipv4_addr.octets() {
1716
[169, 254, 0, _] => false,

src/utils/src/sm.rs

-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ impl<T> StateMachine<T> {
2424
/// # Arguments
2525
///
2626
/// `function` - the state handler for this state.
27-
///
2827
pub fn new(function: Option<StateFn<T>>) -> StateMachine<T> {
2928
StateMachine { function }
3029
}
@@ -34,7 +33,6 @@ impl<T> StateMachine<T> {
3433
/// # Arguments
3534
///
3635
/// `function` - the state handler for this state.
37-
///
3836
pub fn next(function: StateFn<T>) -> StateMachine<T> {
3937
StateMachine::new(Some(function))
4038
}
@@ -45,7 +43,6 @@ impl<T> StateMachine<T> {
4543
/// # Arguments
4644
///
4745
/// `function` - the state handler for this last state.
48-
///
4946
pub fn finish() -> StateMachine<T> {
5047
StateMachine::new(None)
5148
}
@@ -57,7 +54,6 @@ impl<T> StateMachine<T> {
5754
/// `machine` - a mutable reference to the object running through the various states.
5855
/// `starting_state_fn` - a `fn(&mut T) -> StateMachine<T>` that should be the handler for
5956
/// the initial state.
60-
///
6157
pub fn run(machine: &mut T, starting_state_fn: StateFn<T>) {
6258
// Start off in the `starting_state` state.
6359
let mut state_machine = StateMachine::new(Some(starting_state_fn));

tests/integration_tests/style/test_rust.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def test_rust_style():
1313
"""
1414
# Check that the output is empty.
1515
_, stdout, _ = utils.run_cmd(
16-
'cargo fmt --all -- --check')
16+
'cargo fmt --all -- --check '
17+
'--config format_code_in_doc_comments=true')
1718

1819
# rustfmt prepends `"Diff in"` to the reported output.
1920
assert "Diff in" not in stdout

0 commit comments

Comments
 (0)