Skip to content

Commit df7f213

Browse files
style(rust): satisfy cargo fmt --check (fix red Build Check on main) (#84)
## Why The **`Build Check`** gate (`cargo fmt --check`, rustfmt 1.8.0-stable) is **red on `main`** — surfaced by CI on the unrelated docs PR #83, but the nonconformity is in Rust source neither PR's feature work touches. So it fails independently of any feature branch. ## What Pure `cargo fmt` reformat — **same tokens, no logic change** (verified: the diff is only line-wrapping of single-line block bodies and a long 3-pattern match arm): | File | Change | |---|---| | `src/ast/visitor.rs` | expand single-line block bodies (`for … { f(); }`) to multi-line | | `src/linter/mod.rs` | wrap the `ReceiveMessage \| AwaitWorker \| CancelWorker` arm | | `src/typechecker/mod.rs` | wrap the same 3-pattern arm | `cargo fmt --check` exits **0** after this change. ## Scope note Deliberately isolated from the bot-state surfacing in #83 (which stays docs-only). This PR is just the formatting rot on `main`, so `Build Check` goes green for everyone. https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7 --- _Generated by [Claude Code](https://claude.ai/code/session_013wg3Mtq2QFhYi4XVw1Z6z7)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 11ec276 commit df7f213

3 files changed

Lines changed: 76 additions & 32 deletions

File tree

src/ast/visitor.rs

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ use super::*;
77
/// Trait for visiting WokeLang AST nodes.
88
pub trait Visitor: Sized {
99
fn visit_program(&mut self, program: &Program) {
10-
for item in &program.items { self.visit_top_level_item(item); }
10+
for item in &program.items {
11+
self.visit_top_level_item(item);
12+
}
1113
}
1214
fn visit_top_level_item(&mut self, item: &TopLevelItem) {
1315
walk_top_level_item(self, item);
1416
}
15-
fn visit_statement(&mut self, stmt: &Statement) { walk_statement(self, stmt); }
16-
fn visit_expr(&mut self, expr: &Expr) { walk_expr(self, expr); }
17+
fn visit_statement(&mut self, stmt: &Statement) {
18+
walk_statement(self, stmt);
19+
}
20+
fn visit_expr(&mut self, expr: &Expr) {
21+
walk_expr(self, expr);
22+
}
1723
fn visit_pattern(&mut self, _pattern: &Pattern) {}
1824
fn visit_function_def(&mut self, func: &FunctionDef) {
1925
walk_function_def(self, func);
@@ -24,26 +30,35 @@ pub fn walk_top_level_item<V: Visitor>(v: &mut V, item: &TopLevelItem) {
2430
match item {
2531
TopLevelItem::Function(f) => v.visit_function_def(f),
2632
TopLevelItem::ConsentBlock(c) => {
27-
for stmt in &c.body { v.visit_statement(stmt); }
33+
for stmt in &c.body {
34+
v.visit_statement(stmt);
35+
}
2836
}
2937
TopLevelItem::GratitudeDecl(_) => {}
3038
TopLevelItem::WorkerDef(w) => {
31-
for stmt in &w.body { v.visit_statement(stmt); }
39+
for stmt in &w.body {
40+
v.visit_statement(stmt);
41+
}
3242
}
3343
TopLevelItem::SideQuestDef(s) => {
34-
for stmt in &s.body { v.visit_statement(stmt); }
44+
for stmt in &s.body {
45+
v.visit_statement(stmt);
46+
}
3547
}
3648
TopLevelItem::SuperpowerDecl(s) => {
37-
for stmt in &s.body { v.visit_statement(stmt); }
49+
for stmt in &s.body {
50+
v.visit_statement(stmt);
51+
}
3852
}
39-
TopLevelItem::ModuleImport(_) | TopLevelItem::Pragma(_)
40-
| TopLevelItem::TypeDef(_) => {}
53+
TopLevelItem::ModuleImport(_) | TopLevelItem::Pragma(_) | TopLevelItem::TypeDef(_) => {}
4154
TopLevelItem::ConstDef(c) => v.visit_expr(&c.value.node),
4255
}
4356
}
4457

4558
pub fn walk_function_def<V: Visitor>(v: &mut V, func: &FunctionDef) {
46-
for stmt in &func.body { v.visit_statement(stmt); }
59+
for stmt in &func.body {
60+
v.visit_statement(stmt);
61+
}
4762
}
4863

4964
pub fn walk_statement<V: Visitor>(v: &mut V, stmt: &Statement) {
@@ -53,37 +68,54 @@ pub fn walk_statement<V: Visitor>(v: &mut V, stmt: &Statement) {
5368
Statement::Return(r) => v.visit_expr(&r.value.node),
5469
Statement::Conditional(c) => {
5570
v.visit_expr(&c.condition.node);
56-
for s in &c.then_branch { v.visit_statement(s); }
71+
for s in &c.then_branch {
72+
v.visit_statement(s);
73+
}
5774
if let Some(eb) = &c.else_branch {
58-
for s in eb { v.visit_statement(s); }
75+
for s in eb {
76+
v.visit_statement(s);
77+
}
5978
}
6079
}
6180
Statement::Loop(l) => {
6281
v.visit_expr(&l.count.node);
63-
for s in &l.body { v.visit_statement(s); }
82+
for s in &l.body {
83+
v.visit_statement(s);
84+
}
6485
}
6586
Statement::While(w) => {
6687
v.visit_expr(&w.condition.node);
67-
for s in &w.body { v.visit_statement(s); }
88+
for s in &w.body {
89+
v.visit_statement(s);
90+
}
6891
}
6992
Statement::AttemptBlock(a) => {
70-
for s in &a.body { v.visit_statement(s); }
93+
for s in &a.body {
94+
v.visit_statement(s);
95+
}
7196
}
7297
Statement::ConsentBlock(c) => {
73-
for s in &c.body { v.visit_statement(s); }
98+
for s in &c.body {
99+
v.visit_statement(s);
100+
}
74101
}
75102
Statement::Expression(e) => v.visit_expr(&e.node),
76103
Statement::SendMessage(s) => v.visit_expr(&s.message.node),
77-
Statement::WorkerSpawn(_) | Statement::ReceiveMessage(_)
78-
| Statement::AwaitWorker(_) | Statement::CancelWorker(_)
104+
Statement::WorkerSpawn(_)
105+
| Statement::ReceiveMessage(_)
106+
| Statement::AwaitWorker(_)
107+
| Statement::CancelWorker(_)
79108
| Statement::Complain(_)
80-
| Statement::Break(_) | Statement::Continue(_) => {}
109+
| Statement::Break(_)
110+
| Statement::Continue(_) => {}
81111
Statement::EmoteAnnotated(e) => v.visit_statement(&e.statement),
82112
Statement::Decide(d) => {
83113
v.visit_expr(&d.scrutinee.node);
84114
for arm in &d.arms {
85115
v.visit_pattern(&arm.pattern);
86-
for s in &arm.body { v.visit_statement(s); }
116+
for s in &arm.body {
117+
v.visit_statement(s);
118+
}
87119
}
88120
}
89121
}
@@ -98,15 +130,21 @@ pub fn walk_expr<V: Visitor>(v: &mut V, expr: &Expr) {
98130
}
99131
Expr::Unary(_, operand) => v.visit_expr(&operand.node),
100132
Expr::Call(_, args) => {
101-
for arg in args { v.visit_expr(&arg.node); }
133+
for arg in args {
134+
v.visit_expr(&arg.node);
135+
}
102136
}
103137
Expr::CallExpr(callee, args) => {
104138
v.visit_expr(&callee.node);
105-
for arg in args { v.visit_expr(&arg.node); }
139+
for arg in args {
140+
v.visit_expr(&arg.node);
141+
}
106142
}
107143
Expr::UnitMeasurement(inner, _) => v.visit_expr(&inner.node),
108144
Expr::Array(elems) => {
109-
for e in elems { v.visit_expr(&e.node); }
145+
for e in elems {
146+
v.visit_expr(&e.node);
147+
}
110148
}
111149
Expr::Index(arr, idx) => {
112150
v.visit_expr(&arr.node);
@@ -115,17 +153,19 @@ pub fn walk_expr<V: Visitor>(v: &mut V, expr: &Expr) {
115153
Expr::Okay(inner) | Expr::Oops(inner) | Expr::Unwrap(inner) => {
116154
v.visit_expr(&inner.node);
117155
}
118-
Expr::Lambda(lam) => {
119-
match &lam.body {
120-
LambdaBody::Expr(e) => v.visit_expr(&e.node),
121-
LambdaBody::Block(stmts) => {
122-
for s in stmts { v.visit_statement(s); }
156+
Expr::Lambda(lam) => match &lam.body {
157+
LambdaBody::Expr(e) => v.visit_expr(&e.node),
158+
LambdaBody::Block(stmts) => {
159+
for s in stmts {
160+
v.visit_statement(s);
123161
}
124162
}
125-
}
163+
},
126164
Expr::FieldAccess(obj, _) => v.visit_expr(&obj.node),
127165
Expr::RecordLiteral(_, fields) => {
128-
for (_, val) in fields { v.visit_expr(&val.node); }
166+
for (_, val) in fields {
167+
v.visit_expr(&val.node);
168+
}
129169
}
130170
}
131171
}

src/linter/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ impl Linter {
156156
}
157157
Statement::WorkerSpawn(_) => {}
158158
Statement::SendMessage(s) => self.lint_expr(&s.message),
159-
Statement::ReceiveMessage(_) | Statement::AwaitWorker(_) | Statement::CancelWorker(_) => {}
159+
Statement::ReceiveMessage(_)
160+
| Statement::AwaitWorker(_)
161+
| Statement::CancelWorker(_) => {}
160162
Statement::Complain(_) => {}
161163
Statement::EmoteAnnotated(emote) => {
162164
self.lint_statement(&emote.statement);

src/typechecker/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,9 @@ impl TypeChecker {
13571357
self.infer_expr(&s.message, sub)?;
13581358
Ok(sub.clone())
13591359
}
1360-
Statement::ReceiveMessage(_) | Statement::AwaitWorker(_) | Statement::CancelWorker(_) => {
1360+
Statement::ReceiveMessage(_)
1361+
| Statement::AwaitWorker(_)
1362+
| Statement::CancelWorker(_) => {
13611363
// TODO: Check worker/channel exists in scope
13621364
Ok(sub.clone())
13631365
}

0 commit comments

Comments
 (0)