Skip to content

Commit 3a14dbb

Browse files
committed
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.
1 parent fa43703 commit 3a14dbb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ fn codegen_stmt<'tcx>(
868868
NullOp::UbChecks => {
869869
let val = fx.tcx.sess.ub_checks();
870870
let val = CValue::by_val(
871-
fx.bcx.ins().iconst(types::I8, i64::try_from(val).unwrap()),
871+
fx.bcx.ins().iconst(types::I8, i64::from(val)),
872872
fx.layout_of(fx.tcx.types.bool),
873873
);
874874
lval.write_cvalue(fx, val);
@@ -877,7 +877,7 @@ fn codegen_stmt<'tcx>(
877877
NullOp::ContractChecks => {
878878
let val = fx.tcx.sess.contract_checks();
879879
let val = CValue::by_val(
880-
fx.bcx.ins().iconst(types::I8, i64::try_from(val).unwrap()),
880+
fx.bcx.ins().iconst(types::I8, i64::from(val)),
881881
fx.layout_of(fx.tcx.types.bool),
882882
);
883883
lval.write_cvalue(fx, val);

0 commit comments

Comments
 (0)