Skip to content

Commit 30c48bc

Browse files
committed
Use Operand::constant() in a couple of places
Also reduce visibility of a function
1 parent 7988b8c commit 30c48bc

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fn pointer_for_allocation<'tcx>(
228228
crate::pointer::Pointer::new(global_ptr)
229229
}
230230

231-
pub(crate) fn data_id_for_alloc_id(
231+
fn data_id_for_alloc_id(
232232
cx: &mut ConstantCx,
233233
module: &mut dyn Module,
234234
alloc_id: AllocId,

src/intrinsics/llvm_x86.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,10 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>(
202202
};
203203
let x = codegen_operand(fx, &x.node);
204204
let y = codegen_operand(fx, &y.node);
205-
let kind = match &kind.node {
206-
Operand::Constant(const_) => crate::constant::eval_mir_constant(fx, const_).0,
207-
Operand::Copy(_) | Operand::Move(_) => unreachable!("{kind:?}"),
205+
let kind = if let Some(const_) = kind.node.constant() {
206+
crate::constant::eval_mir_constant(fx, const_).0
207+
} else {
208+
unreachable!("{kind:?}")
208209
};
209210

210211
let flt_cc = match kind

src/intrinsics/simd.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
205205
// Find a way to reuse `immediate_const_vector` from `codegen_ssa` instead.
206206
let indexes = {
207207
use rustc_middle::mir::interpret::*;
208-
let idx_const = match &idx.node {
209-
Operand::Constant(const_) => crate::constant::eval_mir_constant(fx, const_).0,
210-
Operand::Copy(_) | Operand::Move(_) => unreachable!("{idx:?}"),
208+
let idx_const = if let Some(const_) = idx.node.constant() {
209+
crate::constant::eval_mir_constant(fx, const_).0
210+
} else {
211+
unreachable!("{idx:?}")
211212
};
212213

213214
let idx_bytes = match idx_const {

0 commit comments

Comments
 (0)