Skip to content

Commit d4fbd08

Browse files
committed
fmt
1 parent cee85b7 commit d4fbd08

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

crates/lean_compiler/src/analysis/ssa.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! SSA (Static Single Assignment) analysis utilities.
22
3-
use crate::lang::{Line, Expression, Boolean, Var};
43
use super::visitors::{Visitor, VisitorResult};
4+
use crate::lang::{Boolean, Expression, Line, Var};
55
use std::collections::{HashMap, HashSet};
66

77
/// Tracks variable assignments to detect SSA violations
@@ -131,7 +131,12 @@ impl ReturnContextCollector {
131131
collector.contexts
132132
}
133133

134-
fn collect_recursive(&mut self, lines: &[Line], return_vars: &[Var], current_conditions: Vec<Boolean>) {
134+
fn collect_recursive(
135+
&mut self,
136+
lines: &[Line],
137+
return_vars: &[Var],
138+
current_conditions: Vec<Boolean>,
139+
) {
135140
for line in lines {
136141
match line {
137142
Line::Assignment { var, value } if return_vars.contains(var) => {
@@ -141,7 +146,11 @@ impl ReturnContextCollector {
141146
};
142147
self.contexts.push(context);
143148
}
144-
Line::IfCondition { condition, then_branch, else_branch } => {
149+
Line::IfCondition {
150+
condition,
151+
then_branch,
152+
else_branch,
153+
} => {
145154
// Collect from then branch with added condition
146155
let mut then_conditions = current_conditions.clone();
147156
then_conditions.push(condition.clone());
@@ -234,7 +243,7 @@ pub fn create_ssa_repair_strategy(contexts: &[ReturnContext]) -> Vec<Line> {
234243
#[cfg(test)]
235244
mod tests {
236245
use super::*;
237-
use crate::lang::{SimpleExpr, ConstExpression};
246+
use crate::lang::{ConstExpression, SimpleExpr};
238247

239248
#[test]
240249
fn test_ssa_analyzer_no_violations() {
@@ -273,12 +282,10 @@ mod tests {
273282

274283
#[test]
275284
fn test_return_context_collection() {
276-
let lines = vec![
277-
Line::Assignment {
278-
var: "result".to_string(),
279-
value: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(42))),
280-
},
281-
];
285+
let lines = vec![Line::Assignment {
286+
var: "result".to_string(),
287+
value: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(42))),
288+
}];
282289

283290
let return_vars = vec!["result".to_string()];
284291
let contexts = ReturnContextCollector::collect_from(&lines, &return_vars);
@@ -296,12 +303,10 @@ mod tests {
296303
left: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
297304
right: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(1))),
298305
},
299-
then_branch: vec![
300-
Line::Assignment {
301-
var: "result".to_string(),
302-
value: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(100))),
303-
}
304-
],
306+
then_branch: vec![Line::Assignment {
307+
var: "result".to_string(),
308+
value: Expression::Value(SimpleExpr::Constant(ConstExpression::scalar(100))),
309+
}],
305310
else_branch: vec![],
306311
},
307312
Line::Assignment {
@@ -313,4 +318,4 @@ mod tests {
313318
let return_vars = vec!["result".to_string()];
314319
assert!(detect_return_ssa_violations(&lines, &return_vars));
315320
}
316-
}
321+
}

crates/lean_compiler/src/codegen/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ impl Compiler {
8181
#[cfg(test)]
8282
mod tests {
8383
use super::*;
84-
use crate::lang::SimpleExpr;
8584
use crate::ir::{SimpleFunction, SimpleLine, VarOrConstMallocAccess};
85+
use crate::lang::SimpleExpr;
8686

8787
#[test]
8888
fn test_compiler_creation() {

crates/lean_compiler/src/codegen/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub fn compile_function(
4545
#[cfg(test)]
4646
mod tests {
4747
use super::*;
48-
use crate::lang::SimpleExpr;
4948
use crate::ir::VarOrConstMallocAccess;
49+
use crate::lang::SimpleExpr;
5050

5151
#[test]
5252
fn test_compile_simple_function() {

crates/lean_compiler/src/codegen/memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{lang::*, ir::*};
1+
use crate::{ir::*, lang::*};
22
use std::collections::BTreeSet;
33

44
/// Finds all internal variables declared within a set of instructions.
@@ -59,8 +59,8 @@ pub fn find_internal_vars(lines: &[SimpleLine]) -> BTreeSet<Var> {
5959
mod tests {
6060
use super::*;
6161
use crate::ir::HighLevelOperation;
62-
use crate::lang::{ConstExpression, SimpleExpr};
6362
use crate::ir::VarOrConstMallocAccess;
63+
use crate::lang::{ConstExpression, SimpleExpr};
6464

6565
#[test]
6666
fn test_find_internal_vars_empty() {

crates/lean_compiler/src/ir/conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,8 @@ fn create_recursive_function(
764764
#[cfg(test)]
765765
mod tests {
766766
use super::*;
767-
use crate::{ir::HighLevelOperation, lang::*};
768767
use crate::ir::types::*;
768+
use crate::{ir::HighLevelOperation, lang::*};
769769

770770
fn create_test_counters() -> Counters {
771771
Counters::default()

crates/lean_compiler/src/ir/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ pub use value::{IntermediaryMemOrFpOrConstant, IntermediateValue};
1717

1818
// High-level IR exports (AST to IR)
1919
pub use types::{
20-
ArrayManager,
21-
ConstMalloc,
22-
Counters,
23-
SimpleFunction,
24-
SimpleLine,
25-
SimpleProgram,
20+
ArrayManager, ConstMalloc, Counters, SimpleFunction, SimpleLine, SimpleProgram,
2621
VarOrConstMallocAccess,
2722
};
2823

crates/lean_compiler/src/ir/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ impl Display for IntermediaryMemOrFpOrConstant {
140140
#[cfg(test)]
141141
mod tests {
142142
use super::*;
143-
use crate::lang::{ConstExpression, SimpleExpr};
144143
use crate::ir::VarOrConstMallocAccess;
144+
use crate::lang::{ConstExpression, SimpleExpr};
145145
use lean_vm::Label;
146146

147147
#[test]

0 commit comments

Comments
 (0)