@@ -94,55 +94,28 @@ pub fn mk_fun_ctx<F: FunctionCommon>(
9494 mk_fun_ctx_dec ( f, checking_spec_preconditions, false )
9595}
9696
97- pub ( crate ) fn param_to_par ( param : & Param , allow_is_mut : bool ) -> Par {
97+ pub ( crate ) fn param_to_par ( param : & Param ) -> Par {
9898 param. map_x ( |p| {
99- let ParamX { name, typ, mode, is_mut, user_mut : _, unwrapped_info : _ } = p;
100- if * is_mut && !allow_is_mut {
101- panic ! ( "mut unexpected here" ) ;
102- }
103- ParX {
104- name : name. clone ( ) ,
105- typ : typ. clone ( ) ,
106- mode : * mode,
107- is_mut : * is_mut,
108- purpose : ParPurpose :: Regular ,
109- }
99+ let ParamX { name, typ, mode, user_mut : _, unwrapped_info : _ } = p;
100+ ParX { name : name. clone ( ) , typ : typ. clone ( ) , mode : * mode, purpose : ParPurpose :: Regular }
110101 } )
111102}
112103
113- pub ( crate ) fn params_to_pars ( params : & Params , allow_is_mut : bool ) -> Pars {
114- Arc :: new ( vec_map ( params, |p| param_to_par ( p, allow_is_mut ) ) )
104+ pub ( crate ) fn params_to_pars ( params : & Params ) -> Pars {
105+ Arc :: new ( vec_map ( params, |p| param_to_par ( p) ) )
115106}
116107
117- pub ( crate ) fn params_to_pre_post_pars ( params : & Params , pre : bool ) -> Pars {
108+ pub ( crate ) fn params_to_pre_post_pars ( params : & Params ) -> Pars {
118109 Arc :: new (
119110 params
120111 . iter ( )
121- . flat_map ( |param| {
122- let mut res = Vec :: new ( ) ;
123- if param. x . is_mut {
124- res. push ( param. map_x ( |p| ParX {
125- name : p. name . clone ( ) ,
126- typ : p. typ . clone ( ) ,
127- mode : p. mode ,
128- is_mut : p. is_mut ,
129- purpose : ParPurpose :: MutPre ,
130- } ) ) ;
131- }
132- if !( param. x . is_mut && pre) {
133- res. push ( param. map_x ( |p| ParX {
134- name : p. name . clone ( ) ,
135- typ : p. typ . clone ( ) ,
136- mode : p. mode ,
137- is_mut : p. is_mut ,
138- purpose : if param. x . is_mut {
139- ParPurpose :: MutPost
140- } else {
141- ParPurpose :: Regular
142- } ,
143- } ) ) ;
144- }
145- res
112+ . map ( |param| {
113+ param. map_x ( |p| ParX {
114+ name : p. name . clone ( ) ,
115+ typ : p. typ . clone ( ) ,
116+ mode : p. mode ,
117+ purpose : ParPurpose :: Regular ,
118+ } )
146119 } )
147120 . collect :: < Vec < _ > > ( ) ,
148121 )
@@ -155,7 +128,7 @@ fn func_body_to_sst(
155128 body : & Expr ,
156129 verifying_owning_bucket : bool ,
157130) -> Result < FuncSpecBodySst , VirErr > {
158- let pars = params_to_pars ( & function. x . params , false ) ;
131+ let pars = params_to_pars ( & function. x . params ) ;
159132
160133 // ast --> sst
161134 let mut state = State :: new ( diagnostics) ;
@@ -425,15 +398,14 @@ fn req_ens_to_sst(
425398 specs : & Vec < Expr > ,
426399 pre : bool ,
427400) -> Result < ( Pars , Vec < Exp > ) , VirErr > {
428- let mut pars = params_to_pre_post_pars ( & function. x . params , pre ) ;
401+ let mut pars = params_to_pre_post_pars ( & function. x . params ) ;
429402 let pars_mut = Arc :: make_mut ( & mut pars) ;
430403 if !pre && matches ! ( function. x. mode, Mode :: Exec | Mode :: Proof ) && function. x . ens_has_return {
431404 if !function. x . attrs . is_async {
432- pars_mut. push ( param_to_par ( & function. x . ret , false ) ) ;
405+ pars_mut. push ( param_to_par ( & function. x . ret ) ) ;
433406 } else {
434407 pars_mut. push ( param_to_par (
435408 & function. x . async_ret . as_ref ( ) . expect ( "Async function has no return type" ) ,
436- false ,
437409 ) ) ;
438410 }
439411 }
@@ -597,7 +569,7 @@ pub fn func_axioms_to_sst(
597569 assert ! ( function. x. ensure. 1 . len( ) == 0 ) ;
598570 let ens = crate :: ast_util:: conjoin ( span, & * function. x . ensure . 0 ) ;
599571 let req_ens = crate :: ast_util:: mk_implies ( span, & req, & ens) ;
600- let params = params_to_pre_post_pars ( & function. x . params , false ) ;
572+ let params = params_to_pre_post_pars ( & function. x . params ) ;
601573 // Use expr_to_bind_decls_exp_skip_checks, skipping checks on req_ens,
602574 // because the requires/ensures are checked when the function itself is checked
603575 let exp = expr_to_bind_decls_exp_skip_checks ( ctx, diagnostics, & params, & req_ens) ?;
@@ -864,15 +836,10 @@ pub fn func_def_to_sst(
864836 None
865837 } ;
866838 let ens_params = Arc :: new ( ens_params) ;
867- let ens_pars = params_to_pars ( & ens_params, true ) ;
839+ let ens_pars = params_to_pars ( & ens_params) ;
868840
869841 for param in function. x . params . iter ( ) {
870- state. declare_var_stm (
871- & param. x . name ,
872- & param. x . typ ,
873- if param. x . is_mut { PreLocalDeclKind :: MutParam } else { PreLocalDeclKind :: Param } ,
874- false ,
875- ) ;
842+ state. declare_var_stm ( & param. x . name , & param. x . typ , PreLocalDeclKind :: Param , false ) ;
876843 }
877844
878845 // When emitting an expression that refers to input variables, but which is embedded
@@ -881,9 +848,7 @@ pub fn func_def_to_sst(
881848 // Collect all such vars here.
882849 let mut params_to_use_pre = HashSet :: < VarIdent > :: new ( ) ;
883850 for param in function. x . params . iter ( ) {
884- if !param. x . is_mut {
885- params_to_use_pre. insert ( param. x . name . clone ( ) ) ;
886- }
851+ params_to_use_pre. insert ( param. x . name . clone ( ) ) ;
887852 }
888853 // We need to perform this translation on:
889854 // - Postcondition
@@ -1140,8 +1105,8 @@ pub fn function_to_sst(
11401105 opaqueness : function. x . opaqueness . clone ( ) ,
11411106 typ_params : function. x . typ_params . clone ( ) ,
11421107 typ_bounds : function. x . typ_bounds . clone ( ) ,
1143- pars : params_to_pars ( & function. x . params , true ) ,
1144- ret : param_to_par ( & function. x . ret , true ) ,
1108+ pars : params_to_pars ( & function. x . params ) ,
1109+ ret : param_to_par ( & function. x . ret ) ,
11451110 ens_has_return : function. x . ens_has_return ,
11461111 item_kind : function. x . item_kind ,
11471112 attrs : function. x . attrs . clone ( ) ,
@@ -1152,7 +1117,7 @@ pub fn function_to_sst(
11521117 recommends_check,
11531118 safe_api_check,
11541119 async_ret : match & function. x . async_ret {
1155- Some ( async_ret) => Some ( param_to_par ( async_ret, true ) ) ,
1120+ Some ( async_ret) => Some ( param_to_par ( async_ret) ) ,
11561121 None => None ,
11571122 } ,
11581123 } ;
0 commit comments