Skip to content

Commit a601e76

Browse files
committed
Use ScalarInt from bool.
1 parent 0f9b789 commit a601e76

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use rustc_ast::InlineAsmOptions;
88
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
99
use rustc_data_structures::profiling::SelfProfilerRef;
1010
use rustc_index::IndexVec;
11+
use rustc_middle::ty::TypeVisitableExt;
1112
use rustc_middle::ty::adjustment::PointerCoercion;
1213
use rustc_middle::ty::layout::FnAbiOf;
1314
use rustc_middle::ty::print::with_no_trimmed_paths;
14-
use rustc_middle::ty::{ScalarInt, TypeVisitableExt};
1515
use rustc_session::config::OutputFilenames;
1616
use rustc_span::Symbol;
1717

@@ -1040,10 +1040,9 @@ pub(crate) fn codegen_operand<'tcx>(
10401040
}
10411041
Operand::Constant(const_) => crate::constant::codegen_constant_operand(fx, const_),
10421042
Operand::RuntimeChecks(checks) => {
1043-
let int = checks.value(fx.tcx.sess);
1044-
let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap();
1043+
let val = checks.value(fx.tcx.sess);
10451044
let layout = fx.layout_of(fx.tcx.types.bool);
1046-
return CValue::const_val(fx, layout, int);
1045+
return CValue::const_val(fx, layout, val.into());
10471046
}
10481047
}
10491048
}

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
540540
operand: &Operand<'tcx>,
541541
) -> Option<ScalarInt> {
542542
match operand {
543-
Operand::RuntimeChecks(checks) => {
544-
let int = checks.value(fx.tcx.sess);
545-
ScalarInt::try_from_uint(int, Size::from_bits(1))
546-
}
543+
Operand::RuntimeChecks(checks) => Some(checks.value(fx.tcx.sess).into()),
547544
Operand::Constant(const_) => eval_mir_constant(fx, const_).0.try_to_scalar_int(),
548545
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored
549546
// inside a temporary before being passed to the intrinsic requiring the const argument.

0 commit comments

Comments
 (0)