diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-12-17 22:30:20 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2024-02-09 21:01:57 +0000 |
| commit | 304b4ad8b9899584c7b981dee3b72017ca101a3e (patch) | |
| tree | 983fb118e80024ec8c4ccd728ac79085798363bd /compiler/rustc_mir_transform/src | |
| parent | 1f544ca0cc3652aeca1d8dbe78d406533f691c1b (diff) | |
| download | rust-304b4ad8b9899584c7b981dee3b72017ca101a3e.tar.gz rust-304b4ad8b9899584c7b981dee3b72017ca101a3e.zip | |
Compute unsizing casts in GVN.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/gvn.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 3e8e454fcaa..0ef3cdbb337 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -551,6 +551,16 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } value.offset(Size::ZERO, to, &self.ecx).ok()? } + CastKind::PointerCoercion(ty::adjustment::PointerCoercion::Unsize) => { + let src = self.evaluated[value].as_ref()?; + let to = self.ecx.layout_of(to).ok()?; + let dest = self.ecx.allocate(to, MemoryKind::Stack).ok()?; + self.ecx.unsize_into(src, to, &dest.clone().into()).ok()?; + self.ecx + .alloc_mark_immutable(dest.ptr().provenance.unwrap().alloc_id()) + .ok()?; + dest.into() + } _ => return None, }, }; |
