diff options
| author | Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer <github35764891676564198441@oli-obk.de> | 2018-10-29 21:31:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-29 21:31:22 +0100 |
| commit | 3e9d7e8aa8b73ea3d73940a573523fd498181b6e (patch) | |
| tree | 4993f52c0f3eb6f49a0c9ce133c2be13825a8d84 | |
| parent | 3ad154f4842e9a1f09b5da37a76a333691f31784 (diff) | |
| download | rust-3e9d7e8aa8b73ea3d73940a573523fd498181b6e.tar.gz rust-3e9d7e8aa8b73ea3d73940a573523fd498181b6e.zip | |
Add a comment explaining the two checks
| -rw-r--r-- | src/librustc_mir/interpret/validity.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 982f3dab108..9d86e737dd5 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -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(()); |
