@@ -27,7 +27,7 @@ pub struct ExprMonoInfo {
2727 /// The generic types shouldn't be presented in this field.
2828 pub typ : Option < TyKind > ,
2929
30- /// Propagated constant value
30+ /// Propagated constant value
3131 /// - For BigUInt expression type, this corresponds the same inner value.
3232 /// - For constant field type, this corresponds the propagated constant value.
3333 /// The reason why we can't just fold all the constants to BigUInt expression node is because
@@ -39,7 +39,7 @@ pub struct ExprMonoInfo {
3939 /// var = var + var;
4040 /// }
4141 /// ```
42- /// If the `var` is folded to a BigUInt expression node,
42+ /// If the `var` is folded to a BigUInt expression node,
4343 /// it won't represent the expression node with the same intension at the synthesizer phase,
4444 /// as it lose the recursive nature of the expression node.
4545 pub constant : Option < u32 > ,
@@ -201,7 +201,8 @@ impl<B: Backend> MastCtx<B> {
201201 ) {
202202 self . tast
203203 . add_monomorphized_fn ( new_qualified. clone ( ) , fn_info) ;
204- self . functions_instantiated . insert ( new_qualified, old_qualified) ;
204+ self . functions_instantiated
205+ . insert ( new_qualified, old_qualified) ;
205206 }
206207
207208 pub fn add_monomorphized_method (
@@ -214,8 +215,10 @@ impl<B: Backend> MastCtx<B> {
214215 self . tast
215216 . add_monomorphized_method ( struct_qualified. clone ( ) , method_name, fn_info) ;
216217
217- self . methods_instantiated
218- . insert ( ( struct_qualified, method_name. to_string ( ) ) , old_method_name. to_string ( ) ) ;
218+ self . methods_instantiated . insert (
219+ ( struct_qualified, method_name. to_string ( ) ) ,
220+ old_method_name. to_string ( ) ,
221+ ) ;
219222 }
220223
221224 pub fn clear_generic_fns ( & mut self ) {
@@ -437,7 +440,7 @@ fn monomorphize_expr<B: Backend>(
437440
438441 // check if this function is already monomorphized
439442 if ctx. functions_instantiated . contains_key ( & old_qualified) {
440- // todo: cache the propagated constant from instantiated function,
443+ // todo: cache the propagated constant from instantiated function,
441444 // so it doesn't need to re-instantiate the function
442445 let mexpr = Expr {
443446 kind : ExprKind :: FnCall {
@@ -448,8 +451,7 @@ fn monomorphize_expr<B: Backend>(
448451 ..expr. clone ( )
449452 } ;
450453 ExprMonoInfo :: new ( mexpr, typ, None )
451- }
452- else {
454+ } else {
453455 let fn_name_mono = & fn_info_mono. sig ( ) . name ;
454456 let mexpr = Expr {
455457 kind : ExprKind :: FnCall {
@@ -459,10 +461,10 @@ fn monomorphize_expr<B: Backend>(
459461 } ,
460462 ..expr. clone ( )
461463 } ;
462-
464+
463465 let qualified = FullyQualified :: new ( module, & fn_name_mono. value ) ;
464466 ctx. add_monomorphized_fn ( old_qualified, qualified, fn_info_mono) ;
465-
467+
466468 ExprMonoInfo :: new ( mexpr, typ, None )
467469 }
468470 }
@@ -522,8 +524,11 @@ fn monomorphize_expr<B: Backend>(
522524 let ( fn_info_mono, typ) = instantiate_fn_call ( ctx, fn_info, & observed, expr. span ) ?;
523525
524526 // check if this function is already monomorphized
525- if ctx. methods_instantiated . contains_key ( & ( struct_qualified. clone ( ) , method_name. value . clone ( ) ) ) {
526- // todo: cache the propagated constant from instantiated method,
527+ if ctx
528+ . methods_instantiated
529+ . contains_key ( & ( struct_qualified. clone ( ) , method_name. value . clone ( ) ) )
530+ {
531+ // todo: cache the propagated constant from instantiated method,
527532 // so it doesn't need to re-instantiate the function
528533 let mexpr = Expr {
529534 kind : ExprKind :: MethodCall {
@@ -534,8 +539,7 @@ fn monomorphize_expr<B: Backend>(
534539 ..expr. clone ( )
535540 } ;
536541 ExprMonoInfo :: new ( mexpr, typ, None )
537- }
538- else {
542+ } else {
539543 let fn_name_mono = & fn_info_mono. sig ( ) . name ;
540544 let mexpr = Expr {
541545 kind : ExprKind :: MethodCall {
@@ -545,11 +549,11 @@ fn monomorphize_expr<B: Backend>(
545549 } ,
546550 ..expr. clone ( )
547551 } ;
548-
552+
549553 let fn_def = fn_info_mono. native ( ) ;
550554 ctx. tast
551555 . add_monomorphized_method ( struct_qualified, & fn_name_mono. value , fn_def) ;
552-
556+
553557 ExprMonoInfo :: new ( mexpr, typ, None )
554558 }
555559 }
@@ -636,7 +640,7 @@ fn monomorphize_expr<B: Backend>(
636640 ExprMonoInfo :: new ( mexpr, typ, None )
637641 }
638642 }
639- } ,
643+ }
640644 // not folding, but propagate the updated constant value
641645 ( _, _) if lhs_mono. constant . is_some ( ) && rhs_mono. constant . is_some ( ) => {
642646 let lhs = lhs_mono. constant . unwrap ( ) ;
@@ -660,7 +664,7 @@ fn monomorphize_expr<B: Backend>(
660664 ) ;
661665
662666 ExprMonoInfo :: new ( mexpr, typ, cst)
663- } ,
667+ }
664668 // keep as is
665669 _ => {
666670 let mexpr = expr. to_mast (
0 commit comments