Use std::fmt::from_fn by coolreader18 · Pull Request #6850 · RustPython/RustPython
📝 Walkthrough
Walkthrough
Rust version bumped to 1.93.0 in Cargo.toml. Two codebases refactored to use fmt::from_fn instead of custom display wrappers, removing lifetime parameters in method signatures. A new helper function added to resolve hard dependencies in the update library script.
Changes
| Cohort / File(s) | Summary |
|---|---|
Rust Version Bump Cargo.toml |
Updated workspace.package rust-version from "1.91.0" to "1.93.0" |
Display Refactoring crates/codegen/src/unparse.rs |
Replaced custom to_string_fmt helper with fmt::from_fn-based construction in unparse_formatted and unparse_fstring, removing the standalone helper function while preserving string-accumulation behavior |
Trait Method Simplification crates/compiler-core/src/bytecode/instruction.rs |
Simplified InstructionMetadata::display method signature by removing explicit lifetime parameters and internal wrapper type, now returning impl fmt::Display directly via fmt::from_fn; updated AnyInstruction implementation to match |
Dependency Resolution scripts/update_lib/deps.py |
Added new function resolve_hard_dep_parent(name: str) -> str | None to resolve hard dependency names to their parent module names |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- improve deps CI formatting and name resolution #6847: Both PRs add the same
resolve_hard_dep_parent()function toscripts/update_lib/deps.py fn unparse_expr->UnparseExpr::new#6121: Both PRs refactorcrates/codegen/src/unparse.rsto improve how Unparser construction is handled
Suggested reviewers
- youknowone
- moreal
Poem
🐰 With fmt::from_fn, we hop along,
Old wrappers gone, our code more strong,
Lifetimes released, and helpers freed,
Rust marches on to version's need,
A cleaner way, a brighter sight! ✨
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The pull request title 'Use std::fmt::from_fn' directly reflects the main change: refactoring code to use the standard library's std::fmt::from_fn introduced in Rust 1.93, replacing custom formatting helper types across multiple files. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
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.
Comment @coderabbitai help to get the list of available commands and usage tips.