From a601e768572a0e9753f40ad45c6d734c276d1043 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 14 Dec 2025 17:29:59 +0000 Subject: [PATCH] Use ScalarInt from bool. --- compiler/rustc_codegen_cranelift/src/base.rs | 7 +++---- compiler/rustc_codegen_cranelift/src/constant.rs | 5 +---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 79f65141e66f..1a916c876824 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -8,10 +8,10 @@ use rustc_ast::InlineAsmOptions; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_index::IndexVec; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::{ScalarInt, TypeVisitableExt}; use rustc_session::config::OutputFilenames; use rustc_span::Symbol; @@ -1040,10 +1040,9 @@ pub(crate) fn codegen_operand<'tcx>( } Operand::Constant(const_) => crate::constant::codegen_constant_operand(fx, const_), Operand::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); + let val = checks.value(fx.tcx.sess); let layout = fx.layout_of(fx.tcx.types.bool); - return CValue::const_val(fx, layout, int); + return CValue::const_val(fx, layout, val.into()); } } } diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index c25034d4be22..ff8e6744bd32 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -540,10 +540,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( operand: &Operand<'tcx>, ) -> Option { match operand { - Operand::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - ScalarInt::try_from_uint(int, Size::from_bits(1)) - } + Operand::RuntimeChecks(checks) => Some(checks.value(fx.tcx.sess).into()), Operand::Constant(const_) => eval_mir_constant(fx, const_).0.try_to_scalar_int(), // FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored // inside a temporary before being passed to the intrinsic requiring the const argument.