Skip to content

Commit

Permalink
Rollup merge of rust-lang#122426 - celinval:smir-fix-full, r=oli-obk
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Mar 13, 2024
2 parents d228c0c + e0488c0 commit 50c35ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/stable_mir/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl WrappingRange {
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()))
}
Expand Down

0 comments on commit 50c35ce

Please sign in to comment.