Enable and fix several more clippy lints.

This commit is contained in:
Dan Gohman
2018-04-02 08:48:06 -07:00
parent 5c6cb202d8
commit bf597b7abf
71 changed files with 360 additions and 219 deletions

View File

@@ -30,9 +30,20 @@
//! `Vec`.
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces, unstable_features)]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive, redundant_field_names))]
allow(new_without_default, new_without_default_derive))]
#![cfg_attr(feature="cargo-clippy", warn(
float_arithmetic,
mut_mut,
nonminimal_bool,
option_map_unwrap_or,
option_map_unwrap_or_else,
print_stdout,
unicode_not_nfc,
use_self,
))]
// Turns on no_std and alloc features if std is not available.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -91,7 +102,7 @@ macro_rules! entity_impl {
impl $crate::__core::fmt::Display for $entity {
fn fmt(&self, f: &mut $crate::__core::fmt::Formatter) -> $crate::__core::fmt::Result {
write!(f, "{}{}", $display_prefix, self.0)
write!(f, concat!($display_prefix, "{}"), self.0)
}
}

View File

@@ -49,7 +49,7 @@ where
pub fn with_default(default: V) -> Self {
Self {
elems: Vec::new(),
default: default,
default,
unused: PhantomData,
}
}

View File

@@ -28,7 +28,7 @@ impl<T: ReservedValue> PackedOption<T> {
/// Returns `true` if the packed option is a `Some` value.
pub fn is_some(&self) -> bool {
!self.is_none()
self.0 != T::reserved_value()
}
/// Expand the packed option into a normal `Option`.
@@ -62,14 +62,14 @@ impl<T: ReservedValue> PackedOption<T> {
impl<T: ReservedValue> Default for PackedOption<T> {
/// Create a default packed option representing `None`.
fn default() -> PackedOption<T> {
fn default() -> Self {
PackedOption(T::reserved_value())
}
}
impl<T: ReservedValue> From<T> for PackedOption<T> {
/// Convert `t` into a packed `Some(x)`.
fn from(t: T) -> PackedOption<T> {
fn from(t: T) -> Self {
debug_assert!(
t != T::reserved_value(),
"Can't make a PackedOption from the reserved value."
@@ -80,7 +80,7 @@ impl<T: ReservedValue> From<T> for PackedOption<T> {
impl<T: ReservedValue> From<Option<T>> for PackedOption<T> {
/// Convert an option into its packed equivalent.
fn from(opt: Option<T>) -> PackedOption<T> {
fn from(opt: Option<T>) -> Self {
match opt {
None => Self::default(),
Some(t) => t.into(),