Skip to content

Commit 28424ec

Browse files
committed
fix warnings about trivial casts, mostly {i,u}128 -> {i,u}128, such as "i128::min_value() as i128"
1 parent e840006 commit 28424ec

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

clippy_lints/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
206206
ty::Array(_, n) => n.assert_usize(self.tcx).expect("array length"),
207207
_ => span_bug!(e.span, "typeck error"),
208208
};
209-
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n as u64))
209+
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))
210210
},
211211
ExprKind::Unary(op, ref operand) => self.expr(operand).and_then(|o| match op {
212212
UnNot => self.constant_not(&o, self.tables.expr_ty(e)),

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#![recursion_limit = "256"]
1010
#![feature(macro_at_most_once_rep)]
1111
#![feature(tool_lints)]
12-
#![warn(rust_2018_idioms)]
12+
#![warn(rust_2018_idioms, trivial_casts, trivial_numeric_casts)]
1313
#![feature(crate_visibility_modifier)]
1414

1515
use toml;

clippy_lints/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) ->
15881588
FullInt::S(i128::from(i64::min_value())),
15891589
FullInt::S(i128::from(i64::max_value())),
15901590
),
1591-
IntTy::I128 => (FullInt::S(i128::min_value() as i128), FullInt::S(i128::max_value() as i128)),
1591+
IntTy::I128 => (FullInt::S(i128::min_value()), FullInt::S(i128::max_value())),
15921592
IntTy::Isize => (FullInt::S(isize::min_value() as i128), FullInt::S(isize::max_value() as i128)),
15931593
}),
15941594
ty::Uint(uint_ty) => Some(match uint_ty {
@@ -1605,7 +1605,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) ->
16051605
FullInt::U(u128::from(u64::min_value())),
16061606
FullInt::U(u128::from(u64::max_value())),
16071607
),
1608-
UintTy::U128 => (FullInt::U(u128::min_value() as u128), FullInt::U(u128::max_value() as u128)),
1608+
UintTy::U128 => (FullInt::U(u128::min_value()), FullInt::U(u128::max_value())),
16091609
UintTy::Usize => (FullInt::U(usize::min_value() as u128), FullInt::U(usize::max_value() as u128)),
16101610
}),
16111611
_ => None,

0 commit comments

Comments
 (0)