Skip to content

Commit 2ebcd9c

Browse files
committed
fmt
1 parent 442f15e commit 2ebcd9c

File tree

20 files changed

+122
-93
lines changed

20 files changed

+122
-93
lines changed

crates/lean_compiler/src/analysis/control_flow.rs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,13 @@ mod tests {
158158

159159
#[test]
160160
fn test_control_flow_analyzer_simple() {
161-
let lines = vec![Line::FunctionRet(crate::lang::ast::statement::FunctionRet {
162-
return_data: vec![Expression::Value(SimpleExpr::Constant(
163-
ConstExpression::scalar(42),
164-
))],
165-
})];
161+
let lines = vec![Line::FunctionRet(
162+
crate::lang::ast::statement::FunctionRet {
163+
return_data: vec![Expression::Value(SimpleExpr::Constant(
164+
ConstExpression::scalar(42),
165+
))],
166+
},
167+
)];
166168

167169
let analysis = ControlFlowAnalyzer::analyze(&lines);
168170
assert!(analysis.has_returns);
@@ -172,18 +174,22 @@ mod tests {
172174

173175
#[test]
174176
fn test_control_flow_analyzer_nested() {
175-
let lines = vec![Line::IfCondition(crate::lang::ast::statement::IfCondition {
176-
condition: Boolean::Equal {
177-
left: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
178-
right: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
177+
let lines = vec![Line::IfCondition(
178+
crate::lang::ast::statement::IfCondition {
179+
condition: Boolean::Equal {
180+
left: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
181+
right: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
182+
},
183+
then_branch: vec![Line::FunctionRet(
184+
crate::lang::ast::statement::FunctionRet {
185+
return_data: vec![Expression::Value(SimpleExpr::Constant(
186+
ConstExpression::scalar(100),
187+
))],
188+
},
189+
)],
190+
else_branch: vec![],
179191
},
180-
then_branch: vec![Line::FunctionRet(crate::lang::ast::statement::FunctionRet {
181-
return_data: vec![Expression::Value(SimpleExpr::Constant(
182-
ConstExpression::scalar(100),
183-
))],
184-
})],
185-
else_branch: vec![],
186-
})];
192+
)];
187193

188194
let analysis = ControlFlowAnalyzer::analyze(&lines);
189195
assert!(analysis.has_returns);
@@ -199,11 +205,13 @@ mod tests {
199205
left: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
200206
right: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
201207
},
202-
then_branch: vec![Line::FunctionRet(crate::lang::ast::statement::FunctionRet {
203-
return_data: vec![Expression::Value(SimpleExpr::Constant(
204-
ConstExpression::scalar(100),
205-
))],
206-
})],
208+
then_branch: vec![Line::FunctionRet(
209+
crate::lang::ast::statement::FunctionRet {
210+
return_data: vec![Expression::Value(SimpleExpr::Constant(
211+
ConstExpression::scalar(100),
212+
))],
213+
},
214+
)],
207215
else_branch: vec![],
208216
}),
209217
Line::FunctionRet(crate::lang::ast::statement::FunctionRet {

crates/lean_compiler/src/lang/ast/statement/array_assign.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Array assignment statement implementation.
22
33
use crate::{
4-
lang::{expr::{Expression, SimpleExpr}},
4+
lang::expr::{Expression, SimpleExpr},
55
traits::IndentedDisplay,
66
};
77
use std::fmt::{Display, Formatter};
@@ -47,6 +47,9 @@ mod tests {
4747
index: Expression::scalar(5),
4848
value: Expression::scalar(42),
4949
};
50-
assert_eq!(array_assign.to_string_with_indent(2), " data[5] = 42");
50+
assert_eq!(
51+
array_assign.to_string_with_indent(2),
52+
" data[5] = 42"
53+
);
5154
}
52-
}
55+
}

crates/lean_compiler/src/lang/ast/statement/assert.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! Assert statement implementation.
22
3-
use crate::{
4-
lang::ast::types::Boolean,
5-
traits::IndentedDisplay,
6-
};
3+
use crate::{lang::ast::types::Boolean, traits::IndentedDisplay};
74
use std::fmt::{Display, Formatter};
85

96
/// Assert statement for runtime checks.
@@ -24,7 +21,10 @@ impl IndentedDisplay for Assert {}
2421
#[cfg(test)]
2522
mod tests {
2623
use super::*;
27-
use crate::lang::{ast::types::Boolean, expr::{Expression, SimpleExpr}};
24+
use crate::lang::{
25+
ast::types::Boolean,
26+
expr::{Expression, SimpleExpr},
27+
};
2828

2929
#[test]
3030
fn test_assert_display() {
@@ -47,4 +47,4 @@ mod tests {
4747
};
4848
assert_eq!(assert_stmt.to_string(), "assert 5 != 0");
4949
}
50-
}
50+
}

crates/lean_compiler/src/lang/ast/statement/assignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ mod tests {
4545
};
4646
assert_eq!(assignment.to_string_with_indent(1), " y = 10");
4747
}
48-
}
48+
}

