Skip to content

Commit 569df1d

Browse files
committed
Inline CValue::pointer_from_data_and_meta
It only has a single use and doesn't need access to CValue internals.
1 parent 8bf1687 commit 569df1d

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

src/base.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,13 @@ fn codegen_stmt<'tcx>(
825825
};
826826
let data = codegen_operand(fx, data);
827827
let meta = codegen_operand(fx, meta);
828-
let ptr_val = CValue::pointer_from_data_and_meta(fx, data, meta, layout);
828+
assert!(data.layout().ty.is_unsafe_ptr());
829+
assert!(layout.ty.is_unsafe_ptr());
830+
let ptr_val = if meta.layout().is_zst() {
831+
data.cast_pointer_to(layout)
832+
} else {
833+
CValue::by_val_pair(data.load_scalar(fx), meta.load_scalar(fx), layout)
834+
};
829835
lval.write_cvalue(fx, ptr_val);
830836
}
831837
Rvalue::Aggregate(ref kind, ref operands) => {

src/value_and_place.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,6 @@ impl<'tcx> CValue<'tcx> {
9595
CValue(CValueInner::ByValPair(value, extra), layout)
9696
}
9797

98-
/// For `AggregateKind::RawPtr`, create a pointer from its parts.
99-
///
100-
/// Panics if the `layout` is not a raw pointer.
101-
pub(crate) fn pointer_from_data_and_meta(
102-
fx: &mut FunctionCx<'_, '_, 'tcx>,
103-
data: CValue<'tcx>,
104-
meta: CValue<'tcx>,
105-
layout: TyAndLayout<'tcx>,
106-
) -> CValue<'tcx> {
107-
assert!(data.layout().ty.is_unsafe_ptr());
108-
assert!(layout.ty.is_unsafe_ptr());
109-
if meta.layout().is_zst() {
110-
data.cast_pointer_to(layout)
111-
} else {
112-
CValue::by_val_pair(data.load_scalar(fx), meta.load_scalar(fx), layout)
113-
}
114-
}
115-
11698
pub(crate) fn layout(&self) -> TyAndLayout<'tcx> {
11799
self.1
118100
}

0 commit comments

Comments
 (0)