Skip to content

Commit dac5e2d

Browse files
authored
Merge pull request #3140 from matthiaskrgr/redundant_casts
fix warnings about trivial casts, mostly {i,u}128 -> {i,u}128, such as "i128::min_value() as i128"
2 parents fd86f8f + 28424ec commit dac5e2d

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
@@ -1590,7 +1590,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) ->
15901590
FullInt::S(i128::from(i64::min_value())),
15911591
FullInt::S(i128::from(i64::max_value())),
15921592
),
1593-
IntTy::I128 => (FullInt::S(i128::min_value() as i128), FullInt::S(i128::max_value() as i128)),
1593+
IntTy::I128 => (FullInt::S(i128::min_value()), FullInt::S(i128::max_value())),
15941594
IntTy::Isize => (FullInt::S(isize::min_value() as i128), FullInt::S(isize::max_value() as i128)),
15951595
}),
15961596
ty::Uint(uint_ty) => Some(match uint_ty {
@@ -1607,7 +1607,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) ->
16071607
FullInt::U(u128::from(u64::min_value())),
16081608
FullInt::U(u128::from(u64::max_value())),
16091609
),
1610-
UintTy::U128 => (FullInt::U(u128::min_value() as u128), FullInt::U(u128::max_value() as u128)),
1610+
UintTy::U128 => (FullInt::U(u128::min_value()), FullInt::U(u128::max_value())),
16111611
UintTy::Usize => (FullInt::U(usize::min_value() as u128), FullInt::U(usize::max_value() as u128)),
16121612
}),
16131613
_ => None,

0 commit comments

Comments
 (0)