Skip to content

Commit 0a43dcf

Browse files
committed
Fixed more lint findings.
1 parent 1c86b37 commit 0a43dcf

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

clippy_lints/src/checked_conversions.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ impl<'a> Conversion<'a> {
123123

124124
/// Checks if the to-type is the same (if there is a type constraint)
125125
fn has_compatible_to_type(&self, other: &Self) -> bool {
126-
transpose(self.to_type.as_ref(), other.to_type.as_ref())
127-
.map(|(l, r)| l == r)
128-
.unwrap_or(true)
126+
transpose(self.to_type.as_ref(), other.to_type.as_ref()).map_or(true, |(l, r)| l == r)
129127
}
130128

131129
/// Try to construct a new conversion if the conversion type is valid
@@ -149,7 +147,7 @@ impl<'a> Conversion<'a> {
149147

150148
impl ConversionType {
151149
/// Creates a conversion type if the type is allowed & conversion is valid
152-
fn try_new(from: &str, to: &str) -> Option<ConversionType> {
150+
fn try_new(from: &str, to: &str) -> Option<Self> {
153151
if UNSIGNED_TYPES.contains(&from) {
154152
Some(ConversionType::FromUnsigned)
155153
} else if SIGNED_TYPES.contains(&from) {

clippy_lints/src/enum_clike.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc::ty;
1010
use rustc::ty::subst::InternalSubsts;
1111
use rustc::ty::util::IntTypeExt;
1212
use rustc::{declare_lint_pass, declare_tool_lint};
13+
use std::convert::TryFrom;
1314
use syntax::ast::{IntTy, UintTy};
1415

1516
declare_clippy_lint! {
@@ -65,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
6566
match ty.sty {
6667
ty::Int(IntTy::Isize) => {
6768
let val = ((val as i128) << 64) >> 64;
68-
if val <= i128::from(i32::max_value()) && val >= i128::from(i32::min_value()) {
69+
if i32::try_from(val).is_ok() {
6970
continue;
7071
}
7172
},

0 commit comments

Comments
 (0)