Fixed more lint findings.
This commit is contained in:
parent
1c86b3758d
commit
0a43dcfd04
2 changed files with 4 additions and 5 deletions
|
@ -123,9 +123,7 @@ impl<'a> Conversion<'a> {
|
||||||
|
|
||||||
/// Checks if the to-type is the same (if there is a type constraint)
|
/// Checks if the to-type is the same (if there is a type constraint)
|
||||||
fn has_compatible_to_type(&self, other: &Self) -> bool {
|
fn has_compatible_to_type(&self, other: &Self) -> bool {
|
||||||
transpose(self.to_type.as_ref(), other.to_type.as_ref())
|
transpose(self.to_type.as_ref(), other.to_type.as_ref()).map_or(true, |(l, r)| l == r)
|
||||||
.map(|(l, r)| l == r)
|
|
||||||
.unwrap_or(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to construct a new conversion if the conversion type is valid
|
/// Try to construct a new conversion if the conversion type is valid
|
||||||
|
@ -149,7 +147,7 @@ impl<'a> Conversion<'a> {
|
||||||
|
|
||||||
impl ConversionType {
|
impl ConversionType {
|
||||||
/// Creates a conversion type if the type is allowed & conversion is valid
|
/// Creates a conversion type if the type is allowed & conversion is valid
|
||||||
fn try_new(from: &str, to: &str) -> Option<ConversionType> {
|
fn try_new(from: &str, to: &str) -> Option<Self> {
|
||||||
if UNSIGNED_TYPES.contains(&from) {
|
if UNSIGNED_TYPES.contains(&from) {
|
||||||
Some(ConversionType::FromUnsigned)
|
Some(ConversionType::FromUnsigned)
|
||||||
} else if SIGNED_TYPES.contains(&from) {
|
} else if SIGNED_TYPES.contains(&from) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ use rustc::ty;
|
||||||
use rustc::ty::subst::InternalSubsts;
|
use rustc::ty::subst::InternalSubsts;
|
||||||
use rustc::ty::util::IntTypeExt;
|
use rustc::ty::util::IntTypeExt;
|
||||||
use rustc::{declare_lint_pass, declare_tool_lint};
|
use rustc::{declare_lint_pass, declare_tool_lint};
|
||||||
|
use std::convert::TryFrom;
|
||||||
use syntax::ast::{IntTy, UintTy};
|
use syntax::ast::{IntTy, UintTy};
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -65,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::Int(IntTy::Isize) => {
|
ty::Int(IntTy::Isize) => {
|
||||||
let val = ((val as i128) << 64) >> 64;
|
let val = ((val as i128) << 64) >> 64;
|
||||||
if val <= i128::from(i32::max_value()) && val >= i128::from(i32::min_value()) {
|
if i32::try_from(val).is_ok() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue