Skip to content

Commit

Permalink
block mut params of &mut types
Browse files Browse the repository at this point in the history
  • Loading branch information
jcp19 committed Jul 22, 2023
1 parent b1de82e commit 45a8a6d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/rust_verify/src/rust_to_vir_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,14 @@ pub(crate) fn check_item_fn<'tcx>(
if mode == Mode::Spec {
return err_span(span, format!("mut argument not allowed for spec functions"));
}
if is_mut {
// REVIEW
// For all mut params, we introduce a new variable that shadows the original mut
// param and assign the value of the param to the new variable. This does not
// work properly when the type of the param is a mutable reference, because
// declaring and assigning to a variable of type `&mut T` is not implemented yet.
unsupported_err!(span, "mut parameters of &mut types")
}
vir_mut_params.push((vir_param.clone(), is_ref_mut.map(|(_, m)| m).flatten()));
let new_binding_pat = ctxt.spanned_typed_new(
span,
Expand All @@ -489,7 +497,6 @@ pub(crate) fn check_item_fn<'tcx>(
);
let new_init_expr =
ctxt.spanned_typed_new(span, &typ, vir::ast::ExprX::Var(name.clone()));
// TODO: doc
if let Some(hir_id) = hir_id {
ctxt.erasure_info.borrow_mut().hir_vir_ids.push((hir_id, new_binding_pat.span.id));
ctxt.erasure_info.borrow_mut().hir_vir_ids.push((hir_id, new_init_expr.span.id));
Expand Down

0 comments on commit 45a8a6d

Please sign in to comment.