From 10268c5b76f149dec523b83ca7dd34898fc31622 Mon Sep 17 00:00:00 2001 From: Guillaume Thiolliere Date: Fri, 27 Aug 2021 15:07:26 +0200 Subject: [PATCH] fix perthing add (#9638) --- substrate/primitives/arithmetic/src/per_things.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/substrate/primitives/arithmetic/src/per_things.rs b/substrate/primitives/arithmetic/src/per_things.rs index 59c7f36d0f..f9c048e55b 100644 --- a/substrate/primitives/arithmetic/src/per_things.rs +++ b/substrate/primitives/arithmetic/src/per_things.rs @@ -772,10 +772,12 @@ macro_rules! implement_per_thing { impl Add for $name { type Output = $name; + // For PerU16, $max == u16::MAX, so we need this `allow`. + #[allow(unused_comparisons)] #[inline] fn add(self, rhs: Self) -> Self::Output { let inner = self.deconstruct().add(rhs.deconstruct()); - debug_assert!(inner < $max); + debug_assert!(inner <= $max); $name::from_parts(inner) } }