Skip to content

Commit 0df40a1

Browse files
committed
fix(ci): cargo fmt drift in async_to_generator.rs (v0.5.857)
v0.5.855's #691 Phase 3 changes left ~13 fmt drifts in crates/perry-transform/src/async_to_generator.rs that the lint job caught on v0.5.856. Pure formatting.
1 parent 393c973 commit 0df40a1

3 files changed

Lines changed: 50 additions & 20 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88

99
Perry is a native TypeScript compiler written in Rust that compiles TypeScript source code directly to native executables. It uses SWC for TypeScript parsing and LLVM for code generation.
1010

11-
**Current Version:** 0.5.856
11+
**Current Version:** 0.5.857
1212

1313

1414
## TypeScript Parity Status

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ opt-level = "s" # Optimize for size in stdlib
188188
opt-level = 3
189189

190190
[workspace.package]
191-
version = "0.5.856"
191+
version = "0.5.857"
192192
edition = "2021"
193193
license = "MIT"
194194
repository = "https://github.com/PerryTS/perry"

crates/perry-transform/src/async_to_generator.rs

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,16 @@ fn strip_in_stmt(stmt: &mut Stmt, non_promise: &mut HashSet<LocalId>) {
874874
}
875875
Stmt::Expr(e) | Stmt::Throw(e) => strip_in_expr(e, non_promise),
876876
Stmt::Return(Some(e)) => strip_in_expr(e, non_promise),
877-
Stmt::Return(None) | Stmt::Break | Stmt::Continue
878-
| Stmt::LabeledBreak(_) | Stmt::LabeledContinue(_) => {}
879-
Stmt::If { condition, then_branch, else_branch } => {
877+
Stmt::Return(None)
878+
| Stmt::Break
879+
| Stmt::Continue
880+
| Stmt::LabeledBreak(_)
881+
| Stmt::LabeledContinue(_) => {}
882+
Stmt::If {
883+
condition,
884+
then_branch,
885+
else_branch,
886+
} => {
880887
strip_in_expr(condition, non_promise);
881888
strip_in_stmts(then_branch, non_promise);
882889
if let Some(eb) = else_branch {
@@ -887,7 +894,12 @@ fn strip_in_stmt(stmt: &mut Stmt, non_promise: &mut HashSet<LocalId>) {
887894
strip_in_expr(condition, non_promise);
888895
strip_in_stmts(body, non_promise);
889896
}
890-
Stmt::For { init, condition, update, body } => {
897+
Stmt::For {
898+
init,
899+
condition,
900+
update,
901+
body,
902+
} => {
891903
if let Some(init_stmt) = init {
892904
strip_in_stmt(init_stmt, non_promise);
893905
}
@@ -899,7 +911,11 @@ fn strip_in_stmt(stmt: &mut Stmt, non_promise: &mut HashSet<LocalId>) {
899911
}
900912
strip_in_stmts(body, non_promise);
901913
}
902-
Stmt::Try { body, catch, finally } => {
914+
Stmt::Try {
915+
body,
916+
catch,
917+
finally,
918+
} => {
903919
strip_in_stmts(body, non_promise);
904920
if let Some(c) = catch {
905921
strip_in_stmts(&mut c.body, non_promise);
@@ -909,7 +925,10 @@ fn strip_in_stmt(stmt: &mut Stmt, non_promise: &mut HashSet<LocalId>) {
909925
}
910926
}
911927
Stmt::Labeled { body, .. } => strip_in_stmt(body, non_promise),
912-
Stmt::Switch { discriminant, cases } => {
928+
Stmt::Switch {
929+
discriminant,
930+
cases,
931+
} => {
913932
strip_in_expr(discriminant, non_promise);
914933
for case in cases {
915934
if let Some(c) = &mut case.test {
@@ -939,11 +958,15 @@ fn strip_in_expr(expr: &mut Expr, non_promise: &HashSet<LocalId>) {
939958
}
940959

941960
fn try_strip_promise_resolve(expr: &Expr, non_promise: &HashSet<LocalId>) -> Option<Expr> {
942-
let Expr::Call { callee, args, .. } = expr else { return None; };
961+
let Expr::Call { callee, args, .. } = expr else {
962+
return None;
963+
};
943964
if args.len() != 1 {
944965
return None;
945966
}
946-
let Expr::PropertyGet { object, property } = callee.as_ref() else { return None; };
967+
let Expr::PropertyGet { object, property } = callee.as_ref() else {
968+
return None;
969+
};
947970
if property != "resolve" {
948971
return None;
949972
}
@@ -961,23 +984,24 @@ fn try_strip_promise_resolve(expr: &Expr, non_promise: &HashSet<LocalId>) -> Opt
961984

962985
fn is_non_promise_expr(expr: &Expr, non_promise: &HashSet<LocalId>) -> bool {
963986
match expr {
964-
Expr::Number(_) | Expr::Integer(_) | Expr::String(_) | Expr::Bool(_)
965-
| Expr::Undefined | Expr::Null => true,
987+
Expr::Number(_)
988+
| Expr::Integer(_)
989+
| Expr::String(_)
990+
| Expr::Bool(_)
991+
| Expr::Undefined
992+
| Expr::Null => true,
966993
Expr::LocalGet(id) => non_promise.contains(id),
967994
Expr::Binary { left, right, .. } => {
968-
is_non_promise_expr(left, non_promise)
969-
&& is_non_promise_expr(right, non_promise)
995+
is_non_promise_expr(left, non_promise) && is_non_promise_expr(right, non_promise)
970996
}
971997
Expr::Unary { operand, .. } => is_non_promise_expr(operand, non_promise),
972998
Expr::Compare { left, right, .. } => {
973-
is_non_promise_expr(left, non_promise)
974-
&& is_non_promise_expr(right, non_promise)
999+
is_non_promise_expr(left, non_promise) && is_non_promise_expr(right, non_promise)
9751000
}
9761001
Expr::Logical { left, right, .. } => {
9771002
// Logical && / || / ?? return one of the operands. If both are
9781003
// non-Promise, the result is non-Promise.
979-
is_non_promise_expr(left, non_promise)
980-
&& is_non_promise_expr(right, non_promise)
1004+
is_non_promise_expr(left, non_promise) && is_non_promise_expr(right, non_promise)
9811005
}
9821006
// `await X` for non-Promise X resolves to X itself (1 microtask hop),
9831007
// so the result is non-Promise. The peephole above handles the
@@ -989,8 +1013,14 @@ fn is_non_promise_expr(expr: &Expr, non_promise: &HashSet<LocalId>) -> bool {
9891013

9901014
fn is_non_promise_type(ty: &Type) -> bool {
9911015
match ty {
992-
Type::Number | Type::Int32 | Type::Boolean | Type::String
993-
| Type::Void | Type::Null | Type::BigInt | Type::Symbol => true,
1016+
Type::Number
1017+
| Type::Int32
1018+
| Type::Boolean
1019+
| Type::String
1020+
| Type::Void
1021+
| Type::Null
1022+
| Type::BigInt
1023+
| Type::Symbol => true,
9941024
Type::Promise(_) => false,
9951025
// Any/Unknown could carry a Promise at runtime.
9961026
// Object/Function could be a thenable. Named/Generic could resolve

0 commit comments

Comments
 (0)