mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add a comment explaining the two checks
This commit is contained in:
parent
3ad154f484
commit
3e9d7e8aa8
@ -303,6 +303,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
||||
let (lo, hi) = layout.valid_range.clone().into_inner();
|
||||
let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits
|
||||
assert!(hi <= max_hi);
|
||||
// We could also write `(hi + 1) % (max_hi + 1) == lo` but `max_hi + 1` overflows for `u128`
|
||||
if (lo == 0 && hi == max_hi) || (hi + 1 == lo) {
|
||||
// Nothing to check
|
||||
return Ok(());
|
||||
|
Loading…
Reference in New Issue
Block a user