@@ -594,9 +594,9 @@ and translate_array (env: env) is_toplevel (init: Ast.expr): env * MiniRust.expr
594594and translate_expr_with_type (env : env ) (e : Ast.expr ) (t_ret : MiniRust.typ ): env * MiniRust.expr =
595595 (* KPrint.bprintf "translate_expr_with_type: %a @@ %a\n" PrintMiniRust.ptyp t_ret PrintAst.Ops.pexpr e; *)
596596
597- let erase_lifetime_info = (object (self )
597+ let erase_lifetime_and_borrow_kind_info = (object (self )
598598 inherit [_] MiniRust.DeBruijn. map
599- method! visit_Ref env _ bk t = Ref (None , bk , self#visit_typ env t)
599+ method! visit_Ref env _ _ t = Ref (None , Shared , self#visit_typ env t)
600600 method! visit_tname _ n _ = Name (n, [] )
601601 end )#visit_typ ()
602602 in
@@ -662,8 +662,11 @@ and translate_expr_with_type (env: env) (e: Ast.expr) (t_ret: MiniRust.typ): env
662662 (* If we reach this case, we perform one last try by erasing the lifetime
663663 information in both terms. This is useful to handle, e.g., implicit lifetime
664664 annotations or annotations up to alpha-conversion.
665- Note, this is sound as lifetime mismatches will be caught by the Rust compiler *)
666- if erase_lifetime_info t = erase_lifetime_info t_ret then
665+ Note, this is sound as lifetime mismatches will be caught by the Rust compiler.
666+ We similarly erase borrow kind information, which should only mismatch when relying
667+ on external, assumed declarations: these will be handled during mutability inference,
668+ and also rechecked by the Rust compiler. *)
669+ if erase_lifetime_and_borrow_kind_info t = erase_lifetime_and_borrow_kind_info t_ret then
667670 x
668671 else
669672 Warn. failwith " type mismatch;\n e=%a\n t=%a (verbose: %s)\n t_ret=%a\n x=%a"
0 commit comments