crates/lean_compiler/src/lang/ast/statement/break_stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ mod tests {
3030
let break_stmt = Break;
3131
assert_eq!(break_stmt.to_string_with_indent(1), " break");
3232
}
33-
}
33+
}

crates/lean_compiler/src/lang/ast/statement/counter_hint.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! Counter hint statement implementation.
22
3-
use crate::{
4-
lang::values::Var,
5-
traits::IndentedDisplay,
6-
};
3+
use crate::{lang::values::Var, traits::IndentedDisplay};
74
use std::fmt::{Display, Formatter};
85

96
/// Counter value hint statement for loops.
@@ -38,6 +35,9 @@ mod tests {
3835
let hint = CounterHint {
3936
var: "loop_counter".to_string(),
4037
};
41-
assert_eq!(hint.to_string_with_indent(3), " loop_counter = counter_hint(loop_counter)");
38+
assert_eq!(
39+
hint.to_string_with_indent(3),
40+
" loop_counter = counter_hint(loop_counter)"
41+
);
4242
}
43-
}
43+
}

crates/lean_compiler/src/lang/ast/statement/decompose_bits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ mod tests {
6666
};
6767
assert_eq!(decompose.to_string(), "empty_bits = decompose_bits()");
6868
}
69-
}
69+
}

crates/lean_compiler/src/lang/ast/statement/for_loop.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pub struct ForLoop {
2525

2626
impl Display for ForLoop {
2727
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
28-
let body_str = self.body
28+
let body_str = self
29+
.body
2930
.iter()
3031
.map(|line| line.to_string_with_indent(1))
3132
.collect::<Vec<_>>()
@@ -46,7 +47,8 @@ impl Display for ForLoop {
4647
impl IndentedDisplay for ForLoop {
4748
fn to_string_with_indent(&self, indent: usize) -> String {
4849
let spaces = " ".repeat(indent);
49-
let body_str = self.body
50+
let body_str = self
51+
.body
5052
.iter()
5153
.map(|line| line.to_string_with_indent(indent + 1))
5254
.collect::<Vec<_>>()
@@ -63,4 +65,4 @@ impl IndentedDisplay for ForLoop {
6365
spaces
6466
)
6567
}
66-
}
68+
}

crates/lean_compiler/src/lang/ast/statement/function_call.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ pub struct FunctionCall {
1919

2020
impl Display for FunctionCall {
2121
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
22-
let args_str = self.args
22+
let args_str = self
23+
.args
2324
.iter()
2425
.map(|arg| format!("{arg}"))
2526
.collect::<Vec<_>>()
2627
.join(", ");
27-
let return_data_str = self.return_data
28+
let return_data_str = self
29+
.return_data
2830
.iter()
2931
.map(|var| var.to_string())
3032
.collect::<Vec<_>>()
@@ -74,4 +76,4 @@ mod tests {
7476
};
7577
assert_eq!(call.to_string(), "a, b = multi_fn()");
7678
}
77-
}
79+
}

crates/lean_compiler/src/lang/ast/statement/function_ret.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! Function return statement implementation.
22
3-
use crate::{
4-
lang::expr::Expression,
5-
traits::IndentedDisplay,
6-
};
3+
use crate::{lang::expr::Expression, traits::IndentedDisplay};
74
use std::fmt::{Display, Formatter};
85

96
/// Function return statement.
@@ -15,7 +12,8 @@ pub struct FunctionRet {
1512

1613
impl Display for FunctionRet {
1714
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
18-
let return_data_str = self.return_data
15+
let return_data_str = self
16+
.return_data
1917
.iter()
2018
.map(|arg| format!("{arg}"))
2119
.collect::<Vec<_>>()
@@ -54,4 +52,4 @@ mod tests {
5452
};
5553
assert_eq!(ret.to_string(), "return 42");
5654
}
57-
}
55+
}

0 commit comments

Comments
 (0)