Fix clippy and rustfmt warnings

Using the latest version of Rust, Clippy, and rustfmt results in some
new warnings; this commit addresses these warnings.
parent 715aff37
Pipeline #141634238 failed with stages
in 64 minutes and 53 seconds
max_width = 80
use_try_shorthand = true
error_on_line_overflow = false
reorder_imports = true
......@@ -7,7 +7,6 @@
//! These settings are all stored in the Config struct, allowing various parts
//! of the VM to easily access these configuration details.
use crate::immix::block::BLOCK_SIZE;
use num_cpus;
use std::cmp::max;
use std::env;
use std::path::PathBuf;
......
//! Module for obtaining paths to directories, such as the home directory.
use dirs;
use std::env;
use std::io;
......
......@@ -58,7 +58,6 @@ use libffi::low::{
call as ffi_call, ffi_abi_FFI_DEFAULT_ABI as ABI, ffi_cif, ffi_type,
prep_cif, types, CodePtr, Error as FFIError,
};
use libloading;
use std::convert::Into;
use std::ffi::{CStr, OsStr};
use std::fmt::{Debug, Display};
......
//! Helper functionality for Unix based network pollers.
use nix;
use std::io;
pub fn map_error<T>(error: nix::Result<T>) -> io::Result<T> {
......
//! Floored integer divisions.
use num_bigint::BigInt;
use num_integer;
use num_integer::Integer;
pub trait FlooredDiv<RHS = Self> {
......
......@@ -39,34 +39,37 @@ use crate::vm::state::RcState;
/// Defines a method for getting the value of an object as a given type.
macro_rules! def_value_getter {
($name: ident, $getter: ident, $as_type: ident, $ok_type: ty) => (
($name: ident, $getter: ident, $as_type: ident, $ok_type: ty) => {
pub fn $name(&self) -> Result<$ok_type, String> {
if self.is_tagged_integer() {
Err(format!("ObjectPointer::{}() called on a tagged integer",
stringify!($as_type)))
Err(format!(
"ObjectPointer::{}() called on a tagged integer",
stringify!($as_type)
))
} else {
self.$getter().value.$as_type()
}
}
)
};
}
macro_rules! def_integer_value_getter {
($name: ident, $kind: ident, $error_name: expr) => (
($name: ident, $kind: ident, $error_name: expr) => {
pub fn $name(&self) -> Result<$kind, String> {
let int_val = self.integer_value()?;
if int_val < i64::from($kind::MIN) || int_val > i64::from($kind::MAX) {
if int_val < i64::from($kind::MIN)
|| int_val > i64::from($kind::MAX)
{
Err(format!(
"{} can not be converted to a {}",
int_val,
$error_name
int_val, $error_name
))
} else {
Ok(int_val as $kind)
}
}
)
};
}
/// The minimum integer value that can be stored as a tagged integer.
......
......@@ -31,7 +31,7 @@ macro_rules! socket_setter {
Ok(())
}
}
};
}
macro_rules! socket_getter {
......@@ -39,7 +39,7 @@ macro_rules! socket_getter {
pub fn $getter(&self) -> Result<$type, RuntimeError> {
Ok(self.socket.$getter()?)
}
}
};
}
macro_rules! socket_u32_getter {
......@@ -47,7 +47,7 @@ macro_rules! socket_u32_getter {
pub fn $getter(&self) -> Result<usize, RuntimeError> {
Ok(self.socket.$getter()? as usize)
}
}
};
}
macro_rules! socket_duration_setter {
......@@ -59,7 +59,7 @@ macro_rules! socket_duration_setter {
Ok(())
}
}
};
}
macro_rules! socket_duration_getter {
......@@ -69,7 +69,7 @@ macro_rules! socket_duration_getter {
Ok(duration::to_f64(dur))
}
}
};
}
const DOMAIN_IPV4: u8 = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment