Use Self where possible#5892
Conversation
WalkthroughThis pull request performs a comprehensive, project-wide refactor to replace explicit type and enum variant references with the Rust Changes
Sequence Diagram(s)Omitted due to the purely stylistic nature of the changes. Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Clippy (1.86.0)error: failed to load source for dependency Caused by: Caused by: Caused by: ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
vm/src/builtins/type.rs (1)
436-439: Tiny nit: remove the superfluous explicit type in the closure.The closure
map(|cls| -> &Self { cls })explicitly annotates the return type, but type-inference already knows it’s&Self. Dropping the arrow clause makes the chain shorter.- .chain(self.mro.read().iter().map(|cls| -> &Self { cls })) + .chain(self.mro.read().iter().map(|cls| cls))vm/src/builtins/bytearray.rs (1)
650-673: Consider taking&selfinstead of consumingselfforlstrip/rstrip.These methods currently take ownership of the
PyRef, which forces callers to re-bind:ba = ba.lstrip(...)Using a shared reference would avoid that extra move/cloning cost:
- fn lstrip(self, chars: OptionalOption<PyBytesInner>, vm: &VirtualMachine) -> Self { + fn lstrip(&self, chars: OptionalOption<PyBytesInner>, vm: &VirtualMachine) -> Self {The same applies to
rstrip.vm/src/bytes_inner.rs (4)
345-350: Avoid passing large structs by value
needle: Either<Self, PyIntRef>moves a completeVec<u8>every call.
An API that takes references avoids this allocation and still keeps the caller ergonomics:- pub fn contains(&self, needle: Either<Self, PyIntRef>, vm: &VirtualMachine) -> PyResult<bool> { + pub fn contains( + &self, + needle: Either<&Self, &PyIntRef>, + vm: &VirtualMachine, + ) -> PyResult<bool> { Ok(match needle { - Either::A(byte) => self.elements.contains_str(byte.elements.as_slice()), - Either::B(int) => self.elements.contains(&int.as_bigint().byte_or(vm)?), + Either::A(byte) => self.elements.contains_str(byte.elements.as_slice()), + Either::B(int) => self.elements.contains(&int.as_bigint().byte_or(vm)?), }) }(Same idea applies to most of the other newly‐
Selfparameters below.)
570-585:maketransstill consumes two full buffers – worth revisitingThe method now reads
from: Self, to: Self; this already cloned the data before the PR, so it is not a new issue.
If you ever touch this again, consider&Selfto prevent an otherwise needless move.
758-801: Large replace helpers – unchanged semantics, but consider borrowingAll four helpers (
replace_interleave,replace_delete,replace_in_place,replace_general) now takeSelfby value, as before.
Given these are potentially large buffers, a future micro-optimisation could pass&Selfand clone only when needed, but that is outside the scope of this PR.Also applies to: 802-827, 831-872, 876-924
1022-1027: Potential ambiguity withSelf::new()/Self::with_capacity()Inside the
impl AnyStrContainer<[u8]> for Vec<u8>block,Self::new()andSelf::with_capacity()currently resolve to the inherent Vec methods, so there is no recursion.
However clippy can flag this as unclear. Using the fully-qualified inherent path avoids any doubt:- Self::new() + Vec::new() ... - Self::with_capacity(capacity) + Vec::with_capacity(capacity)Run
cargo clippy -- -W clippy::needless_return -W clippy::unnecessary_wraps(or the full clippy set) to ensure there is no warning about the ambiguous call resolution.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (107)
common/src/atomic.rs(1 hunks)common/src/boxvec.rs(3 hunks)common/src/cformat.rs(5 hunks)common/src/format.rs(17 hunks)common/src/linked_list.rs(2 hunks)common/src/lock/cell_lock.rs(3 hunks)common/src/lock/thread_mutex.rs(2 hunks)common/src/refcount.rs(1 hunks)common/src/str.rs(1 hunks)compiler/codegen/src/compile.rs(1 hunks)compiler/codegen/src/ir.rs(3 hunks)compiler/codegen/src/lib.rs(1 hunks)compiler/codegen/src/symboltable.rs(4 hunks)compiler/core/src/bytecode.rs(10 hunks)compiler/core/src/frozen.rs(3 hunks)compiler/core/src/mode.rs(1 hunks)compiler/src/lib.rs(2 hunks)derive-impl/src/compile_bytecode.rs(2 hunks)derive-impl/src/error.rs(2 hunks)derive-impl/src/from_args.rs(3 hunks)stdlib/src/array.rs(8 hunks)stdlib/src/bz2.rs(1 hunks)stdlib/src/contextvars.rs(3 hunks)stdlib/src/csv.rs(5 hunks)stdlib/src/hashlib.rs(7 hunks)stdlib/src/posixsubprocess.rs(2 hunks)stdlib/src/pyexpat.rs(1 hunks)stdlib/src/pystruct.rs(4 hunks)stdlib/src/resource.rs(1 hunks)stdlib/src/select.rs(4 hunks)stdlib/src/socket.rs(2 hunks)stdlib/src/syslog.rs(1 hunks)stdlib/src/unicodedata.rs(2 hunks)stdlib/src/zlib.rs(4 hunks)vm/src/buffer.rs(6 hunks)vm/src/builtins/asyncgenerator.rs(2 hunks)vm/src/builtins/bool.rs(1 hunks)vm/src/builtins/builtin_func.rs(1 hunks)vm/src/builtins/bytearray.rs(8 hunks)vm/src/builtins/bytes.rs(9 hunks)vm/src/builtins/classmethod.rs(1 hunks)vm/src/builtins/code.rs(3 hunks)vm/src/builtins/complex.rs(4 hunks)vm/src/builtins/coroutine.rs(1 hunks)vm/src/builtins/dict.rs(6 hunks)vm/src/builtins/enumerate.rs(1 hunks)vm/src/builtins/float.rs(3 hunks)vm/src/builtins/function.rs(5 hunks)vm/src/builtins/generator.rs(1 hunks)vm/src/builtins/genericalias.rs(3 hunks)vm/src/builtins/int.rs(8 hunks)vm/src/builtins/iter.rs(1 hunks)vm/src/builtins/list.rs(3 hunks)vm/src/builtins/map.rs(1 hunks)vm/src/builtins/mappingproxy.rs(1 hunks)vm/src/builtins/memory.rs(3 hunks)vm/src/builtins/module.rs(2 hunks)vm/src/builtins/object.rs(1 hunks)vm/src/builtins/property.rs(2 hunks)vm/src/builtins/range.rs(5 hunks)vm/src/builtins/set.rs(11 hunks)vm/src/builtins/slice.rs(2 hunks)vm/src/builtins/staticmethod.rs(1 hunks)vm/src/builtins/str.rs(23 hunks)vm/src/builtins/super.rs(2 hunks)vm/src/builtins/traceback.rs(2 hunks)vm/src/builtins/tuple.rs(1 hunks)vm/src/builtins/type.rs(7 hunks)vm/src/builtins/weakproxy.rs(1 hunks)vm/src/builtins/zip.rs(1 hunks)vm/src/bytes_inner.rs(16 hunks)vm/src/codecs.rs(3 hunks)vm/src/convert/try_from.rs(1 hunks)vm/src/coroutine.rs(2 hunks)vm/src/dict_inner.rs(5 hunks)vm/src/exceptions.rs(2 hunks)vm/src/format.rs(2 hunks)vm/src/frame.rs(3 hunks)vm/src/function/argument.rs(11 hunks)vm/src/function/arithmetic.rs(1 hunks)vm/src/function/buffer.rs(1 hunks)vm/src/function/either.rs(1 hunks)vm/src/function/fspath.rs(2 hunks)vm/src/function/number.rs(2 hunks)vm/src/function/protocol.rs(3 hunks)vm/src/intern.rs(1 hunks)vm/src/object/core.rs(11 hunks)vm/src/object/ext.rs(1 hunks)vm/src/object/traverse.rs(1 hunks)vm/src/object/traverse_object.rs(2 hunks)vm/src/ospath.rs(2 hunks)vm/src/protocol/buffer.rs(1 hunks)vm/src/protocol/iter.rs(3 hunks)vm/src/protocol/mapping.rs(1 hunks)vm/src/protocol/number.rs(2 hunks)vm/src/protocol/object.rs(6 hunks)vm/src/protocol/sequence.rs(1 hunks)vm/src/py_io.rs(1 hunks)vm/src/scope.rs(1 hunks)vm/src/sequence.rs(1 hunks)vm/src/sliceable.rs(1 hunks)vm/src/stdlib/ast/basic.rs(1 hunks)vm/src/stdlib/ast/exception.rs(3 hunks)vm/src/stdlib/ast/expression.rs(4 hunks)vm/src/stdlib/ast/statement.rs(22 hunks)vm/src/stdlib/ast/string.rs(1 hunks)vm/src/stdlib/ast/type_ignore.rs(2 hunks)
⛔ Files not processed due to max files limit (21)
- vm/src/stdlib/ast/type_parameters.rs
- vm/src/stdlib/collections.rs
- vm/src/stdlib/functools.rs
- vm/src/stdlib/io.rs
- vm/src/stdlib/itertools.rs
- vm/src/stdlib/operator.rs
- vm/src/stdlib/os.rs
- vm/src/stdlib/posix.rs
- vm/src/stdlib/sre.rs
- vm/src/stdlib/sys.rs
- vm/src/stdlib/thread.rs
- vm/src/stdlib/time.rs
- vm/src/stdlib/typevar.rs
- vm/src/stdlib/typing.rs
- vm/src/vm/context.rs
- vm/src/vm/method.rs
- vm/src/vm/mod.rs
- vm/src/vm/setting.rs
- vm/src/vm/thread.rs
- vm/src/warn.rs
- vm/sre_engine/src/engine.rs
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.rs`: Follow the default rustfmt code style (`cargo fmt` to format) Always ...
**/*.rs: Follow the default rustfmt code style (cargo fmtto format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
vm/src/builtins/zip.rscompiler/core/src/mode.rsstdlib/src/bz2.rsvm/src/builtins/mappingproxy.rsvm/src/builtins/map.rscommon/src/cformat.rsvm/src/builtins/classmethod.rsvm/src/builtins/staticmethod.rsvm/src/builtins/generator.rsvm/src/function/buffer.rsvm/src/function/arithmetic.rsvm/src/format.rscompiler/src/lib.rsvm/src/protocol/buffer.rsvm/src/builtins/iter.rsvm/src/builtins/coroutine.rsvm/src/builtins/slice.rsstdlib/src/hashlib.rsvm/src/function/number.rscompiler/codegen/src/lib.rsvm/src/builtins/enumerate.rscommon/src/atomic.rsvm/src/protocol/sequence.rsvm/src/stdlib/ast/basic.rsstdlib/src/posixsubprocess.rsvm/src/stdlib/ast/string.rsvm/src/sequence.rscommon/src/refcount.rscommon/src/lock/thread_mutex.rsvm/src/builtins/weakproxy.rsvm/src/builtins/builtin_func.rsvm/src/stdlib/ast/expression.rsvm/src/protocol/mapping.rsvm/src/object/traverse.rsvm/src/convert/try_from.rscommon/src/linked_list.rsvm/src/coroutine.rsderive-impl/src/compile_bytecode.rsstdlib/src/pyexpat.rsvm/src/function/fspath.rsvm/src/builtins/traceback.rscommon/src/str.rsvm/src/py_io.rsstdlib/src/resource.rsvm/src/builtins/object.rsvm/src/builtins/memory.rscompiler/codegen/src/symboltable.rsstdlib/src/syslog.rsderive-impl/src/from_args.rsvm/src/builtins/function.rsvm/src/builtins/tuple.rsvm/src/builtins/int.rsvm/src/builtins/property.rsvm/src/intern.rsvm/src/builtins/bool.rsvm/src/builtins/genericalias.rsstdlib/src/zlib.rsstdlib/src/pystruct.rsvm/src/ospath.rsvm/src/stdlib/ast/type_ignore.rsvm/src/object/ext.rsvm/src/builtins/float.rsvm/src/builtins/list.rsvm/src/protocol/number.rsstdlib/src/unicodedata.rsvm/src/builtins/super.rsvm/src/function/argument.rsvm/src/stdlib/ast/exception.rscompiler/codegen/src/ir.rsstdlib/src/contextvars.rsstdlib/src/select.rsvm/src/sliceable.rsvm/src/codecs.rsvm/src/builtins/asyncgenerator.rsvm/src/builtins/code.rscommon/src/lock/cell_lock.rsvm/src/scope.rsvm/src/function/protocol.rsvm/src/object/traverse_object.rsvm/src/builtins/module.rscompiler/core/src/bytecode.rsvm/src/object/core.rscompiler/codegen/src/compile.rsvm/src/frame.rscommon/src/boxvec.rsvm/src/buffer.rsstdlib/src/csv.rsvm/src/exceptions.rsderive-impl/src/error.rsvm/src/stdlib/ast/statement.rscompiler/core/src/frozen.rsvm/src/builtins/dict.rsvm/src/builtins/range.rsvm/src/function/either.rsstdlib/src/socket.rsvm/src/builtins/complex.rsstdlib/src/array.rsvm/src/protocol/iter.rsvm/src/protocol/object.rsvm/src/dict_inner.rsvm/src/builtins/bytes.rscommon/src/format.rsvm/src/builtins/bytearray.rsvm/src/builtins/set.rsvm/src/builtins/str.rsvm/src/builtins/type.rsvm/src/bytes_inner.rs
🧠 Learnings (41)
📓 Common learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
vm/src/builtins/map.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
common/src/cformat.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
vm/src/builtins/classmethod.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/staticmethod.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/generator.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/function/arithmetic.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/format.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
compiler/src/lib.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
stdlib/src/hashlib.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
compiler/codegen/src/lib.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/protocol/sequence.rs (2)
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
stdlib/src/posixsubprocess.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
vm/src/stdlib/ast/expression.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
vm/src/protocol/mapping.rs (2)
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
vm/src/py_io.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
vm/src/builtins/object.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/function.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/int.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/property.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
stdlib/src/zlib.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
stdlib/src/pystruct.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/float.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/list.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/protocol/number.rs (3)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
vm/src/builtins/super.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/function/argument.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
vm/src/stdlib/ast/exception.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
vm/src/builtins/code.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/module.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/object/core.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
vm/src/exceptions.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/stdlib/ast/statement.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/range.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/complex.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/protocol/iter.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/protocol/object.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/bytes.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
common/src/format.rs (2)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
vm/src/builtins/str.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/builtins/type.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.851Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
🧬 Code Graph Analysis (5)
vm/src/builtins/object.rs (13)
vm/src/builtins/bytes.rs (1)
new_ref(102-104)vm/src/builtins/list.rs (1)
new_ref(66-68)vm/src/builtins/bytearray.rs (1)
new_ref(76-78)vm/src/builtins/set.rs (1)
new_ref(42-46)vm/src/builtins/classmethod.rs (1)
new_ref(114-122)vm/src/builtins/complex.rs (1)
new_ref(235-237)vm/src/builtins/function.rs (1)
new_ref(729-735)vm/src/builtins/dict.rs (2)
new_ref(54-56)dict(755-755)vm/src/builtins/staticmethod.rs (1)
new_ref(64-72)vm/src/builtins/tuple.rs (1)
new_ref(176-183)vm/src/builtins/str.rs (1)
new_ref(397-400)vm/src/object/core.rs (3)
new_ref(1046-1051)Self(373-376)dict(709-711)vm/src/builtins/namespace.rs (1)
new_ref(30-36)
vm/src/object/ext.rs (1)
vm/src/object/core.rs (1)
Self(373-376)
vm/src/builtins/float.rs (5)
vm/src/builtins/complex.rs (2)
from(50-52)other(413-413)vm/src/builtins/int.rs (4)
from(45-47)other(300-301)other(311-311)other(719-720)vm/src/builtins/list.rs (1)
other(134-134)vm/src/builtins/builtin_func.rs (1)
other(216-216)vm/src/builtins/memory.rs (1)
other(333-333)
vm/src/stdlib/ast/statement.rs (3)
vm/src/stdlib/ast/expression.rs (2)
ast_from_object(51-139)ast_to_object(8-49)vm/src/class.rs (1)
static_type(25-33)vm/src/stdlib/ast.rs (1)
range_from_object(166-189)
vm/src/builtins/bytes.rs (6)
vm/src/builtins/bytearray.rs (10)
repeat(95-97)center(338-340)ljust(343-345)rjust(348-350)join(358-360)iter(837-842)translate(425-427)mod_(540-543)lstrip(650-660)rstrip(663-673)vm/src/builtins/tuple.rs (2)
repeat(196-210)iter(420-425)vm/src/builtins/str.rs (9)
repeat(483-500)center(1284-1291)ljust(1294-1301)rjust(1304-1311)join(1121-1139)iter(1514-1519)translate(1329-1359)lstrip(800-816)rstrip(819-835)vm/src/protocol/sequence.rs (1)
repeat(135-149)vm/src/bytes_inner.rs (7)
center(520-526)ljust(528-534)rjust(536-542)join(551-554)translate(587-607)lstrip(619-625)rstrip(627-633)vm/src/builtins/weakproxy.rs (1)
__bytes__(98-100)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: Run tests under miri
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Ensure compilation on various targets
🔇 Additional comments (240)
vm/src/stdlib/ast/string.rs (1)
258-259: LGTM! Excellent use ofSelfin enum pattern matching.The replacement of explicit
JoinedStrPart::withSelf::in the match arms improves code conciseness and follows Rust idioms. This change maintains the same functionality while making the code more maintainable.vm/src/builtins/zip.rs (1)
39-39: LGTM! Proper use ofSelfin struct instantiation.The replacement of explicit
PyZipwithSelfin the struct instantiation improves code conciseness and follows Rust best practices. The functionality remains identical while the code becomes more maintainable.vm/src/builtins/coroutine.rs (1)
33-35: LGTM! Correct usage ofSelfin constructor method.The replacement of explicit
PyCoroutinewithSelfin the struct instantiation follows Rust best practices and improves code readability. The constructor logic remains unchanged while the code becomes more concise and maintainable.vm/src/function/arithmetic.rs (1)
37-38: LGTM! Excellent use ofSelfin enum pattern matching.The replacement of explicit
PyArithmeticValue::withSelf::in the match arms improves code conciseness and follows Rust idioms. This change maintains the same functionality while making the code more maintainable and readable.common/src/atomic.rs (1)
68-70: LGTM! Proper use ofSelfin constructor method.The replacement of explicit
OncePtrwithSelfin the struct instantiation follows Rust best practices and improves code readability. The constructor logic remains unchanged while the code becomes more concise and maintainable.vm/src/builtins/generator.rs (1)
35-39: LGTM! Improved idiomatic Rust usage.Using
Selfinstead of the explicit type namePyGeneratorwithin the impl block is more concise and idiomatic.vm/src/builtins/enumerate.rs (1)
47-50: LGTM! Improved idiomatic Rust usage.Using
Selfinstead of the explicit type namePyEnumeratewithin the impl block is more concise and idiomatic.stdlib/src/bz2.rs (1)
50-52: LGTM! Improved idiomatic Rust usage.Using
Self::StreamEndinstead of the explicit enum nameStatus::StreamEndwithin the impl block is more concise and idiomatic.compiler/core/src/mode.rs (1)
16-18: LGTM! Improved idiomatic Rust usage.Using
Self::instead of the explicit enum nameMode::within the impl block is more concise and idiomatic.stdlib/src/syslog.rs (1)
52-53: LGTM! Improved idiomatic Rust usage.Using
Self::instead of the explicit enum nameGlobalIdent::within the impl block is more concise and idiomatic.vm/src/builtins/classmethod.rs (1)
95-97: LGTM! Excellent use of idiomatic Rust style.Using
Selfinstead of the explicit type name within impl blocks is the preferred Rust idiom. This change improves maintainability and follows best practices.vm/src/builtins/staticmethod.rs (1)
49-52: LGTM! Consistent with idiomatic Rust style.Using
Selfinstead of explicit type names within impl blocks is the preferred approach in Rust. This change improves code consistency and maintainability.vm/src/stdlib/ast/basic.rs (1)
17-17: LGTM! Proper use of Self in constructor call.Using
Self::new()instead of the fully qualified type name within impl blocks is idiomatic Rust. This change improves code readability and maintainability.vm/src/builtins/map.rs (1)
30-33: LGTM! Consistent idiomatic Rust style.Using
Selffor struct initialization within impl blocks is the preferred Rust idiom. This change improves code consistency and maintainability across the codebase.vm/src/builtins/mappingproxy.rs (1)
32-33: LGTM! Idiomatic enum variant matching.Using
Self::for enum variant matching within impl blocks is the preferred Rust idiom. This change improves code consistency and makes the code more maintainable.vm/src/builtins/iter.rs (1)
31-32: LGTM! Excellent use ofSelffor enum variants.This change improves code readability by using the idiomatic
Self::syntax instead of explicit enum variant paths within the impl block.vm/src/object/traverse.rs (1)
147-148: LGTM! Clean improvement usingSelfin pattern matching.The use of
Self::AandSelf::Binstead of explicitEither::AandEither::Bfollows Rust idioms and enhances code maintainability.stdlib/src/pyexpat.rs (1)
68-75: LGTM! Idiomatic constructor usingSelf.Replacing the explicit struct name with
Selfin the constructor is a clean improvement that makes the code more maintainable and follows Rust best practices.vm/src/builtins/tuple.rs (1)
339-339: LGTM! Proper use ofSelffor method calls.Using
Self::new_refinstead ofPyTuple::new_refwithin the impl block is more concise and follows Rust conventions for referring to the current type.vm/src/builtins/builtin_func.rs (1)
267-267: LGTM! Clean constructor syntax usingSelf.The change from
NativeFunctionOrMethod(...)toSelf(...)is a nice stylistic improvement that makes the code more readable and idiomatic.vm/src/function/number.rs (1)
44-45: Use ofSelfconstructor is clear and idiomatic
Nothing to flag – the swap toSelf { value }is correct and keeps the logic unchanged.compiler/codegen/src/compile.rs (1)
286-286: Excellent use ofSelfin constructor method.This change makes the code more concise and idiomatic by using
Selfinstead of the explicit struct name within theimplblock. This is the preferred Rust style for constructor methods and improves maintainability.vm/src/function/buffer.rs (1)
174-176: Idiomatic use ofSelf– looks goodReplacing the explicit variant path with
Self::Stringis inline with Rust style and keeps the logic unchanged.vm/src/protocol/buffer.rs (1)
66-72: Constructor call shortened withSelf::new– no concernsThe switch from
PyBuffer::newtoSelf::newis purely stylistic within the sameimplscope and does not affect behaviour.common/src/lock/thread_mutex.rs (1)
24-28: ConsistentSelfusage in constants & ctorBoth the
INITconstant andnewconstructor now useSelffor clarity. Implementation remains identical; no functional impact observed.Also applies to: 82-85
vm/src/function/fspath.rs (1)
28-35: Enum variant shorthand applied consistentlyAll occurrences now use
Self::{Str,Bytes}for pattern matching & construction. Improves readability without altering semantics.Also applies to: 64-66, 72-74, 79-81, 86-88
compiler/codegen/src/lib.rs (1)
31-63: LGTM: Idiomatic use ofSelfin pattern matching.The replacement of explicit enum variant paths with
Self::notation makes the code more concise and follows Rust best practices. The logic remains unchanged while improving readability.vm/src/builtins/float.rs (2)
55-55: LGTM: Consistent use ofSelfin struct construction.Using
Self { value }instead ofPyFloat { value }improves code maintainability and follows Rust idioms.
526-526: LGTM: Consistent generic parameter usage.The change from
payload_if_subclass::<PyFloat>topayload_if_subclass::<Self>aligns with similar patterns used in other builtin types (as seen invm/src/builtins/list.rs,vm/src/builtins/complex.rs, andvm/src/builtins/int.rs) and improves code consistency.vm/src/py_io.rs (1)
48-48: LGTM: Idiomatic trait method dispatch.Using
<Self as fmt::Write>instead of<String as fmt::Write>makes the code more generic and follows Rust best practices.common/src/cformat.rs (4)
106-109: LGTM: Consistent enum variant pattern matching.Using
Self::Number(x),Self::Float(x), etc. instead of the fully qualified variants improves code conciseness while maintaining clarity.
122-122: LGTM: Idiomatic struct construction in trait implementation.Using
Self::Quantity(quantity)follows Rust best practices for constructor methods.
341-341: LGTM: Consistent static method calls.Using
Self::compute_fill_stringinstead of the fully qualified method name improves maintainability and follows Rust conventions.Also applies to: 364-364
724-724: LGTM: Simplified pattern matching.Using
Self::Specinstead ofCFormatPart::Specin pattern matches makes the code more concise and idiomatic.Also applies to: 730-730
vm/src/stdlib/ast/expression.rs (2)
682-682: LGTM: Idiomatic pattern matching and construction for ExprYield.Using
Selfin both destructuring (let Self { value, range } = self;) and construction (Ok(Self { ... })) follows Rust best practices and improves code maintainability.Also applies to: 698-698
1023-1023: LGTM: Consistent pattern matching and construction for ExprList.The use of
Selfin both destructuring and construction patterns aligns with the changes made to other AST node types and follows Rust idioms.Also applies to: 1041-1041
vm/src/coroutine.rs (2)
14-15: LGTM! Idiomatic use ofSelfin enum variants.The replacement of
ExecutionResult::YieldandExecutionResult::ReturnwithSelf::YieldandSelf::Returnis correct and follows Rust best practices for more concise, maintainable code.
52-52: LGTM! Proper use ofSelfin constructor.Using
Selfinstead of the explicit struct nameCoroin the constructor is idiomatic Rust and improves code maintainability.vm/src/builtins/super.rs (2)
51-51: LGTM! Correct use ofSelfin constructor implementation.Replacing
PySuperwithSelfin theConstructortrait implementation is idiomatic and maintains the same functionality while improving code readability.
208-208: LGTM! Appropriate use ofSelfin descriptor implementation.Using
Selfinstead ofPySuperin theGetDescriptortrait implementation follows Rust best practices and improves code maintainability.vm/src/builtins/weakproxy.rs (1)
56-56: LGTM! Idiomatic constructor implementation.Replacing
PyWeakProxywithSelfin the constructor is correct and follows Rust best practices for more concise and maintainable code.vm/src/function/argument.rs (6)
81-84: LGTM! Consistent use ofSelfinFuncArgsimplementations.The replacement of explicit
FuncArgswithSelfin theFromtrait implementations and methods improves code consistency and follows Rust idioms.Also applies to: 90-93, 128-131
253-253: LGTM! Proper use ofSelfin error conversion.Using
Self::Exceptioninstead ofArgumentError::Exceptionis idiomatic and maintains the same functionality.
265-281: LGTM! Consistent enum variant usage withSelf.Replacing
ArgumentErrorvariants withSelfvariants in the match expression is correct and improves code maintainability.
348-348: LGTM! IdiomaticSelfusage inKwArgsimplementations.The consistent use of
Selfinstead of explicitKwArgstype names across various trait implementations follows Rust best practices.Also applies to: 362-362, 368-368, 381-381
462-462: LGTM! Proper constructor pattern withSelf.Using
Selfin thePosArgsconstructor is idiomatic and maintains consistency with the codebase improvements.
504-506: LGTM! Correct enum variant usage inOptionalArg.Replacing explicit
OptionalArgvariants withSelfvariants in both pattern matching and construction is idiomatic Rust and improves code readability.Also applies to: 535-537
vm/src/object/ext.rs (1)
496-496: LGTM! Idiomatic pointer cast withSelf.Replacing
*const PyObjectwith*const Selfin theunique_idmethod is correct and follows Rust best practices. This change aligns with the pattern used elsewhere in the codebase (as seen invm/src/object/core.rs) and improves code maintainability.vm/src/sequence.rs (1)
142-142: Excellent use ofSelffor improved type genericity.This change makes the return type more generic and follows Rust best practices by using
Selfinstead of the concrete typeVec<T>.vm/src/stdlib/ast/type_ignore.rs (1)
11-11: Great use ofSelffor enum variant references.Replacing
TypeIgnore::TypeIgnorewithSelf::TypeIgnoremakes the code more concise and follows Rust idioms for referencing enum variants within impl blocks.Also applies to: 21-21
vm/src/sliceable.rs (1)
309-309: Improved type cast usingSelf.Using
Selfinstead of the explicitisizetype makes the cast more self-documenting and consistent with the surrounding codebase.vm/src/builtins/slice.rs (1)
68-68: Excellent refactoring to useSelfin constructors and type annotations.These changes make the code more maintainable by using
Selfinstead of repeating thePySlicetype name. This follows Rust best practices and reduces the need for updates if the type name ever changes.Also applies to: 74-78, 83-87
vm/src/function/either.rs (1)
31-31: Proper use ofSelfin trait bounds.The change correctly uses
Selfto refer toPyObjectRef(the target type) in the trait bounds, making the implementation more generic and self-documenting.vm/src/builtins/traceback.rs (2)
31-31: Good use ofSelfin constructor!Using
Selfinstead of the explicit struct name improves code maintainability and follows Rust best practices.
66-66: Excellent iterator return type improvement!Using
Selfas the iterator item type makes the method signature more generic and idiomatic.derive-impl/src/compile_bytecode.rs (2)
237-237: Clean return type improvement!Using
Selfin the return type makes the function signature more maintainable and idiomatic.
310-310: Good constructor pattern!Using
Selffor struct instantiation within impl blocks follows Rust best practices and improves readability.vm/src/builtins/property.rs (1)
202-204: Excellent improvement for descriptor subclassing!Using
Self::py_newandSelf::initinstead of explicit type names enables better subclass support while maintaining type safety through the downcast operation.vm/src/intern.rs (1)
314-314: Safe and idiomatic transmute improvement!Using
&Selfinstead of the explicit type reference maintains type safety while making the unsafe operation more generic and maintainable.stdlib/src/pystruct.rs (4)
42-42: Clean tuple struct construction!Using
Selfinstead of the explicit struct name follows Rust conventions and improves maintainability.
168-168: Good return type improvement!Using
Selfin the return type makes the function signature cleaner and more maintainable.
183-183: Excellent constructor pattern!Using
Selffor struct instantiation within impl blocks is idiomatic Rust and improves code readability.
247-247: Great constructor improvement!Using
Selfinstead of the explicit struct name follows Rust best practices and makes the code more maintainable.stdlib/src/hashlib.rs (7)
103-106: LGTM! Excellent use ofSelfin constructor.This change improves code maintainability by using the idiomatic
Selfkeyword instead of the explicit struct name in the constructor.
146-146: LGTM! Consistent use ofSelf::newin method.Using
Self::newinstead of the explicit constructor call follows Rust best practices and improves code consistency.
176-179: LGTM! Proper use ofSelfin constructor.This change enhances code readability and maintainability by using the
Selfkeyword consistently in the constructor.
219-219: LGTM! Consistent constructor pattern.Using
Self::newmaintains consistency with the pattern established in other methods and follows Rust conventions.
370-373: LGTM! Clean constructor implementation.The use of
Selfin the constructor improves code clarity and follows idiomatic Rust practices.
406-410: LGTM! Consistent enum variant usage.Using
Self::Shake128andSelf::Shake256instead of the fully qualified enum paths improves code readability and maintains consistency within theimplblock.Also applies to: 414-418
423-425: LGTM! Consistent pattern matching withSelf.The pattern matching consistently uses
Self::Variantsyntax, which improves code maintainability and follows Rust best practices for enum handling withinimplblocks.Also applies to: 430-432, 437-439
vm/src/builtins/list.rs (3)
40-43: LGTM! Clean constructor implementation withSelf.Using
Selfin theFromtrait implementation improves code readability and follows Rust idioms for constructor patterns.
134-134: LGTM! Consistent use ofSelfin generic context.Using
Selfas the generic type parameter improves code clarity and maintains consistency within the method implementation.
382-382: LGTM! Proper constructor trait implementation.Using
Self::default()in theConstructortrait follows Rust conventions and improves code maintainability.vm/src/builtins/genericalias.rs (3)
71-71: LGTM! Clean constructor trait implementation.Using
Self::newin theConstructortrait implementation improves code consistency and follows Rust best practices for type references withinimplblocks.
204-204: LGTM! Consistent constructor usage in method.The use of
Self::newmaintains consistency and improves code readability in the__getitem__method implementation.
599-604: LGTM! Proper use ofSelf::newin iterator implementation.Using
Self::newfor creating the starred alias follows Rust conventions and improves code maintainability in theIterabletrait implementation.vm/src/builtins/function.rs (6)
81-95: LGTM! Excellent constructor implementation withSelf.Using
Selfin the constructor improves code readability and maintainability. The implementation follows Rust best practices for struct initialization withinimplblocks.
452-452: LGTM! Clean downcast operation withSelf.Using
Selfin the downcast operation improves type safety and code consistency while maintaining the same functionality.
463-463: LGTM! Consistent type reference withSelf.Using
PyRef<Self>follows Rust conventions and improves code maintainability by using the type alias consistently.
640-651: LGTM! Proper constructor call pattern.Using
Self::newin theConstructortrait implementation maintains consistency and follows Rust best practices for method calls withinimplblocks.
718-718: LGTM! Clean constructor delegation.Using
Self::newin theConstructortrait implementation improves code consistency and readability.
726-726: LGTM! Consistent struct literal withSelf.Using
Selfin the struct literal follows Rust idioms and improves code maintainability within theimplblock.vm/src/builtins/memory.rs (3)
80-83: Idiomatic use ofSelf– looks good
Switching toSelf::from_bufferkeeps the code concise and resilient to future type-renames.
94-104: Consistent struct construction withSelf– no issues
The move toOk(Self { .. })is purely stylistic and correct.
123-130:new_viewrefactor complete
ReplacingPyMemoryViewwithSelfmaintains clarity and adheres to the PR objective.compiler/codegen/src/ir.rs (3)
14-15: Const definition updated toSelf– approved
This change is straightforward and preserves behaviour.
60-64:Defaultimpl now returnsSelf– approved
The refactor is idiomatic and has no functional impact.
94-111: Destructuring withlet Self { .. }– approved
The pattern remains correct and improves readability without altering semantics.stdlib/src/socket.rs (3)
800-810: LGTM: Idiomatic use ofSelfin Default implementationThe replacement of
PySocketwithSelfin the constructor follows Rust best practices and improves code maintainability.
1660-1667: LGTM: Proper use ofSelfin constructorThe change from
Address { host, port }toSelf { host, port }is idiomatic Rust and improves code consistency within the impl block.
1669-1688: LGTM: Consistent use ofSelffor associated function callThe replacement of
Address::from_tuplewithSelf::from_tuplemaintains consistency with the use ofSelfthroughout the impl block and follows Rust conventions.vm/src/builtins/asyncgenerator.rs (2)
36-41: LGTM: Idiomatic use ofSelfin constructorThe replacement of
PyAsyncGenwithSelfin the constructor follows Rust best practices and improves code readability within the impl block.
78-81: LGTM: Proper use ofSelfin method return typeThe change from
PyRef<PyAsyncGen>toSelfis correct since this method is in animpl PyRef<PyAsyncGen>block, makingSelfequivalent toPyRef<PyAsyncGen>. This follows Rust idioms and improves maintainability.vm/src/builtins/range.rs (5)
188-193: Excellent use ofSelffor struct construction.This change correctly replaces the explicit
PyRangetype name withSelfwithin the impl block, making the code more concise and idiomatic.
207-212: Good refactoring to use idiomatic Rust syntax.Using
Selfinstead of the explicit type name improves code readability and maintainability within impl blocks.
299-305: Correct usage ofSelffor struct construction.The change from
PyRange { ... }toSelf { ... }is appropriate and follows Rust conventions.
318-322: Proper use ofSelf::for associated functions.These changes correctly replace
PyRange::newandPyRange::new_fromwithSelf::newandSelf::new_fromrespectively.
700-708: Excellent enum variant refactoring.The changes from
RangeIndex::IntandRangeIndex::SlicetoSelf::IntandSelf::Sliceare correct and make the code more concise within theTryFromObjectimplementation.stdlib/src/select.rs (4)
149-150: Good use ofSelffor struct construction.Replacing
Selectable { obj, fno }withSelf { obj, fno }is the idiomatic way to construct structs within impl blocks.
158-164: Correct refactoring for tuple struct construction.Both changes are appropriate:
Self::new()for the associated function call andSelf(fdset)for tuple struct construction.
443-444: Proper tuple struct construction withSelf.The change from
EventMask(mask)toSelf(mask)correctly uses theSelfkeyword for tuple struct construction.
605-606: Clean struct construction usingSelf.This change improves code consistency by using
Selfinstead of the explicitPyEpolltype name.stdlib/src/contextvars.rs (3)
153-154: Excellent use ofSelffor associated function call.Replacing
PyContext::empty(vm)withSelf::empty(vm)is more concise and idiomatic within the impl block.
256-257: Good refactoring in Constructor implementation.Using
Self::empty(vm)instead of the explicit type name improves code clarity within the trait implementation.
502-508: Proper struct construction withSelf.The change from
ContextVar { ... }toSelf { ... }follows Rust conventions for struct construction within impl blocks.vm/src/object/traverse_object.rs (2)
20-31: Correct use ofSelfin const context.Replacing
PyObjVTable { ... }withSelf { ... }is appropriate and works correctly in const contexts.
52-53: Proper type cast usingSelf.The change from
PyInner<Erased>toSelfin the unsafe cast is correct and more concise within the impl block.stdlib/src/unicodedata.rs (2)
50-54: Excellent enum variant refactoring.The changes from
NormalizeForm::Nfc,NormalizeForm::Nfkc, etc. toSelf::Nfc,Self::Nfkc, etc. are correct and make the code more concise.
224-230: Clean enum pattern matching withSelf::.Replacing the explicit
EastAsianWidth::qualifiers withSelf::improves readability and follows Rust conventions for pattern matching within impl blocks.vm/src/codecs.rs (3)
45-45: Excellent use ofSelffor improved idiomatic Rust style!Using
Self(tuple)instead ofPyCodec(tuple)makes the code more maintainable and follows Rust best practices.
142-142: Good consistency in usingSelffor method calls.The change to
Self::from_tuplemaintains consistency with the otherSelfusage improvements in this impl block.
193-195: Perfect constructor style improvement!Using
Self { ... }instead of the explicit struct name makes the constructor more maintainable and idiomatic.vm/src/ospath.rs (3)
47-47: Excellent return type improvement!Using
PyResult<Self>instead ofPyResult<OsPath>makes the method signature more maintainable and idiomatic.
53-53: Consistent constructor style with the return type change.The
Self { path, mode }construction aligns perfectly with thePyResult<Self>return type change above.
122-124: Great improvement to enum variant references!Using
Self::PathandSelf::Fdinstead of the fully qualifiedOsPathOrFd::variants is more idiomatic and maintainable.derive-impl/src/from_args.rs (4)
17-17: Excellent return type improvement for better maintainability.Using
Option<Self>instead ofOption<ParameterKind>makes the method signature more idiomatic and maintainable.
19-22: Perfect enum variant style improvements!Replacing
ParameterKind::withSelf::for all variant references makes the code more concise and idiomatic.
37-37: Consistent return type improvement.Using
Option<Result<Self>>aligns with the Rust idiom of usingSelfin return types within impl blocks.
55-59: Great constructor consistency with the return type changes.Using
Self { ... }for the constructor aligns perfectly with theOption<Result<Self>>return type improvement.vm/src/function/protocol.rs (3)
53-53: Excellent trait implementation improvement!Using
Selfin theFromtrait return type is more idiomatic and maintains the same functionality.
66-66: Consistent constructor style improvement.The
Self { obj, call }construction follows the idiomatic Rust pattern for struct initialization within impl blocks.
178-178: Perfect consistency with the ArgCallable From implementation!Using
Selfin bothFromtrait implementations maintains consistency and idiomatic style throughout the module.vm/src/builtins/complex.rs (4)
51-51: Excellent trait implementation constructor improvement!Using
Self { value }in theFromtrait implementation is more idiomatic and maintainable than the explicit type name.
164-164: Great use ofSelfin generic parameters!Using
downcast_exact::<Self>instead of the explicit type makes the code more maintainable and follows Rust idioms.
396-396: Perfect return type improvement for the__complex__method!Using
Selfin the return type makes the method signature more maintainable and idiomatic.
413-413: Excellent consistency in generic parameter usage!Using
payload_if_subclass::<Self>maintains consistency with the otherSelfimprovements and enhances maintainability.vm/src/builtins/code.rs (3)
205-207: LGTM: Idiomatic use ofSelfin constructorThe change from explicit
PyCodetoSelfin both the return type and struct instantiation follows Rust best practices for impl blocks.
338-338: LGTM: Consistent use ofSelfin return typeThe return type change from
PyResult<PyCode>toPyResult<Self>is idiomatic and maintains consistency with the constructor pattern.
395-421: LGTM: Proper use ofSelfin struct instantiationThe struct instantiation using
Selfinstead of explicitPyCodeis more concise and follows Rust conventions within impl blocks.vm/src/frame.rs (3)
145-145: LGTM: Idiomatic use ofSelfin constructor return typeThe change from explicit
FrametoSelfin the return type follows Rust best practices for impl blocks.
158-171: LGTM: Consistent struct instantiation withSelfUsing
Selfinstead of explicitFramein the struct instantiation is more concise and idiomatic within impl blocks.
2288-2288: LGTM: Proper use ofSelfin generic type parameterThe change from
elem.payload_is::<Frame>()toelem.payload_is::<Self>()maintains correctness while following the consistent pattern of usingSelfthroughout the codebase.vm/src/builtins/int.rs (1)
226-226: Excellent use ofSelfkeyword for improved code consistency.The systematic replacement of explicit
PyInttype references withSelfthroughout the implementation significantly improves code maintainability and follows Rust idiomatic patterns. All changes are correctly applied withinimpl PyIntblocks whereSelfappropriately refers to the current type.Also applies to: 258-258, 301-301, 311-311, 405-405, 720-720, 754-795
compiler/codegen/src/symboltable.rs (1)
52-60: Clean idiomatic improvements usingSelfkeyword.The changes appropriately replace explicit type names with
Selfin constructors, enum variant patterns, and type annotations. This enhances code maintainability and follows Rust best practices for code withinimplblocks.Also applies to: 90-95, 157-163, 296-296
vm/src/scope.rs (1)
19-22: Proper application ofSelfkeyword in method signatures and constructors.The changes correctly replace explicit
Scopetype references withSelfin return types and constructors, improving code consistency and following Rust idiomatic patterns within theimplblock.Also applies to: 28-35
common/src/boxvec.rs (1)
41-46: Consistent and correct use ofSelfkeyword throughout.The changes systematically replace explicit type names with
Selfin constructors and return types for bothBoxVec<T>andCapacityError<T>. This improves code maintainability and follows Rust idiomatic practices withinimplblocks.Also applies to: 596-596, 679-681
common/src/lock/cell_lock.rs (1)
14-16: LGTM! Excellent use ofSelfin const declarations.These changes properly replace explicit type names with
Selfin constant initializations within impl blocks, making the code more concise and idiomatic.Also applies to: 64-66, 206-206
vm/src/protocol/iter.rs (3)
79-82: LGTM! Proper generalization withSelf.The
Fromtrait implementation is correctly generalized to usePyIter<Self>instead of the explicitPyIter<PyObjectRef>, making it more flexible and idiomatic.
135-135: LGTM! Appropriate use ofSelf::check.Using
Self::checkinstead ofPyIter::checkis correct within theTryFromObjectimplementation context and improves readability.
163-164: LGTM! Clean enum variant pattern matching.Replacing explicit
PyIterReturn::prefixes withSelf::in pattern matching is idiomatic and improves code conciseness within the impl block.compiler/core/src/frozen.rs (3)
35-35: LGTM! Concise struct construction.Using
Self { bytes }instead of the explicit type name makes the constructor more concise and maintainable.
45-46: LGTM! Proper use ofSelfin method signature and unsafe cast.The return type and pointer cast correctly use
Self, improving code consistency while maintaining the same semantics.
103-103: LGTM! Clean method signature.Using
Selfas the return type is more idiomatic and consistent with Rust conventions.derive-impl/src/error.rs (4)
78-85: LGTM! Consistent use ofSelfin constructor.The
errormethod properly usesSelffor both return type and struct construction, improving code consistency.
87-94: LGTM! Clean method signature and construction.The
spans_errormethod correctly usesSelfthroughout, making it more concise and idiomatic.
96-104: LGTM! Proper use ofSelfin generic contexts.The
from_vecmethod appropriately usesSelfin both the parameter typeVec<Self>and return type, maintaining semantic correctness.
116-120: LGTM! Idiomatic trait implementation.The
From<Error>trait implementation correctly usesSelffor return type and struct construction, following Rust best practices.compiler/core/src/bytecode.rs (6)
39-49: LGTM! Clean enum variant pattern matching.The pattern matching in
borrow_constantproperly usesSelf::prefixes for enum variants, making the code more concise and maintainable.
139-148: LGTM! Consistent flag constant definitions.The
NAME_MAPPINGconstant correctly usesSelf::prefixes for the flag values, improving readability and maintainability.
157-158: LGTM! Idiomatic constructor implementations.The
null()andmarker()methods properly useSelfin constructor calls, following Rust conventions for associated functions.Also applies to: 172-173, 284-285
336-337: LGTM! ProperOpArgTypetrait implementations.The trait implementations correctly use
Selffor constructor calls and enum variants, improving code consistency.Also applies to: 354-358
634-637: LGTM! Clean trait implementations.The
FromandTryFromtrait implementations properly useSelffor return types and in unsafe transmute operations, maintaining semantic correctness while improving readability.Also applies to: 644-647
683-684: LGTM! Consistent method call.Using
Self::from_bitsinstead of the explicit type name is more idiomatic and maintainable.compiler/src/lib.rs (1)
60-62: Good use ofSelffor enum variantsReplacing the fully-qualified names with
Self::{Codegen, Parse}inside theimpl CompileErrorblock improves readability and keeps the code resilient to type renames without altering behaviour.Also applies to: 67-78, 83-85
stdlib/src/array.rs (1)
1457-1468: Casting viaas Selfremains correctThe switch from explicit
u8casts toas Selfkeeps theimpl From<MachineFormatCode> for u8concise while preserving the original logic.vm/src/builtins/set.rs (4)
85-89: LGTM: Idiomatic use ofSelfin Default implementation.The replacement of
PyFrozenSetwithSelfin the struct construction is more concise and follows Rust best practices.
214-218: LGTM: Consistent use ofSelfin method signature and implementation.Both the return type and struct construction now use
Self, making the code more maintainable and concise.
245-263: LGTM: Excellent consistency in set operation methods.The systematic replacement of explicit return types with
Selfacross union, intersection, difference, and symmetric_difference methods creates a uniform and maintainable API.Also applies to: 265-271, 277-288
1268-1268: LGTM: Clean struct construction withSelf.The TryFromObject implementation now uses idiomatic
Selfconstruction.common/src/format.rs (5)
41-58: LGTM: Excellent enum method refactoring.The conversion from explicit
FormatConversionvariants toSelf::variants in bothfrom_charandfrom_stringmethods demonstrates consistent application of idiomatic Rust patterns.
70-78: LGTM: Clean FormatAlign implementation.The method signature and variant references now use
Selfconsistently, improving code readability.
144-144: LGTM: Proper trait implementation withSelf.The From trait implementation correctly uses
Selfas the return type, following Rust conventions.
302-312: LGTM: Comprehensive FormatSpec construction.The struct construction using
Selfmaintains the same field initialization while being more concise and maintainable.
719-723: LGTM: Clean FromStr trait implementation.The trait implementation now uses
Self::parse()which is more idiomatic and consistent with the rest of the code.vm/src/format.rs (1)
15-40: LGTM: Excellent error handling refactoring.The systematic replacement of explicit enum variants (
FormatSpecError::andFormatParseError::) withSelf::in the match arms makes the code more concise while maintaining identical functionality and error messages.Also applies to: 48-48
common/src/str.rs (1)
50-52: LGTM: Clean use ofSelfin pattern matching.The pattern matching update from explicit
StrKind::variants toSelf::variants is idiomatic and improves code conciseness while maintaining identical functionality.common/src/refcount.rs (1)
24-26: LGTM: Idiomatic use ofSelfin constructor.Using
Selfinstead of the explicitRefCounttype name in the constructor follows Rust best practices and improves maintainability.vm/src/builtins/object.rs (1)
72-72: LGTM: Consistent use ofSelfwithPyRef::new_refpattern.The change to use
Selfinstead ofPyBaseObjectis consistent with the pattern used throughout the codebase forPyRef::new_refcalls, as seen in similar constructors across other builtin types.vm/src/protocol/sequence.rs (1)
53-62: LGTM: Improved constant declaration withSelf.Using
Selfinstead of the explicitPySequenceMethodstype name in the constant declaration is more concise and follows Rust idiomatic style within impl blocks.stdlib/src/posixsubprocess.rs (2)
74-74: LGTM: Idiomatic struct construction withSelf.Using
Selfinstead of the explicitCStrPathLiketype name in the constructor is more concise and follows Rust best practices.
179-181: LGTM: Clean pattern matching withSelf.The pattern matching update from explicit
ExecErrorContext::variants toSelf::variants improves code readability and follows idiomatic Rust style within impl blocks.vm/src/protocol/mapping.rs (1)
44-44: Excellent use ofSelffor improved consistency.This change properly uses
Selfinstead of the explicit type name in the constant declaration, making the code more idiomatic and maintainable.vm/src/builtins/bool.rs (1)
24-24: Good use ofSelfin trait implementation.Using
Selfinstead of the explicitbooltype in the return type annotation is more idiomatic and maintains consistency with Rust best practices.common/src/linked_list.rs (2)
143-149: Proper use ofSelfin constructor.Using
Selfinstead of the explicitLinkedList<L, T>type in the constructor return type is more idiomatic and maintainable.
326-334: Good improvement in constructor return type.Replacing the explicit
Pointers<T>type withSelfin the constructor follows Rust best practices and improves code consistency.vm/src/protocol/number.rs (2)
162-162: Excellent use ofSelfin constant declaration.Using
Selfinstead of the explicitPyNumberMethodstype in the constant declaration is more idiomatic and improves code maintainability.
200-200: Good improvement in function return type.Replacing
&'static PyNumberMethodswith&'static Selffollows Rust best practices and makes the code more consistent.vm/src/stdlib/ast/statement.rs (3)
7-34: Excellent use ofSelfin pattern matching.The consistent replacement of
ruff::Stmt::withSelf::in all match arms makes the code more idiomatic and easier to maintain. This change properly leverages Rust'sSelfkeyword within the impl block.
45-159: Good improvement in constructor calls.Using
Self::instead ofruff::Stmt::for enum variant construction is more idiomatic and consistent with Rust best practices. The changes maintain the same functionality while improving code clarity.
171-181: Proper use ofSelfin struct destructuring and construction.The consistent replacement of explicit struct names with
Selfin destructuring patterns and constructor calls throughout the AST node implementations is excellent. This improves code maintainability and follows Rust idioms perfectly.Also applies to: 345-348, 363-363, 374-377, 392-392, 450-455, 478-478, 958-962, 979-979, 995-998, 1013-1013, 1070-1073, 1088-1088, 1101-1104, 1119-1119, 1132-1135, 1150-1150, 1163-1163, 1176-1176, 1184-1184, 1197-1197, 1205-1205, 1218-1218
stdlib/src/csv.rs (5)
71-71: Excellent use ofSelfin constructor method.The change from
PyDialect::try_from_objecttoSelf::try_from_objectimproves code consistency and follows Rust idioms within impl blocks.
428-432: Great consistency improvement withSelf::enum variants.Using
Self::Always,Self::NonNumeric, andSelf::Neverinstead of fully qualified variants makes the code more concise and maintainable within the impl block.
447-456: Consistent enum variant usage withSelf::.The refactor from
QuoteStyle::*toSelf::*variants maintains consistency with the codebase style improvements.
490-490: Proper use ofSelfin struct instantiation.Using
Self { ... }instead ofFormatOptions { ... }follows Rust best practices within impl blocks.
560-560: Clean use ofSelf::default().This change improves consistency and follows the pattern established throughout the refactor.
vm/src/stdlib/ast/exception.rs (3)
7-7: Proper use ofSelf::in pattern matching.The change from fully qualified enum variant to
Self::ExceptHandlerimproves code consistency within the impl block.
18-22: Improved constructor formatting withSelf::.The refactor to use
Self::ExceptHandlerwith better multiline formatting enhances both consistency and readability.
35-40: Clean destructuring pattern withSelf.Using
Selfin the destructuring pattern follows Rust idioms and improves code maintainability.vm/src/builtins/module.rs (2)
86-86: Good generalization with&Py<Self>.Changing the parameter type from
&Py<PyModule>to&Py<Self>makes the code more generic and consistent with Rust best practices within impl blocks.
172-172: Consistent constructor usage withSelf::new().Using
Self::new()instead ofPyModule::new()follows the established pattern and improves code consistency.stdlib/src/zlib.rs (4)
121-121: Proper return type generalization.Changing the return type from
PyResult<InitOptions>toPyResult<Self>follows Rust conventions and improves consistency.
130-131: Consistent enum variant usage.Using
Self::StandardandSelf::Gzipinstead of fully qualified variants improves readability within the impl block.
425-426: Excellent trait implementation consistency.The use of
Self::Ok,Self::StreamEnd,Self::None,Self::Finish, andSelf::Syncin trait implementations follows Rust best practices and maintains consistency across the codebase.Also applies to: 434-435, 522-522
517-517: Clean enum comparison withSelf::.Using
Self::StreamEndinstead of the fully qualified variant improves code consistency within the impl block.vm/src/dict_inner.rs (5)
798-798: LGTM! Improved type reference style.Using
Selfinstead of the explicit type name in the unsafe cast is more idiomatic and maintainable.
893-893: LGTM! Consistent use ofSelfin associated type.This change improves code maintainability by using
Selfinstead of the explicit type name.
954-954: LGTM! Consistent use ofSelfin associated type.Using
Selfinstead ofWtf8Bufimproves code consistency and maintainability.
1015-1015: LGTM! Consistent use ofSelfin associated type.The change from
Vec<u8>toSelfenhances code consistency across the DictKey implementations.
1040-1040: LGTM! Consistent use ofSelfin associated type.Using
Selfinstead ofusizemaintains consistency with the codebase-wide refactoring.vm/src/exceptions.rs (4)
550-550: LGTM! Improved constructor return type.Using
Selfinstead of the explicit type name follows Rust conventions and improves code maintainability.
551-551: LGTM! Consistent use ofSelfin struct instantiation.This change aligns with Rust best practices for using
Selfin constructor methods.
691-691: LGTM! Consistent use ofSelfin method call.Using
Self::classinstead of the explicit type improves code consistency and maintainability.
694-694: LGTM! Improved constructor call style.Using
Self::newfollows Rust conventions and enhances code readability within the impl block.vm/src/buffer.rs (4)
30-43: LGTM: Idiomatic use ofSelfin enum implementationThe changes to use
Selffor the return type and enum variant references follow Rust best practices and improve code maintainability.
270-275: LGTM: Constructor usingSelfUsing
Selffor the constructor is the idiomatic Rust approach within impl blocks.
324-340: LGTM: Method signature and constructor improvementsThe use of
Selffor both the return type and constructor follows Rust conventions and makes the code more concise.
547-558: LGTM:Selfusage in trait implementationUsing
Selfinstead of explicitf16type references is more maintainable and follows Rust idioms for trait implementations.vm/src/builtins/dict.rs (6)
66-67: LGTM: Idiomatic downcasting withSelfUsing
Selffor the downcast operation is more maintainable and follows Rust conventions.
190-191: LGTM: Generic downcast withSelfThe use of
Selfin the generic downcast operation is the idiomatic approach.
266-270: LGTM: Method signature and constructor usingSelfBoth the return type and constructor usage of
Selffollow Rust best practices and improve code clarity.
334-334: LGTM: Parameter type usingSelfUsing
Selffor the parameter type is more concise and maintainable.
406-406: LGTM: Downcast result type withSelfThe use of
Selffor the downcast result type follows Rust idioms.
695-697: LGTM: Constructor improvements withSelfBoth the return type and constructor call using
Selfare idiomatic Rust and improve maintainability.vm/src/builtins/type.rs (5)
262-271: Use ofSelfhere is correct and improves readability.The switch from the concrete
PyTypename toSelfinsidePyRef::new_refis totally safe and eliminates repetition without altering semantics.
No additional action required.
307-316: Consistent replacement withSelflooks good.Same comment as above – the static‐type constructor now matches the heap‐type constructor stylistically.
536-538: Iterator helper remains sound afterSelfrefactor.
Option::as_deref()convertsOption<&PyRef<_>>toOption<&Py<_>>, so the signature
impl Iterator<Item = &Self>still compiles cleanly.
448-459:__new__signature updated – behaviour unchanged.The method now accepts
PyRef<Self>instead ofPyRef<PyType>which is idiomatic inside theimplblock and doesn’t affect logic.
489-497: Helpersis_subtype/check_exactmigrated toSelf– good.No functional difference, but this keeps the impl generic-friendly.
vm/src/protocol/object.rs (3)
276-286: Closure signature changed to&Self– safe.All interior calls still expect
&PyObject, so the alias is purely cosmetic.
412-458: Large method body untouched; signature only.
abstract_issubclasskeeps identical control-flow and error paths. ✔️
540-547:real_is_instance→object_isinstancechain unaffected.Just confirming: the switch to
&Selfdoes not change borrow semantics and still satisfies trait bounds (TryFromObjectetc.).vm/src/builtins/bytearray.rs (3)
81-85: Constructor helper now returnsSelf– fine.
from_inneris clearer and gate-keeps the struct invariants as before.
338-360: Padding helpers (center,ljust,rjust,join) converted toSelf.The returned inner value is still wrapped via
.into(), so no semantic drift.
541-543:__mod__keeps behaviour; signature tidied.Nothing to flag – the
%operator still delegates tocformat.vm/src/builtins/bytes.rs (4)
119-119: LGTM: Idiomatic use ofSelfin return type.The change from
PyResult<PyBytes>toPyResult<Self>follows Rust best practices and improves code maintainability.
273-283: LGTM: Consistent use ofSelfin padding method return types.The systematic replacement of
PyResult<PyBytes>withPyResult<Self>across the padding methods (center, ljust, rjust) follows Rust best practices and improves code consistency.
293-466: LGTM: Idiomatic return type improvements.The changes to use
PyResult<Self>instead ofPyResult<PyBytes>in the join, translate, replace, and mod_ methods follow Rust conventions and improve code maintainability.
514-533: LGTM: Appropriate use ofSelfin PyRef implementation.The changes to use
Selfinstead of explicit type references in the bytes, lstrip, and rstrip methods are idiomatic and maintain the same functionality while improving code readability.vm/src/builtins/str.rs (7)
184-184: LGTM: Idiomatic struct instantiation and constructor calls.The changes to use
Selfinstead ofPyStrin struct instantiation and constructor calls follow Rust best practices and improve code maintainability within the impl blocks.Also applies to: 367-373
520-520: LGTM: Consistent use ofSelfin type parameters.The changes to use
Selfinstead ofPyStrin payload() and downcast() method type parameters are idiomatic and maintain the same functionality while improving code consistency.Also applies to: 1338-1338, 1370-1370, 1408-1408
629-629: LGTM: Idiomatic return types for string manipulation methods.The changes to use
Selfinstead ofPyStrin the return types of lower(), upper(), and strip() methods follow Rust conventions and improve code maintainability.Also applies to: 651-651, 768-768
848-848: LGTM: Consistent type annotations in closures.The changes to use
&Py<Self>instead of&Py<PyStr>in closure parameters maintain functionality while following idiomatic Rust style.Also applies to: 868-868
1696-1825: LGTM: Comprehensive use ofSelfin trait implementation.The systematic replacement of
PyStrwithSelfthroughout the SliceableSequenceOp trait implementation, including the type alias and method calls, follows Rust best practices and improves code consistency.
1889-1928: LGTM: Idiomatic associated function calls.The changes to use
Self::prefix for method calls (new, with_capacity, push_str, chars) instead of explicit type names follow Rust conventions and improve code readability.
2002-2128: LGTM: Consistent pattern across all container implementations.The changes to use
Self::prefix in the Wtf8Buf and AsciiString implementations maintain consistency with the established pattern and follow Rust best practices.vm/src/bytes_inner.rs (5)
32-36: PreferSelf– stylistic improvement looks goodReplacing the explicit struct name with
Selfmakes the conversion impl shorter and keeps it in-sync if the type is ever renamed.
551-554: No regression introducedBehaviour is unchanged; signature is now cleaner.
Nothing else to flag.
609-633: Strip helpers – signature polish LGTMThe switch to
Selfin the optional parameters keeps the public API unchanged while reducing verbosity.
636-651: Prefix / suffix helpers – stylistic change onlyNothing behavioural changed; good to merge.
694-712: Partition helpers – looks correct
Selfsubstitution is safe here; no further remarks.
Sorry, something went wrong.
youknowone
left a comment
There was a problem hiding this comment.
👍
Sorry, something went wrong.
69545c0
into
RustPython:main
Jul 4, 2025
Summary by CodeRabbit
Selfinstead of explicit type names for return types, parameter types, and pattern matching.