Skip to content

Commit 9c64e90

Browse files
committed
chore(cleanup): remove unused imports from session extractions (v0.5.343)
cargo fix --bin perry --lib -p perry-hir -p perry-codegen --allow-dirty --release narrows `use` statements across 25 files. No behavior changes. Mostly imports added during the v0.5.329-v0.5.342 split work that turned out unused once the moved bodies inlined. Example: - expr_object.rs: anyhow!, FuncId, ArrayElement, BinaryOp, is_destructuring_pattern, infer_type_from_expr - lower_call/native.rs: Function, is_abort_controller_expr, lower_abort_controller_call, nanbox_string_inline - compile/resolve.rs: find_file_dep_in_package_json, find_node_modules, has_perry_native_module, is_ts_file, resolve_exports, resolve_package_entry, resolve_package_source_entry, resolve_with_extensions (still callable via super:: re-exports — just not used inside the resolve module itself). Workspace warning count: 321 → 255 (-66, -21%). Remaining 255 warnings are pre-existing categorical issues (63 unnecessary-unsafe-block in perry-runtime, 25 unreachable-pattern in the HIR/codegen lowerers, 23 unnecessary-transmute, etc.) — separate bugs not introduced by this session. Verified: - cargo build --release clean - cargo test --workspace 434/0/5 = baseline - gap tests 25/28; doc-tests 80/82 = baseline. Final session tally: 15 commits (v0.5.329→v0.5.343), all baselines green throughout, ~14,000 LOC reorganized into 19 focused sub-modules, the most-cited monolith (lower::lower_expr) shrunk by 91%, compile.rs by 60%, lower.rs by 44%, lower_call.rs by 33%.
1 parent 530a35c commit 9c64e90

28 files changed

Lines changed: 92 additions & 105 deletions

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

Cargo.lock

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

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

113113
[workspace.package]
114-
version = "0.5.342"
114+
version = "0.5.343"
115115
edition = "2021"
116116
license = "MIT"
117117
repository = "https://github.com/PerryTS/perry"

