Skip to content

Commit c65d3ce

Browse files
committed
Generalize unsize and unsize_into destinations
1 parent 6c0a912 commit c65d3ce

File tree

2 files changed

+5
-4
lines changed
  • compiler
    • rustc_const_eval/src/interpret
    • rustc_mir_transform/src

2 files changed

+5
-4
lines changed

compiler/rustc_const_eval/src/interpret/cast.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use super::{
1717
throw_ub_custom,
1818
};
1919
use crate::fluent_generated as fluent;
20+
use crate::interpret::Writeable;
2021

2122
impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
2223
pub fn cast(
@@ -358,7 +359,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
358359
fn unsize_into_ptr(
359360
&mut self,
360361
src: &OpTy<'tcx, M::Provenance>,
361-
dest: &PlaceTy<'tcx, M::Provenance>,
362+
dest: &impl Writeable<'tcx, M::Provenance>,
362363
// The pointee types
363364
source_ty: Ty<'tcx>,
364365
cast_ty: Ty<'tcx>,
@@ -455,7 +456,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
455456
&mut self,
456457
src: &OpTy<'tcx, M::Provenance>,
457458
cast_ty: TyAndLayout<'tcx>,
458-
dest: &PlaceTy<'tcx, M::Provenance>,
459+
dest: &impl Writeable<'tcx, M::Provenance>,
459460
) -> InterpResult<'tcx> {
460461
trace!("Unsizing {:?} of type {} into {}", *src, src.layout.ty, cast_ty.ty);
461462
match (src.layout.ty.kind(), cast_ty.ty.kind()) {
@@ -496,7 +497,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
496497
self.cur_span(),
497498
"unsize_into: invalid conversion: {:?} -> {:?}",
498499
src.layout,
499-
dest.layout
500+
dest.layout()
500501
)
501502
}
502503
}

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
579579
CastKind::PointerCoercion(ty::adjustment::PointerCoercion::Unsize, _) => {
580580
let src = self.evaluated[value].as_ref()?;
581581
let dest = self.ecx.allocate(ty, MemoryKind::Stack).discard_err()?;
582-
self.ecx.unsize_into(src, ty, &dest.clone().into()).discard_err()?;
582+
self.ecx.unsize_into(src, ty, &dest).discard_err()?;
583583
self.ecx
584584
.alloc_mark_immutable(dest.ptr().provenance.unwrap().alloc_id())
585585
.discard_err()?;

0 commit comments

Comments
 (0)