about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/base.rs
diff options
context:
space:
mode:
authorCelina G. Val <celinval@amazon.com>2025-01-15 13:54:04 -0800
committerCelina G. Val <celinval@amazon.com>2025-02-03 13:55:15 -0800
commit804cce47d96d7b30f3798b51a1377c6697011c54 (patch)
treefe9addffcc69d9d44739bb7ed5a046605c6f5e65 /compiler/rustc_codegen_cranelift/src/base.rs
parent6a6c6b891bb0350b3f16abd3e84ff12dbd1b4c5b (diff)
downloadrust-804cce47d96d7b30f3798b51a1377c6697011c54.tar.gz
rust-804cce47d96d7b30f3798b51a1377c6697011c54.zip
Refactor contract builtin macro + error handling
Instead of parsing the different components of a function signature,
eagerly look for either the `where` keyword or the function body.

- Also address feedback to use `From` instead of `TryFrom` in cranelift
  contract and ubcheck codegen.
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/base.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/src/base.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs
index de2ce1768fa..a2b9e5712e5 100644
--- a/compiler/rustc_codegen_cranelift/src/base.rs
+++ b/compiler/rustc_codegen_cranelift/src/base.rs
@@ -868,7 +868,7 @@ fn codegen_stmt<'tcx>(
                         NullOp::UbChecks => {
                             let val = fx.tcx.sess.ub_checks();
                             let val = CValue::by_val(
-                                fx.bcx.ins().iconst(types::I8, i64::try_from(val).unwrap()),
+                                fx.bcx.ins().iconst(types::I8, i64::from(val)),
                                 fx.layout_of(fx.tcx.types.bool),
                             );
                             lval.write_cvalue(fx, val);
@@ -877,7 +877,7 @@ fn codegen_stmt<'tcx>(
                         NullOp::ContractChecks => {
                             let val = fx.tcx.sess.contract_checks();
                             let val = CValue::by_val(
-                                fx.bcx.ins().iconst(types::I8, i64::try_from(val).unwrap()),
+                                fx.bcx.ins().iconst(types::I8, i64::from(val)),
                                 fx.layout_of(fx.tcx.types.bool),
                             );
                             lval.write_cvalue(fx, val);