From b8017928af94871eba9973ff66086a65bcff3a64 Mon Sep 17 00:00:00 2001 From: dfireBird Date: Thu, 22 Jun 2023 12:43:29 +0530 Subject: [PATCH] Change comparsion for checking if number is negative to include 128 Reason: The last byte in Little Endian representation of negative integers start at 128 (Ox80) till 255 (OxFF). The comparison before the fix didn't check for 128 which made is_negative variable as false. --- crates/hir-ty/src/mir/eval.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs index 9acf9d39e5..28b6066c19 100644 --- a/crates/hir-ty/src/mir/eval.rs +++ b/crates/hir-ty/src/mir/eval.rs @@ -2122,7 +2122,7 @@ impl Evaluator<'_> { } pub fn pad16(x: &[u8], is_signed: bool) -> [u8; 16] { - let is_negative = is_signed && x.last().unwrap_or(&0) > &128; + let is_negative = is_signed && x.last().unwrap_or(&0) > &127; let fill_with = if is_negative { 255 } else { 0 }; x.iter() .copied()