mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
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)
|
||||
fn has_compatible_to_type(&self, other: &Self) -> bool {
|
||||
transpose(self.to_type.as_ref(), other.to_type.as_ref())
|
||||
.map(|(l, r)| l == r)
|
||||
.unwrap_or(true)
|
||||
transpose(self.to_type.as_ref(), other.to_type.as_ref()).map_or(true, |(l, r)| l == r)
|
||||
}
|
||||
|
||||
/// Try to construct a new conversion if the conversion type is valid
|
||||
|
@ -149,7 +147,7 @@ impl<'a> Conversion<'a> {
|
|||
|
||||
impl ConversionType {
|
||||
/// 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) {
|
||||
Some(ConversionType::FromUnsigned)
|
||||
} else if SIGNED_TYPES.contains(&from) {
|
||||
|
|
|
@ -10,6 +10,7 @@ use rustc::ty;
|
|||
use rustc::ty::subst::InternalSubsts;
|
||||
use rustc::ty::util::IntTypeExt;
|
||||
use rustc::{declare_lint_pass, declare_tool_lint};
|
||||
use std::convert::TryFrom;
|
||||
use syntax::ast::{IntTy, UintTy};
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
@ -65,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
|
|||
match ty.sty {
|
||||
ty::Int(IntTy::Isize) => {
|
||||
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;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue