diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2018-09-06 15:57:32 +0200 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2018-09-13 07:59:12 +0200 |
| commit | 28424ecbfa2e644fb4661c7019346f46dd1eefd1 (patch) | |
| tree | 80c7815539d672355b8da7f2216ed394a42b9018 | |
| parent | e8400061bd813fa768e94534028c875ee2c9fe89 (diff) | |
| download | rust-28424ecbfa2e644fb4661c7019346f46dd1eefd1.tar.gz rust-28424ecbfa2e644fb4661c7019346f46dd1eefd1.zip | |
fix warnings about trivial casts, mostly {i,u}128 -> {i,u}128, such as "i128::min_value() as i128"
| -rw-r--r-- | clippy_lints/src/consts.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/lib.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/types.rs | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 6f646e340a0..bcc85c31376 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -206,7 +206,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { ty::Array(_, n) => n.assert_usize(self.tcx).expect("array length"), _ => span_bug!(e.span, "typeck error"), }; - self.expr(value).map(|v| Constant::Repeat(Box::new(v), n as u64)) + self.expr(value).map(|v| Constant::Repeat(Box::new(v), n)) }, ExprKind::Unary(op, ref operand) => self.expr(operand).and_then(|o| match op { UnNot => self.constant_not(&o, self.tables.expr_ty(e)), diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index e7a8006e5ab..5f001901481 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -9,7 +9,7 @@ #![recursion_limit = "256"] #![feature(macro_at_most_once_rep)] #![feature(tool_lints)] -#![warn(rust_2018_idioms)] +#![warn(rust_2018_idioms, trivial_casts, trivial_numeric_casts)] #![feature(crate_visibility_modifier)] use toml; diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index cc04eb8eece..66b6fe6170a 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -1588,7 +1588,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> FullInt::S(i128::from(i64::min_value())), FullInt::S(i128::from(i64::max_value())), ), - IntTy::I128 => (FullInt::S(i128::min_value() as i128), FullInt::S(i128::max_value() as i128)), + IntTy::I128 => (FullInt::S(i128::min_value()), FullInt::S(i128::max_value())), IntTy::Isize => (FullInt::S(isize::min_value() as i128), FullInt::S(isize::max_value() as i128)), }), ty::Uint(uint_ty) => Some(match uint_ty { @@ -1605,7 +1605,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> FullInt::U(u128::from(u64::min_value())), FullInt::U(u128::from(u64::max_value())), ), - UintTy::U128 => (FullInt::U(u128::min_value() as u128), FullInt::U(u128::max_value() as u128)), + UintTy::U128 => (FullInt::U(u128::min_value()), FullInt::U(u128::max_value())), UintTy::Usize => (FullInt::U(usize::min_value() as u128), FullInt::U(usize::max_value() as u128)), }), _ => None, |
