Skip to content

Commit e0488c0

Browse files
committed
Fix StableMIR is_full computation
`WrappingRange::is_full` computation assumed that to be full the range couldn't wrap, which is not necessarily true. For example, a range of 1..=0 is a valid representation of a full wrapping range.
1 parent 7de1a1f commit e0488c0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/stable_mir/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl WrappingRange {
383383
return Err(error!("Expected size <= 128 bits, but found {} instead", size.bits()));
384384
};
385385
if self.start <= max_value && self.end <= max_value {
386-
Ok(self.start == 0 && max_value == self.end)
386+
Ok(self.start == (self.end.wrapping_add(1) & max_value))
387387
} else {
388388
Err(error!("Range `{self:?}` out of bounds for size `{}` bits.", size.bits()))
389389
}

0 commit comments

Comments
 (0)