◐ Shell
clean mode source ↗

Apply clippy suggestions to switch to let chains by coolreader18 · Pull Request #6126 · RustPython/RustPython

Walkthrough

Batches of nested if/if-let conditionals across the workspace were collapsed into single guarded conditionals using combined if-let/&& patterns; the workspace MSRV in Cargo.toml was bumped from 1.87.0 to 1.89.0. No public API or behavioral changes introduced.

Changes

Cohort / File(s) Summary
Workspace config
Cargo.toml
Bump [workspace.package].rust-version from "1.87.0" to "1.89.0".
Compiler
compiler/codegen/src/compile.rs, compiler/codegen/src/symboltable.rs
Flatten nested conditionals into combined if let ... && ... guards for qualname/mangling, rest-pattern validation, future-import detection, and type-parameter scope checks; semantics unchanged.
Derive & build scripts
derive-impl/src/compile_bytecode.rs, pylib/build.rs
Merge Windows-specific nested fallbacks into single guarded conditions; behavior unchanged.
JIT
jit/src/instructions.rs
Combine guards for jump/trap insertion based on current block state; refactor only.
WASM bridge
wasm/lib/src/convert.rs
Merge wasm-id and function-type guards; move arg/kwarg conversion into inner interp.enter VM context; internal refactor only.
Shell & VM new-syntax
src/shell.rs, vm/src/vm/vm_new.rs
Collapse unclosed triple-quote / incomplete-input detection into chained guards; behavior preserved.
Stdlib (multiple modules)
stdlib/src/* (e.g., contextvars.rs, math.rs, select.rs, socket.rs, syslog.rs, unicodedata.rs, zlib.rs, sqlite.rs, scproxy.rs, nt.rs, time.rs, warnings.rs, ...)
Replace nested checks with combined guards across caching, numeric fallbacks, timeout validation, address parsing, argv/syslog handling, Unicode name lookup, zlib dict handling, sqlite callback truthiness, proxy construction, time.sleep error handling, warnings import/call, etc.; no API changes.
VM builtins & stdlib glue (many files)
vm/src/* (e.g., builtins/*.rs, byte.rs, cformat.rs, exceptions.rs, object/core.rs, protocol/*.rs, readline.rs, signal.rs, vm/context.rs, vm/method.rs, vm/mod.rs, vm/vm_ops.rs, stdlib/*)
Consolidated nested ifs into single guarded conditionals for descriptors, iterators, default handling, mapping/method resolution, int-cache lookup, importlib init, op dispatch, exception tuple processing, weakref, history path creation, signal invocation, and related utilities; semantics preserved.
Common & platform-specific
common/src/fileutils.rs, vm/src/windows.rs
Consolidate nested checks for executable extension handling and raw OS error matching; behavior unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor JS as JavaScript
  participant W as wasm glue
  participant VM as RustPython VM
  participant IP as InnerInterperter

  JS->>W: invoke wrapped function (JsValue args/kwargs)
  W->>VM: stored_vm_from_wasm(wasm_id)
  alt VM found
    VM->>IP: interp.enter(...)
    Note over IP: Args/kwargs conversion now runs inside inner VM context
    IP->>IP: convert args/kwargs -> PyObjectRef
    IP->>IP: call Python function
    IP-->>W: return PyObjectRef / error
    W->>VM: try Promise bridge (if Promise type && downcast OK)
    alt Promise
      W-->>JS: return Promise
    else
      W-->>JS: return converted result
    end
  else VM missing
    W-->>JS: return Err(JsValue)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • youknowone
  • arihant2math

Poem

Hop hop, I tidy the ifs tonight,
Guarded chains make the logic light.
Rust asks for 1.89 to play,
I munched the nests and cleared the way.
A carrot cheer for builds gone right. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.