about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-14 20:47:31 +0100
committerGitHub <noreply@github.com>2021-12-14 20:47:31 +0100
commitbae9270989cda75f891c3099383352daa5435404 (patch)
treecdb7b4ec54632ce835744a48de2a1a6608fd42e0 /compiler/rustc_const_eval/src
parent6a9491895f3aaa37f8b83c24ce01f97ff4716e45 (diff)
parenta5054e3858150384c30ce71afc76ca9c57c8cec2 (diff)
downloadrust-bae9270989cda75f891c3099383352daa5435404.tar.gz
rust-bae9270989cda75f891c3099383352daa5435404.zip
Rollup merge of #91856 - ouz-a:master, r=oli-obk
Looser check for overflowing_binary_op

Fix for issue #91636 tight check resulted in ICE, this makes the check a little looser. It seems `eq` allows comparing of `supertype` and `subtype` if `lhs = supertype` and `rhs = subtype` but not vice versa, is this intended behavior ?
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/interpret/operator.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs
index a90582fc338..48c90e1881a 100644
--- a/compiler/rustc_const_eval/src/interpret/operator.rs
+++ b/compiler/rustc_const_eval/src/interpret/operator.rs
@@ -328,9 +328,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                 self.binary_int_op(bin_op, l, left.layout, r, right.layout)
             }
             _ if left.layout.ty.is_any_ptr() => {
-                // The RHS type must be the same *or an integer type* (for `Offset`).
+                // The RHS type must be a `pointer` *or an integer type* (for `Offset`).
+                // (Even when both sides are pointers, their type might differ, see issue #91636)
                 assert!(
-                    right.layout.ty == left.layout.ty || right.layout.ty.is_integral(),
+                    right.layout.ty.is_any_ptr() || right.layout.ty.is_integral(),
                     "Unexpected types for BinOp: {:?} {:?} {:?}",
                     left.layout.ty,
                     bin_op,