Skip to content

rustfmt: format doc comments #2866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/api_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ impl ApiServer {
/// # Example
///
/// ```
/// use mmds::MAX_DATA_STORE_SIZE;
/// use api_server::ApiServer;
/// use logger::ProcessTimeReporter;
/// use mmds::MAX_DATA_STORE_SIZE;
/// use mmds::MMDS;
/// use std::env::consts::ARCH;
/// use std::{
/// convert::TryInto, io::Read, io::Write, os::unix::net::UnixStream, path::PathBuf,
/// sync::mpsc::channel, thread, time::Duration,
/// };
/// use std::env::consts::ARCH;
/// use utils::{eventfd::EventFd, tempfile::TempFile};
/// use logger::ProcessTimeReporter;
/// use vmm::rpc_interface::VmmData;
/// use vmm::seccomp_filters::{get_filters, SeccompConfig};
/// use vmm::vmm_config::instance_info::InstanceInfo;
Expand Down
4 changes: 2 additions & 2 deletions src/cpuid/src/bit_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ pub trait BitRangeExt<T> {
/// use cpuid::bit_helper::*;
///
/// let range = BitRange {
/// msb_index: 7,
/// lsb_index: 3,
/// msb_index: 7,
/// lsb_index: 3,
/// };
/// println!("binary value: {:b}", range.get_mask());
/// ```
Expand Down
20 changes: 7 additions & 13 deletions src/logger/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! ## Example for logging to stdout/stderr
//!
//! ```
//! use logger::{warn, error, LOGGER};
//! use logger::{error, warn, LOGGER};
//! use std::ops::Deref;
//!
//! // Optionally do an initial configuration for the logger.
Expand All @@ -35,17 +35,14 @@
//!
//! ```
//! use libc::c_char;
//! use logger::{error, warn, LOGGER};
//! use std::io::Cursor;
//! use logger::{warn, error, LOGGER};
//!
//! let mut logs = Cursor::new(vec![0; 15]);
//!
//! // Initialize the logger to log to a FIFO that was created beforehand.
//! assert!(LOGGER
//! .init(
//! "Running Firecracker v.x".to_string(),
//! Box::new(logs),
//! )
//! .init("Running Firecracker v.x".to_string(), Box::new(logs),)
//! .is_ok());
//! // The following messages should appear in the in-memory buffer `logs`.
//! warn!("this is a warning");
Expand Down Expand Up @@ -305,9 +302,9 @@ impl Logger {
/// use std::ops::Deref;
///
/// LOGGER
/// .deref()
/// .configure(Some("MY-INSTANCE".to_string()))
/// .unwrap();
/// .deref()
/// .configure(Some("MY-INSTANCE".to_string()))
/// .unwrap();
/// ```
pub fn configure(&self, instance_id: Option<String>) -> Result<()> {
self.init
Expand Down Expand Up @@ -341,10 +338,7 @@ impl Logger {
///
/// let mut logs = Cursor::new(vec![0; 15]);
///
/// LOGGER.init(
/// "Running Firecracker v.x".to_string(),
/// Box::new(logs),
/// );
/// LOGGER.init("Running Firecracker v.x".to_string(), Box::new(logs));
/// ```
pub fn init(&self, header: String, log_dest: Box<dyn Write + Send>) -> Result<()> {
self.init
Expand Down
2 changes: 1 addition & 1 deletion src/mmds/src/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Mmds {
/// "key2" : "value3"
/// "key3" : "value3"
/// }
///```
/// ```
///
/// IMDS formatted JSON object:
/// ```text
Expand Down
78 changes: 39 additions & 39 deletions src/net_gen/src/iff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2727,45 +2727,45 @@ pub const net_device_flags_IFF_PORTSEL: net_device_flags = 8192;
pub const net_device_flags_IFF_AUTOMEDIA: net_device_flags = 16384;
pub const net_device_flags_IFF_DYNAMIC: net_device_flags = 32768;
/**
** enum net_device_flags - &struct net_device flags
**
** These are the &struct net_device flags, they can be set by drivers, the
** kernel and some can be triggered by userspace. Userspace can query and
** set these flags using userspace utilities but there is also a sysfs
** entry available for all dev flags which can be queried and set. These flags
** are shared for all types of net_devices. The sysfs entries are available
** via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs
** are annotated below, note that only a few flags can be toggled and some
** other flags are always preserved from the original net_device flags
** even if you try to set them via sysfs. Flags which are always preserved
** are kept under the flag grouping @IFF_VOLATILE. Flags which are __volatile__
** are annotated below as such.
**
** You should have a pretty good reason to be extending these flags.
**
** @IFF_UP: interface is up. Can be toggled through sysfs.
** @IFF_BROADCAST: broadcast address valid. Volatile.
** @IFF_DEBUG: turn on debugging. Can be toggled through sysfs.
** @IFF_LOOPBACK: is a loopback net. Volatile.
** @IFF_POINTOPOINT: interface is has p-p link. Volatile.
** @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs.
** Volatile.
** @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile.
** @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile.
** @IFF_PROMISC: receive all packets. Can be toggled through sysfs.
** @IFF_ALLMULTI: receive all multicast packets. Can be toggled through
** sysfs.
** @IFF_MASTER: master of a load balancer. Volatile.
** @IFF_SLAVE: slave of a load balancer. Volatile.
** @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs.
** @IFF_PORTSEL: can set media type. Can be toggled through sysfs.
** @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs.
** @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled
** through sysfs.
** @IFF_LOWER_UP: driver signals L1 up. Volatile.
** @IFF_DORMANT: driver signals dormant. Volatile.
** @IFF_ECHO: echo sent packets. Volatile.
**/
* enum net_device_flags - &struct net_device flags
*
* These are the &struct net_device flags, they can be set by drivers, the
* kernel and some can be triggered by userspace. Userspace can query and
* set these flags using userspace utilities but there is also a sysfs
* entry available for all dev flags which can be queried and set. These flags
* are shared for all types of net_devices. The sysfs entries are available
* via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs
* are annotated below, note that only a few flags can be toggled and some
* other flags are always preserved from the original net_device flags
* even if you try to set them via sysfs. Flags which are always preserved
* are kept under the flag grouping @IFF_VOLATILE. Flags which are __volatile__
* are annotated below as such.
*
* You should have a pretty good reason to be extending these flags.
*
* @IFF_UP: interface is up. Can be toggled through sysfs.
* @IFF_BROADCAST: broadcast address valid. Volatile.
* @IFF_DEBUG: turn on debugging. Can be toggled through sysfs.
* @IFF_LOOPBACK: is a loopback net. Volatile.
* @IFF_POINTOPOINT: interface is has p-p link. Volatile.
* @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs.
* Volatile.
* @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile.
* @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile.
* @IFF_PROMISC: receive all packets. Can be toggled through sysfs.
* @IFF_ALLMULTI: receive all multicast packets. Can be toggled through
* sysfs.
* @IFF_MASTER: master of a load balancer. Volatile.
* @IFF_SLAVE: slave of a load balancer. Volatile.
* @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs.
* @IFF_PORTSEL: can set media type. Can be toggled through sysfs.
* @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs.
* @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled
* through sysfs.
* @IFF_LOWER_UP: driver signals L1 up. Volatile.
* @IFF_DORMANT: driver signals dormant. Volatile.
* @IFF_ECHO: echo sent packets. Volatile.
*/
pub type net_device_flags = ::std::os::raw::c_uint;
pub const IF_OPER_UNKNOWN: _bindgen_ty_4 = 0;
pub const IF_OPER_NOTPRESENT: _bindgen_ty_4 = 1;
Expand Down
1 change: 0 additions & 1 deletion src/snapshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//! primitives types (currently we use versionize that uses serde bincode as a backend). The current
//! implementation does not have any logic dependent on it.
//! - **the data version** which refers to the state.
//!
mod persist;
pub use crate::persist::Persist;

Expand Down
1 change: 0 additions & 1 deletion src/utils/src/net/ipv4addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::net::Ipv4Addr;
/// use utils::net::ipv4addr::is_link_local_valid;
///
/// is_link_local_valid(Ipv4Addr::new(169, 254, 1, 1));
///
pub fn is_link_local_valid(ipv4_addr: Ipv4Addr) -> bool {
match ipv4_addr.octets() {
[169, 254, 0, _] => false,
Expand Down
4 changes: 0 additions & 4 deletions src/utils/src/sm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl<T> StateMachine<T> {
/// # Arguments
///
/// `function` - the state handler for this state.
///
pub fn new(function: Option<StateFn<T>>) -> StateMachine<T> {
StateMachine { function }
}
Expand All @@ -34,7 +33,6 @@ impl<T> StateMachine<T> {
/// # Arguments
///
/// `function` - the state handler for this state.
///
pub fn next(function: StateFn<T>) -> StateMachine<T> {
StateMachine::new(Some(function))
}
Expand All @@ -45,7 +43,6 @@ impl<T> StateMachine<T> {
/// # Arguments
///
/// `function` - the state handler for this last state.
///
pub fn finish() -> StateMachine<T> {
StateMachine::new(None)
}
Expand All @@ -57,7 +54,6 @@ impl<T> StateMachine<T> {
/// `machine` - a mutable reference to the object running through the various states.
/// `starting_state_fn` - a `fn(&mut T) -> StateMachine<T>` that should be the handler for
/// the initial state.
///
pub fn run(machine: &mut T, starting_state_fn: StateFn<T>) {
// Start off in the `starting_state` state.
let mut state_machine = StateMachine::new(Some(starting_state_fn));
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/style/test_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def test_rust_style():
"""
# Check that the output is empty.
_, stdout, _ = utils.run_cmd(
'cargo fmt --all -- --check')
'cargo fmt --all -- --check '
'--config format_code_in_doc_comments=true')

# rustfmt prepends `"Diff in"` to the reported output.
assert "Diff in" not in stdout
Expand Down