From ea745c0b298c76ef4baed748ea2cce4a53121f9e Mon Sep 17 00:00:00 2001 From: David Semakula Date: Thu, 23 Jan 2025 19:55:19 +0300 Subject: [PATCH] Deny overflowing (and lossy) integer type cast operations (#1895) * Deny overflowing (and lossy) integer type cast operations * Update docs --- CHANGELOG.md | 3 +++ crates/build/src/lib.rs | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cc7326b2..31f525954 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Unreleased] +### Added +- Deny overflowing (and lossy) integer type cast operations - [#1895](https://github.com/use-ink/cargo-contract/pull/1895) + ### Changed - Target `pallet-revive` instead of `pallet-contracts` - [#1851](https://github.com/use-ink/cargo-contract/pull/1851) diff --git a/crates/build/src/lib.rs b/crates/build/src/lib.rs index d1b0c3086..bdda314a6 100644 --- a/crates/build/src/lib.rs +++ b/crates/build/src/lib.rs @@ -504,9 +504,14 @@ fn exec_cargo_clippy(crate_metadata: &CrateMetadata, verbosity: Verbosity) -> Re "--all-features", // customize clippy lints after the "--" "--", - // this is a hard error because we want to guarantee that implicit overflows - // never happen + // these are hard errors because we want to guarantee that implicit overflows + // and lossy integer conversions never happen + // See https://github.com/use-ink/cargo-contract/pull/1190 "-Dclippy::arithmetic_side_effects", + // See https://github.com/use-ink/cargo-contract/pull/1895 + "-Dclippy::cast_possible_truncation", + "-Dclippy::cast_possible_wrap", + "-Dclippy::cast_sign_loss", ]; // we execute clippy with the plain manifest no temp dir required execute_cargo(util::cargo_cmd(