about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2024-06-22 12:11:14 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2024-06-22 20:27:08 -0700
commita76e1d9b09ece967c01aafd3f8419f579a7ac5ca (patch)
tree8484fe9b33b82da421a3d3bb7af61bc7626094ce /compiler/rustc_mir_transform/src
parent9140c9ad5b1279aecfebb6c64b18dbaf67150183 (diff)
downloadrust-a76e1d9b09ece967c01aafd3f8419f579a7ac5ca.tar.gz
rust-a76e1d9b09ece967c01aafd3f8419f579a7ac5ca.zip
Add a `pointee_metadata_ty_or_projection` helper
Diffstat (limited to 'compiler/rustc_mir_transform/src')
-rw-r--r--compiler/rustc_mir_transform/src/gvn.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs
index bfdefd5a7d6..23124523f17 100644
--- a/compiler/rustc_mir_transform/src/gvn.rs
+++ b/compiler/rustc_mir_transform/src/gvn.rs
@@ -987,23 +987,14 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
                     // `*const [T]` -> `*const T` which remove metadata.
                     // We run on potentially-generic MIR, though, so unlike codegen
                     // we can't always know exactly what the metadata are.
-                    // Thankfully, equality on `ptr_metadata_ty_or_tail` gives us
-                    // what we need: `Ok(meta_ty)` if the metadata is known, or
-                    // `Err(tail_ty)` if not. Matching metadata is ok, but if
-                    // that's not known, then matching tail types is also ok,
-                    // allowing things like `*mut (?A, ?T)` <-> `*mut (?B, ?T)`.
+                    // To allow things like `*mut (?A, ?T)` <-> `*mut (?B, ?T)`,
+                    // it's fine to get a projection as the type.
                     // FIXME: Would it be worth trying to normalize, rather than
-                    // passing the identity closure?  Or are the types in the
+                    // just accepting the projection?  Or are the types in the
                     // Cast realistically about as normalized as we can get anyway?
                     Value::Cast { kind: CastKind::PtrToPtr, value: inner, from, to }
-                        if from
-                            .builtin_deref(true)
-                            .unwrap()
-                            .ptr_metadata_ty_or_tail(self.tcx, |t| t)
-                            == to
-                                .builtin_deref(true)
-                                .unwrap()
-                                .ptr_metadata_ty_or_tail(self.tcx, |t| t) =>
+                        if from.pointee_metadata_ty_or_projection(self.tcx)
+                            == to.pointee_metadata_ty_or_projection(self.tcx) =>
                     {
                         arg_index = *inner;
                         was_updated = true;