diff --git a/rust-toolchain b/rust-toolchain index bf66aeae18b..1fc08a92fe8 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-04-20" +channel = "nightly-2024-04-22" components = ["rust-src", "rustc-dev", "llvm-tools"] diff --git a/src/base.rs b/src/base.rs index 4892d46a572..4c53a9db7bd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -825,7 +825,7 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool { }; let data = codegen_operand(fx, data); let meta = codegen_operand(fx, meta); - let ptr_val = CValue::pointer_from_data_and_meta(data, meta, layout); + let ptr_val = CValue::pointer_from_data_and_meta(fx, data, meta, layout); lval.write_cvalue(fx, ptr_val); } Rvalue::Aggregate(ref kind, ref operands) => { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 38fedb6036c..eeae98ed04d 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -99,17 +99,18 @@ pub(crate) fn by_val_pair( /// /// Panics if the `layout` is not a raw pointer. pub(crate) fn pointer_from_data_and_meta( + fx: &mut FunctionCx<'_, '_, 'tcx>, data: CValue<'tcx>, meta: CValue<'tcx>, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { + assert!(data.layout().ty.is_unsafe_ptr()); assert!(layout.ty.is_unsafe_ptr()); - let inner = match (data.0, meta.0) { - (CValueInner::ByVal(p), CValueInner::ByVal(m)) => CValueInner::ByValPair(p, m), - (p @ CValueInner::ByVal(_), CValueInner::ByRef(..)) if meta.1.is_zst() => p, - _ => bug!("RawPtr operands {data:?} {meta:?}"), - }; - CValue(inner, layout) + if meta.layout().is_zst() { + data.cast_pointer_to(layout) + } else { + CValue::by_val_pair(data.load_scalar(fx), meta.load_scalar(fx), layout) + } } pub(crate) fn layout(&self) -> TyAndLayout<'tcx> {