Skip to content

Commit f794eeb

Browse files
committed
fmt
1 parent 1e586e9 commit f794eeb

3 files changed

Lines changed: 26 additions & 20 deletions

File tree

src/mast/mod.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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(

src/parser/expr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,9 @@ impl Expr {
529529
// sanity check
530530
if !matches!(
531531
self.kind,
532-
ExprKind::Variable { .. } | ExprKind::FieldAccess { .. } | ExprKind::ArrayAccess { .. }
532+
ExprKind::Variable { .. }
533+
| ExprKind::FieldAccess { .. }
534+
| ExprKind::ArrayAccess { .. }
533535
) {
534536
panic!("an array access can only follow a variable or another array access");
535537
}

src/parser/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl Symbolic {
228228
Symbolic::Sub(lhs, rhs) => {
229229
generics.extend(lhs.extract_generics());
230230
generics.extend(rhs.extract_generics());
231-
},
231+
}
232232
}
233233

234234
generics

0 commit comments

Comments
 (0)