Skip to content

Commit 13ecc5a

Browse files
committed
fix: handle panic for unsupported operations and missing return type
1 parent d74707f commit 13ecc5a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::ast::{
77
};
88
use crate::ast_util::{get_field, is_unit, path_as_vstd_name, typ_to_diagnostic_str};
99
use crate::def::user_local_name;
10-
use crate::messages::{Span, error};
10+
use crate::messages::{Span, error, internal_error};
1111
use crate::messages::{error_bare, error_with_label};
1212
use crate::util::vec_map_result;
1313
use air::scope_map::ScopeMap;
@@ -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(internal_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)