Skip to content

Commit aa36232

Browse files
committed
fix: handle panic for unsupported operations and missing return type
1 parent 0c1e223 commit aa36232

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

source/rust_verify/src/rust_to_vir_expr.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,8 +3043,9 @@ fn binopkind_to_binaryop_inner<'tcx>(
30433043
BinOpKind::BitAnd => {
30443044
match ((tc.expr_ty_adjusted(lhs)).kind(), (tc.expr_ty_adjusted(rhs)).kind()) {
30453045
(TyKind::Bool, TyKind::Bool) => {
3046-
panic!(
3047-
"bitwise AND for bools (i.e., the not-short-circuited version) not supported"
3046+
unsupported_err!(
3047+
lhs.span,
3048+
"bitwise AND for bools (i.e., the not-short-circuited version)"
30483049
);
30493050
}
30503051
(TyKind::Int(_), TyKind::Int(_)) => {
@@ -3059,7 +3060,8 @@ fn binopkind_to_binaryop_inner<'tcx>(
30593060
BinOpKind::BitOr => {
30603061
match ((tc.expr_ty_adjusted(lhs)).kind(), (tc.expr_ty_adjusted(rhs)).kind()) {
30613062
(TyKind::Bool, TyKind::Bool) => {
3062-
panic!(
3063+
unsupported_err!(
3064+
lhs.span,
30633065
"bitwise OR for bools (i.e., the not-short-circuited version) not supported"
30643066
);
30653067
}

source/vir/src/modes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ fn check_expr_handle_mut_arg(
28882888
match (e1, typing.ret_mode) {
28892889
(None, _) => {}
28902890
(Some(v), None) if is_unit(&v.typ) => {}
2891-
(_, None) => panic!("internal error: missing return type"),
2891+
(_, None) => return Err(error(&expr.span, "missing return type")),
28922892
(Some(e1), Some(ret_mode)) => {
28932893
let proph = check_expr_has_mode(
28942894
ctxt,

0 commit comments

Comments
 (0)