summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorJakob Degen <jakob.e.degen@gmail.com>2022-04-13 05:42:28 -0400
committerJakob Degen <jakob.e.degen@gmail.com>2022-04-13 05:51:08 -0400
commitd5f3863204b655ad4498f08c3a02dc320b7b6ea1 (patch)
treeb14e6f31c75ce2885be1b91cd437bbede9b3a012 /compiler/rustc_const_eval/src
parentb768f248e99688a2d7649731a99b2f2ad962abf5 (diff)
downloadrust-d5f3863204b655ad4498f08c3a02dc320b7b6ea1.tar.gz
rust-d5f3863204b655ad4498f08c3a02dc320b7b6ea1.zip
Consider lifetimes when comparing types for equality in MIR validator
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/transform/validate.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs
index 01af9585135..79d427ccc44 100644
--- a/compiler/rustc_const_eval/src/transform/validate.rs
+++ b/compiler/rustc_const_eval/src/transform/validate.rs
@@ -315,9 +315,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
                                     | ty::FnPtr(..)
                             )
                         }
-                        // None of the possible types have lifetimes, so we can just compare
-                        // directly
-                        if a != b {
+                        // The function pointer types can have lifetimes
+                        if !self.mir_assign_valid_types(a, b) {
                             self.fail(
                                 location,
                                 format!("Cannot compare unequal types {:?} and {:?}", a, b),
@@ -464,7 +463,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
                 };
                 // since CopyNonOverlapping is parametrized by 1 type,
                 // we only need to check that they are equal and not keep an extra parameter.
-                if op_src_ty != op_dst_ty {
+                if !self.mir_assign_valid_types(op_src_ty, op_dst_ty) {
                     self.fail(location, format!("bad arg ({:?} != {:?})", op_src_ty, op_dst_ty));
                 }