@@ -14,7 +14,7 @@ use crate::chc;
1414use crate :: pretty:: PrettyDisplayExt as _;
1515use crate :: refine:: {
1616 self , Assumption , BasicBlockType , Env , PlaceType , PlaceTypeBuilder , PlaceTypeVar , TempVarIdx ,
17- TemplateTypeGenerator , UnrefinedTypeGenerator , Var ,
17+ TypeBuilder , Var ,
1818} ;
1919use crate :: rty:: {
2020 self , ClauseBuilderExt as _, ClauseScope as _, ShiftExistential as _, Subtyping as _,
@@ -222,9 +222,10 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
222222 let rty_args: IndexVec < _ , _ > = args
223223 . types ( )
224224 . map ( |ty| {
225- self . ctx
226- . build_template_ty_with_scope ( & self . env )
227- . refined_ty ( ty)
225+ TypeBuilder :: new ( self . tcx )
226+ . for_template ( & mut self . ctx )
227+ . with_scope ( & self . env )
228+ . build_refined ( ty)
228229 } )
229230 . collect ( ) ;
230231 for ( field_pty, mut variant_rty) in
@@ -237,7 +238,8 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
237238 self . ctx . extend_clauses ( cs) ;
238239 }
239240
240- let sort_args: Vec < _ > = rty_args. iter ( ) . map ( |rty| rty. ty . to_sort ( ) ) . collect ( ) ;
241+ let sort_args: Vec < _ > =
242+ rty_args. iter ( ) . map ( |rty| rty. ty . to_sort ( ) ) . collect ( ) ;
241243 let ty = rty:: EnumType :: new ( ty_sym. clone ( ) , rty_args) . into ( ) ;
242244
243245 let mut builder = PlaceTypeBuilder :: default ( ) ;
@@ -433,7 +435,10 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
433435 let func_ty = match func. const_fn_def ( ) {
434436 // TODO: move this to well-known defs?
435437 Some ( ( def_id, args) ) if self . is_box_new ( def_id) => {
436- let inner_ty = self . ctx . build_template_ty ( ) . ty ( args. type_at ( 0 ) ) . vacuous ( ) ;
438+ let inner_ty = TypeBuilder :: new ( self . tcx )
439+ . for_template ( & mut self . ctx )
440+ . build ( args. type_at ( 0 ) )
441+ . vacuous ( ) ;
437442 let param = rty:: RefinedType :: unrefined ( inner_ty. clone ( ) ) ;
438443 let ret_term =
439444 chc:: Term :: box_ ( chc:: Term :: var ( rty:: FunctionParamIdx :: from ( 0_usize ) ) ) ;
@@ -444,7 +449,7 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
444449 rty:: FunctionType :: new ( [ param] . into_iter ( ) . collect ( ) , ret) . into ( )
445450 }
446451 Some ( ( def_id, args) ) if self . is_mem_swap ( def_id) => {
447- let inner_ty = self . ctx . unrefined_ty ( args. type_at ( 0 ) ) . vacuous ( ) ;
452+ let inner_ty = TypeBuilder :: new ( self . tcx ) . build ( args. type_at ( 0 ) ) . vacuous ( ) ;
448453 let param1 =
449454 rty:: RefinedType :: unrefined ( rty:: PointerType :: mut_to ( inner_ty. clone ( ) ) . into ( ) ) ;
450455 let param2 =
@@ -531,7 +536,7 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
531536 }
532537
533538 fn add_prophecy_var ( & mut self , statement_index : usize , ty : mir_ty:: Ty < ' tcx > ) {
534- let ty = self . ctx . unrefined_ty ( ty) ;
539+ let ty = TypeBuilder :: new ( self . tcx ) . build ( ty) ;
535540 let temp_var = self . env . push_temp_var ( ty. vacuous ( ) ) ;
536541 self . prophecy_vars . insert ( statement_index, temp_var) ;
537542 tracing:: debug!( stmt_idx = %statement_index, temp_var = ?temp_var, "add_prophecy_var" ) ;
@@ -552,7 +557,7 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
552557 referent : mir:: Place < ' tcx > ,
553558 prophecy_ty : mir_ty:: Ty < ' tcx > ,
554559 ) -> rty:: RefinedType < Var > {
555- let prophecy_ty = self . ctx . unrefined_ty ( prophecy_ty) ;
560+ let prophecy_ty = TypeBuilder :: new ( self . tcx ) . build ( prophecy_ty) ;
556561 let prophecy = self . env . push_temp_var ( prophecy_ty. vacuous ( ) ) ;
557562 let place = self . elaborate_place_for_borrow ( & referent) ;
558563 self . env . borrow_place ( place, prophecy) . into ( )
@@ -664,10 +669,10 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
664669 }
665670
666671 let decl = self . local_decls [ destination] . clone ( ) ;
667- let rty = self
668- . ctx
669- . build_template_ty_with_scope ( & self . env )
670- . refined_ty ( decl. ty ) ;
672+ let rty = TypeBuilder :: new ( self . tcx )
673+ . for_template ( & mut self . ctx )
674+ . with_scope ( & self . env )
675+ . build_refined ( decl. ty ) ;
671676 self . type_call ( func. clone ( ) , args. clone ( ) . into_iter ( ) . map ( |a| a. node ) , & rty) ;
672677 self . bind_local ( destination, rty) ;
673678 }
@@ -738,9 +743,10 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
738743 #[ tracing:: instrument( skip( self ) ) ]
739744 fn ret_template ( & mut self ) -> rty:: RefinedType < Var > {
740745 let ret_ty = self . body . local_decls [ mir:: RETURN_PLACE ] . ty ;
741- self . ctx
742- . build_template_ty_with_scope ( & self . env )
743- . refined_ty ( ret_ty)
746+ TypeBuilder :: new ( self . tcx )
747+ . for_template ( & mut self . ctx )
748+ . with_scope ( & self . env )
749+ . build_refined ( ret_ty)
744750 }
745751
746752 // TODO: remove this
0 commit comments