Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b801792

Browse files
committed
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.
1 parent 85493df commit b801792

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/hir-ty/src/mir/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2122,7 +2122,7 @@ impl Evaluator<'_> {
21222122
}
21232123

21242124
pub fn pad16(x: &[u8], is_signed: bool) -> [u8; 16] {
2125-
let is_negative = is_signed && x.last().unwrap_or(&0) > &128;
2125+
let is_negative = is_signed && x.last().unwrap_or(&0) > &127;
21262126
let fill_with = if is_negative { 255 } else { 0 };
21272127
x.iter()
21282128
.copied()

0 commit comments

Comments
 (0)