crates/perry-codegen/src/boxed_vars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn collect_nested_closure_boxed_vars_in_stmts(
130130
stmts: &[perry_hir::Stmt],
131131
out: &mut HashSet<u32>,
132132
) {
133-
use perry_hir::Stmt;
133+
134134
for s in stmts {
135135
collect_nested_closure_boxed_vars_in_stmt(s, out);
136136
}

crates/perry-codegen/src/collectors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ fn collect_closures_in_expr(
308308
// Helper closure that recurses into a sub-expression. We use a
309309
// local closure rather than a method so we can keep the same
310310
// recursion entry point.
311-
let mut walk = |sub: &Expr,
311+
let walk = |sub: &Expr,
312312
seen: &mut HashSet<perry_types::FuncId>,
313313
out: &mut Vec<(perry_types::FuncId, Expr)>| {
314314
collect_closures_in_expr(sub, seen, out);
@@ -831,7 +831,7 @@ pub(crate) fn collect_ref_ids_in_stmts(stmts: &[perry_hir::Stmt], out: &mut Hash
831831

832832
fn collect_ref_ids_in_expr(e: &perry_hir::Expr, out: &mut HashSet<u32>) {
833833
use perry_hir::{ArrayElement, CallArg, Expr};
834-
let mut walk = |sub: &Expr, out: &mut HashSet<u32>| {
834+
let walk = |sub: &Expr, out: &mut HashSet<u32>| {
835835
collect_ref_ids_in_expr(sub, out);
836836
};
837837
match e {
@@ -2036,7 +2036,7 @@ fn collect_localset_ids_in_expr_filtered(
20362036
clamp_fn_ids: &HashSet<u32>,
20372037
) {
20382038
use perry_hir::{ArrayElement, CallArg, Expr};
2039-
let mut walk = |sub: &Expr, out: &mut HashSet<u32>| {
2039+
let walk = |sub: &Expr, out: &mut HashSet<u32>| {
20402040
collect_localset_ids_in_expr_filtered(sub, out, filter, flat_const_ids, flat_row_alias_ids, clamp_fn_ids);
20412041
};
20422042
match e {
@@ -2632,7 +2632,7 @@ pub(crate) fn collect_non_escaping_news(
26322632
module_globals: &std::collections::HashMap<u32, String>,
26332633
classes: &std::collections::HashMap<String, &perry_hir::Class>,
26342634
) -> std::collections::HashMap<u32, String> {
2635-
use perry_hir::{Expr, Stmt};
2635+
26362636

26372637
// Pass 1: find candidates — Let bindings of New that aren't boxed/global.
26382638
let mut candidates: std::collections::HashMap<u32, String> = std::collections::HashMap::new();
@@ -3396,7 +3396,7 @@ fn check_escapes_in_expr(
33963396

33973397
/// Helper: does this expression contain `LocalGet(target_id)` anywhere?
33983398
fn expr_contains_local_get(e: &perry_hir::Expr, target_id: u32) -> bool {
3399-
use perry_hir::{ArrayElement, CallArg, Expr};
3399+
use perry_hir::Expr;
34003400
match e {
34013401
Expr::LocalGet(id) => *id == target_id,
34023402
Expr::Binary { left, right, .. }

crates/perry-codegen/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7975,7 +7975,7 @@ pub(crate) fn lower_expr(ctx: &mut FnCtx<'_>, expr: &Expr) -> Result<String> {
79757975

79767976
Expr::ChildProcessSpawnBackground { command, args, log_file, env_json } => {
79777977
let cmd_box = lower_expr(ctx, command)?;
7978-
let args_box = if let Some(a) = args {
7978+
let _args_box = if let Some(a) = args {
79797979
lower_expr(ctx, a)?
79807980
} else {
79817981
double_literal(0.0)

crates/perry-codegen/src/lower_call/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use anyhow::Result;
1717
use perry_hir::Expr;
1818

19-
use crate::expr::{lower_expr, nanbox_pointer_inline, nanbox_string_inline, unbox_to_i64, FnCtx};
19+
use crate::expr::{lower_expr, nanbox_pointer_inline, unbox_to_i64, FnCtx};
2020
use crate::nanbox::double_literal;
2121
use crate::types::{DOUBLE, I32, I64};
2222

crates/perry-codegen/src/lower_call/native.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717
use anyhow::{bail, Result};
1818
use perry_dispatch::{ArgKind as UiArgKind, ReturnKind as UiReturnKind};
1919
use perry_hir::Expr;
20-
use perry_types::Type as HirType;
2120

22-
use crate::expr::{lower_expr, nanbox_pointer_inline, nanbox_string_inline, unbox_to_i64, FnCtx};
21+
use crate::expr::{lower_expr, nanbox_pointer_inline, unbox_to_i64, FnCtx};
2322
use crate::nanbox::{double_literal, POINTER_MASK_I64};
24-
use crate::types::{DOUBLE, I32, I64};
23+
use crate::types::{DOUBLE, I64};
2524

2625
use super::{
2726
apply_inline_style, collect_closure_introduced_ids, extract_options_fields,
28-
find_outer_writes_stmt, get_raw_string_ptr, is_abort_controller_expr,
29-
lower_abort_controller_call, lower_fetch_native_method, lower_native_module_dispatch,
27+
find_outer_writes_stmt, get_raw_string_ptr, lower_fetch_native_method, lower_native_module_dispatch,
3028
lower_notification_schedule, lower_perry_ui_table_call, native_module_lookup,
3129
perry_i18n_table_lookup, perry_plugin_instance_method_lookup, perry_plugin_table_lookup,
3230
perry_system_table_lookup, perry_ui_instance_method_lookup, perry_ui_table_lookup,

crates/perry-hir/src/analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ pub(crate) fn collect_assigned_locals_expr(expr: &Expr, assigned: &mut Vec<Local
385385
assigned.push(*array_id); // These may reallocate the array
386386
collect_assigned_locals_expr(value, assigned);
387387
}
388-
Expr::ArrayPop(array_id) | Expr::ArrayShift(array_id) => {
388+
Expr::ArrayPop(_array_id) | Expr::ArrayShift(_array_id) => {
389389
// These modify the array but don't reallocate
390390
}
391391
Expr::ArrayIndexOf { array, value } | Expr::ArrayIncludes { array, value } => {

crates/perry-hir/src/lower.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4055,7 +4055,7 @@ fn lower_stmt(
40554055
ctxt: Default::default(),
40564056
};
40574057
let mutable = false;
4058-
let is_var = false;
4058+
let _is_var = false;
40594059
for decl in &fake_var.decls {
40604060
if let Some(init) = &decl.init {
40614061
match &decl.name {
@@ -6112,7 +6112,7 @@ fn try_lower_widget_decl(
61126112
let mut placeholder: Option<Vec<(String, WidgetPlaceholderValue)>> = None;
61136113
let mut family_param_name: Option<String> = None;
61146114
let mut app_group: Option<String> = None;
6115-
let mut reload_after_seconds: Option<u32> = None;
6115+
let reload_after_seconds: Option<u32> = None;
61166116

61176117
for prop in &config_obj.props {
61186118
let kv = match prop {

0 commit comments

Comments
 (0)