diff options
| author | ouz-a <oguz.agcayazi@gmail.com> | 2021-12-14 00:15:50 +0300 |
|---|---|---|
| committer | ouz-a <oguz.agcayazi@gmail.com> | 2021-12-14 00:15:50 +0300 |
| commit | b6c80985bd5c63ebf5f720450c4208fabc20af73 (patch) | |
| tree | 05ff079ebd2fec702bea358c0704abd40d9c814b | |
| parent | a01b13dede8f4197520ac136d87a831ddfadc9c4 (diff) | |
| download | rust-b6c80985bd5c63ebf5f720450c4208fabc20af73.tar.gz rust-b6c80985bd5c63ebf5f720450c4208fabc20af73.zip | |
Add regression test and comment
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operator.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/binop/binary-op-on-fn-ptr-eq.rs | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs index 58a51b15faa..3b8b65a50d2 100644 --- a/compiler/rustc_const_eval/src/interpret/operator.rs +++ b/compiler/rustc_const_eval/src/interpret/operator.rs @@ -328,7 +328,8 @@ 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`). + // (This is workaround for the issue #91636) assert!( right.layout.ty.is_any_ptr() || right.layout.ty.is_integral(), "Unexpected types for BinOp: {:?} {:?} {:?}", diff --git a/src/test/ui/binop/binary-op-on-fn-ptr-eq.rs b/src/test/ui/binop/binary-op-on-fn-ptr-eq.rs new file mode 100644 index 00000000000..188a27a1dcd --- /dev/null +++ b/src/test/ui/binop/binary-op-on-fn-ptr-eq.rs @@ -0,0 +1,8 @@ +// Tests equality between supertype and subtype of a function +// See the issue #91636 +fn foo(_a: &str) {} + +fn main() { + let x = foo as fn(&'static str); + let _ = x == foo; +} |
