Rollup merge of #122426 - celinval:smir-fix-full, r=oli-obk

Fix StableMIR `WrappingRange::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.
This commit is contained in:
Matthias Krüger
2024-03-13 20:01:55 +01:00
committed by GitHub
+1 -1
View File
@@ -383,7 +383,7 @@ pub fn is_full(&self, size: Size) -> Result<bool, Error> {
return Err(error!("Expected size <= 128 bits, but found {} instead", size.bits()));
};
if self.start <= max_value && self.end <= max_value {
Ok(self.start == 0 && max_value == self.end)
Ok(self.start == (self.end.wrapping_add(1) & max_value))
} else {
Err(error!("Range `{self:?}` out of bounds for size `{}` bits.", size.bits()))
}