66
77//! Fix ghost variables.
88
9- use super :: super :: polymorphic_vir:: ast;
10- use super :: super :: polymorphic_vir:: cfg;
9+ use super :: super :: polymorphic_vir:: { ast, cfg} ;
1110use fxhash:: FxHashSet ;
1211use std:: mem;
1312
@@ -18,9 +17,7 @@ use std::mem;
1817/// creating the encoding. Therefore, we fix this with an additional
1918/// pass that renames all variables declared inside package statements
2019/// so that they are unique.
21- pub fn fix_ghost_vars (
22- mut method : cfg:: CfgMethod
23- ) -> cfg:: CfgMethod {
20+ pub fn fix_ghost_vars ( mut method : cfg:: CfgMethod ) -> cfg:: CfgMethod {
2421 let mut fixer = GhostVarFixer {
2522 package_stmt_count : 0 ,
2623 vars : None ,
@@ -53,12 +50,12 @@ impl GhostVarFixer {
5350}
5451
5552impl ast:: ExprFolder for GhostVarFixer {
56- fn fold_local ( & mut self , ast:: Local { variable, position} : ast:: Local ) -> ast:: Expr {
53+ fn fold_local ( & mut self , ast:: Local { variable, position } : ast:: Local ) -> ast:: Expr {
5754 match self . vars {
5855 Some ( ref vars) if vars. contains ( & variable) => {
5956 ast:: Expr :: local_with_pos ( self . fix_name ( variable) , position)
6057 }
61- _ => ast:: Expr :: local_with_pos ( variable, position)
58+ _ => ast:: Expr :: local_with_pos ( variable, position) ,
6259 }
6360 }
6461}
@@ -68,11 +65,22 @@ impl ast::StmtFolder for GhostVarFixer {
6865 ast:: ExprFolder :: fold ( self , e)
6966 }
7067
71- fn fold_package_magic_wand ( & mut self , ast:: PackageMagicWand { magic_wand, package_stmts, label, variables, position} : ast:: PackageMagicWand )
72- -> ast:: Stmt {
68+ fn fold_package_magic_wand (
69+ & mut self ,
70+ ast:: PackageMagicWand {
71+ magic_wand,
72+ package_stmts,
73+ label,
74+ variables,
75+ position,
76+ } : ast:: PackageMagicWand ,
77+ ) -> ast:: Stmt {
7378 let magic_wand = self . fold_expr ( magic_wand) ;
7479 self . vars = Some ( variables. into_iter ( ) . collect ( ) ) ;
75- let package_stmts = package_stmts. into_iter ( ) . map ( |stmt| self . fold ( stmt) ) . collect ( ) ;
80+ let package_stmts = package_stmts
81+ . into_iter ( )
82+ . map ( |stmt| self . fold ( stmt) )
83+ . collect ( ) ;
7684 let unfixed_vars = self . vars . take ( ) . unwrap ( ) ;
7785 let variables = unfixed_vars
7886 . into_iter ( )
0 commit comments