diff --git a/src/backend/vm_exec.rs b/src/backend/vm_exec.rs index 9a372e4c..0147e6dd 100644 --- a/src/backend/vm_exec.rs +++ b/src/backend/vm_exec.rs @@ -11,11 +11,10 @@ * Behavior and public APIs are preserved. This is a pure move/refactor. */ -use crate::mir::{MirModule, MirFunction, MirInstruction, ValueId, BasicBlockId}; +use crate::mir::{MirModule, MirFunction, MirInstruction, BasicBlockId}; use crate::box_trait::NyashBox; use super::{vm::VM, vm::VMError, vm::VMValue}; use crate::backend::vm_control_flow::ControlFlow; -use std::sync::Arc; impl VM { /// Execute a MIR module diff --git a/src/backend/vm_gc.rs b/src/backend/vm_gc.rs index 9043dd7a..ea902f13 100644 --- a/src/backend/vm_gc.rs +++ b/src/backend/vm_gc.rs @@ -6,7 +6,7 @@ * - Debug prints for roots snapshot and shallow reachability */ -use super::vm::{VM, VMError, VMValue}; +use super::vm::{VM, VMValue}; impl VM { /// Enter a GC root region and return a guard that leaves on drop @@ -96,4 +96,3 @@ impl VM { eprintln!("[GC] depth2_children: total={} top5={:?}", child_count, top); } } - diff --git a/src/backend/vm_instructions/plugin_invoke.rs b/src/backend/vm_instructions/plugin_invoke.rs index 81281aa3..259aaa1e 100644 --- a/src/backend/vm_instructions/plugin_invoke.rs +++ b/src/backend/vm_instructions/plugin_invoke.rs @@ -1,5 +1,4 @@ use crate::mir::ValueId; -use std::sync::Arc; use crate::backend::vm::ControlFlow; use crate::backend::{VM, VMError, VMValue}; diff --git a/src/bin/ny_mir_builder.rs b/src/bin/ny_mir_builder.rs index 8e8c11d3..8701792c 100644 --- a/src/bin/ny_mir_builder.rs +++ b/src/bin/ny_mir_builder.rs @@ -1,6 +1,6 @@ -use clap::{Arg, ArgAction, Command, value_parser}; +use clap::{Arg, ArgAction, Command}; use std::fs::{self, File}; -use std::io::{self, Read, Write}; +use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::process::{Command as PCommand, Stdio}; @@ -117,11 +117,12 @@ fn current_dir_bin(name: &str) -> PathBuf { } } // Fallback to target/release - let mut cand = PathBuf::from("target/release").join(name); + let cand = PathBuf::from("target/release").join(name); if cand.exists() { return cand; } #[cfg(windows)] { - cand = PathBuf::from("target/release").join(format!("{}.exe", name)); + let cand = PathBuf::from("target/release").join(format!("{}.exe", name)); + return cand; } cand } diff --git a/src/jit/extern/result.rs b/src/jit/extern/result.rs index 0ed6b269..dd6eafce 100644 --- a/src/jit/extern/result.rs +++ b/src/jit/extern/result.rs @@ -1,5 +1,6 @@ //! Result-related JIT extern symbols +#[cfg(feature = "cranelift-jit")] use crate::box_trait::NyashBox; /// Symbol name for wrapping a handle into Result.Ok(handle) diff --git a/src/jit/lower/cfg_dot.rs b/src/jit/lower/cfg_dot.rs index cd96b64d..e80cbb95 100644 --- a/src/jit/lower/cfg_dot.rs +++ b/src/jit/lower/cfg_dot.rs @@ -1,5 +1,4 @@ pub fn dump_cfg_dot(func: &crate::mir::MirFunction, path: &str, phi_min: bool) -> std::io::Result<()> { - use std::io::Write; let mut out = String::new(); out.push_str(&format!("digraph \"{}\" {{\n", func.signature.name)); out.push_str(" node [shape=box, fontsize=10];\n"); diff --git a/src/jit/lower/core/ops_ext.rs b/src/jit/lower/core/ops_ext.rs index c5ff1e19..e044da5f 100644 --- a/src/jit/lower/core/ops_ext.rs +++ b/src/jit/lower/core/ops_ext.rs @@ -15,7 +15,7 @@ impl LowerCore { // Copied logic from core.rs PluginInvoke arm (scoped to PyRuntimeBox path) let bt = self.box_type_map.get(box_val).cloned().unwrap_or_default(); let m = method; - if (bt == "PyRuntimeBox" && (m == "import")) { + if bt == "PyRuntimeBox" && (m == "import") { let argc = 1 + args.len(); if let Some(pidx) = self.param_index.get(box_val).copied() { b.emit_param_i64(pidx); } else { self.push_value_if_known_or_param(b, box_val); } let decision = crate::jit::policy::invoke::decide_box_method(&bt, m, argc, dst.is_some()); @@ -24,7 +24,7 @@ impl LowerCore { crate::jit::observe::lower_plugin_invoke(&box_type, m, type_id, method_id, argc); if let Some(d) = dst { self.handle_values.insert(*d); } } else { if dst.is_some() { b.emit_const_i64(0); } } - } else if (bt == "PyRuntimeBox" && (m == "getattr" || m == "call")) { + } else if bt == "PyRuntimeBox" && (m == "getattr" || m == "call") { let argc = 1 + args.len(); if let Some(pidx) = self.param_index.get(box_val).copied() { b.emit_param_i64(pidx); } else { b.emit_const_i64(-1); } for a in args.iter() { self.push_value_if_known_or_param(b, a); } diff --git a/src/mir/optimizer.rs b/src/mir/optimizer.rs index 5bf4c41e..90f52c72 100644 --- a/src/mir/optimizer.rs +++ b/src/mir/optimizer.rs @@ -8,7 +8,7 @@ * - Dead code elimination */ -use super::{MirModule, MirFunction, MirInstruction, ValueId, MirType, TypeOpKind, EffectMask, Effect}; +use super::{MirModule, MirFunction, MirInstruction, ValueId, MirType, EffectMask, Effect}; use std::collections::{HashMap, HashSet}; /// MIR optimization passes @@ -464,7 +464,7 @@ impl MirOptimizer { /// Rewrites: PluginInvoke { box_val=py (PyRuntimeBox), method="getattr"|"call", args=[obj, rest...] } /// → PluginInvoke { box_val=obj, method, args=[rest...] } fn normalize_python_helper_calls(&mut self, module: &mut MirModule) -> OptimizationStats { - use super::{MirInstruction as I, MirType}; + use super::MirInstruction as I; let mut stats = OptimizationStats::new(); for (_fname, function) in &mut module.functions { for (_bb, block) in &mut function.blocks { @@ -914,7 +914,7 @@ impl MirOptimizer { #[cfg(test)] mod tests { use super::*; - use crate::mir::{MirModule, MirFunction, FunctionSignature, MirType, BasicBlock, BasicBlockId, ValueId, ConstValue}; + use crate::mir::{MirModule, MirFunction, FunctionSignature, MirType, TypeOpKind, BasicBlock, BasicBlockId, ValueId, ConstValue}; #[test] fn test_optimizer_creation() { diff --git a/src/runner/json_v0_bridge.rs b/src/runner/json_v0_bridge.rs index 7e8667ca..95e3af3b 100644 --- a/src/runner/json_v0_bridge.rs +++ b/src/runner/json_v0_bridge.rs @@ -597,7 +597,7 @@ fn lower_args(f: &mut MirFunction, cur_bb: BasicBlockId, args: &[ExprV0]) -> Res pub fn maybe_dump_mir(module: &MirModule) { if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") { - let mut p = MirPrinter::new(); + let p = MirPrinter::new(); println!("{}", p.print_module(module)); } } diff --git a/src/semantics/clif_adapter.rs b/src/semantics/clif_adapter.rs index cdb92708..8e89546b 100644 --- a/src/semantics/clif_adapter.rs +++ b/src/semantics/clif_adapter.rs @@ -1,5 +1,5 @@ use super::Semantics; -use crate::jit::lower::builder::{IRBuilder, BinOpKind, CmpKind, ParamKind}; +use crate::jit::lower::builder::{IRBuilder, BinOpKind, CmpKind}; use crate::mir::{ValueId, BasicBlockId}; /// Adapter that translates Semantics operations into IRBuilder calls (Cranelift path) @@ -53,4 +53,3 @@ impl<'a> Semantics for ClifSemanticsAdapter<'a> { fn barrier_write(&mut self, _ptr: &Self::Ptr, v: Self::Val) -> Self::Val { v } fn safepoint(&mut self) { /* Lowered via explicit hostcall in LowerCore path */ } } -