Use `Self` where possible by ShaharNaveh · Pull Request #5892 · RustPython/RustPython
vm/src/stdlib/ast/string.rs (1)
258-259: LGTM! Excellent use of Self in enum pattern matching.
The replacement of explicit JoinedStrPart:: with Self:: 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 of Self in struct instantiation.
The replacement of explicit PyZip with Self in 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 of Self in constructor method.
The replacement of explicit PyCoroutine with Self in 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 of Self in enum pattern matching.
The replacement of explicit PyArithmeticValue:: with Self:: 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 of Self in constructor method.
The replacement of explicit OncePtr with Self in 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 Self instead of the explicit type name PyGenerator within the impl block is more concise and idiomatic.
vm/src/builtins/enumerate.rs (1)
47-50: LGTM! Improved idiomatic Rust usage.
Using Self instead of the explicit type name PyEnumerate within the impl block is more concise and idiomatic.
stdlib/src/bz2.rs (1)
50-52: LGTM! Improved idiomatic Rust usage.
Using Self::StreamEnd instead of the explicit enum name Status::StreamEnd within 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 name Mode:: 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 name GlobalIdent:: 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 Self instead 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 Self instead 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 Self for 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 of Self for 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 using Self in pattern matching.
The use of Self::A and Self::B instead of explicit Either::A and Either::B follows Rust idioms and enhances code maintainability.
stdlib/src/pyexpat.rs (1)
68-75: LGTM! Idiomatic constructor using Self.
Replacing the explicit struct name with Self in 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 of Self for method calls.
Using Self::new_ref instead of PyTuple::new_ref within 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 using Self.
The change from NativeFunctionOrMethod(...) to Self(...) is a nice stylistic improvement that makes the code more readable and idiomatic.
vm/src/function/number.rs (1)
44-45: Use of Self constructor is clear and idiomatic
Nothing to flag – the swap to Self { value } is correct and keeps the logic unchanged.
compiler/codegen/src/compile.rs (1)
286-286: Excellent use of Self in constructor method.
This change makes the code more concise and idiomatic by using Self instead of the explicit struct name within the impl block. This is the preferred Rust style for constructor methods and improves maintainability.
vm/src/function/buffer.rs (1)
174-176: Idiomatic use of Self – looks good
Replacing the explicit variant path with Self::String is inline with Rust style and keeps the logic unchanged.
vm/src/protocol/buffer.rs (1)
66-72: Constructor call shortened with Self::new – no concerns
The switch from PyBuffer::new to Self::new is purely stylistic within the same impl scope and does not affect behaviour.
common/src/lock/thread_mutex.rs (1)
24-28: Consistent Self usage in constants & ctor
Both the INIT constant and new constructor now use Self for 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 consistently
All 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 of Self in 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 of Self in struct construction.
Using Self { value } instead of PyFloat { value } improves code maintainability and follows Rust idioms.
526-526: LGTM: Consistent generic parameter usage.
The change from payload_if_subclass::<PyFloat> to payload_if_subclass::<Self> aligns with similar patterns used in other builtin types (as seen in vm/src/builtins/list.rs, vm/src/builtins/complex.rs, and vm/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_string instead 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::Spec instead of CFormatPart::Spec in 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 Self in 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 Self in 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 of Self in enum variants.
The replacement of ExecutionResult::Yield and ExecutionResult::Return with Self::Yield and Self::Return is correct and follows Rust best practices for more concise, maintainable code.
52-52: LGTM! Proper use of Self in constructor.
Using Self instead of the explicit struct name Coro in the constructor is idiomatic Rust and improves code maintainability.
vm/src/builtins/super.rs (2)
51-51: LGTM! Correct use of Self in constructor implementation.
Replacing PySuper with Self in the Constructor trait implementation is idiomatic and maintains the same functionality while improving code readability.
208-208: LGTM! Appropriate use of Self in descriptor implementation.
Using Self instead of PySuper in the GetDescriptor trait implementation follows Rust best practices and improves code maintainability.
vm/src/builtins/weakproxy.rs (1)
56-56: LGTM! Idiomatic constructor implementation.
Replacing PyWeakProxy with Self in 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 of Self in FuncArgs implementations.
The replacement of explicit FuncArgs with Self in the From trait implementations and methods improves code consistency and follows Rust idioms.
Also applies to: 90-93, 128-131
253-253: LGTM! Proper use of Self in error conversion.
Using Self::Exception instead of ArgumentError::Exception is idiomatic and maintains the same functionality.
265-281: LGTM! Consistent enum variant usage with Self.
Replacing ArgumentError variants with Self variants in the match expression is correct and improves code maintainability.
348-348: LGTM! Idiomatic Self usage in KwArgs implementations.
The consistent use of Self instead of explicit KwArgs type names across various trait implementations follows Rust best practices.
Also applies to: 362-362, 368-368, 381-381
462-462: LGTM! Proper constructor pattern with Self.
Using Self in the PosArgs constructor is idiomatic and maintains consistency with the codebase improvements.
504-506: LGTM! Correct enum variant usage in OptionalArg.
Replacing explicit OptionalArg variants with Self variants 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 with Self.
Replacing *const PyObject with *const Self in the unique_id method is correct and follows Rust best practices. This change aligns with the pattern used elsewhere in the codebase (as seen in vm/src/object/core.rs) and improves code maintainability.
vm/src/sequence.rs (1)
142-142: Excellent use of Self for improved type genericity.
This change makes the return type more generic and follows Rust best practices by using Self instead of the concrete type Vec<T>.
vm/src/stdlib/ast/type_ignore.rs (1)
11-11: Great use of Self for enum variant references.
Replacing TypeIgnore::TypeIgnore with Self::TypeIgnore makes 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 using Self.
Using Self instead of the explicit isize type makes the cast more self-documenting and consistent with the surrounding codebase.
vm/src/builtins/slice.rs (1)
68-68: Excellent refactoring to use Self in constructors and type annotations.
These changes make the code more maintainable by using Self instead of repeating the PySlice type 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 of Self in trait bounds.
The change correctly uses Self to refer to PyObjectRef (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 of Self in constructor!
Using Self instead of the explicit struct name improves code maintainability and follows Rust best practices.
66-66: Excellent iterator return type improvement!
Using Self as 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 Self in the return type makes the function signature more maintainable and idiomatic.
310-310: Good constructor pattern!
Using Self for 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_new and Self::init instead 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 &Self instead 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 Self instead of the explicit struct name follows Rust conventions and improves maintainability.
168-168: Good return type improvement!
Using Self in the return type makes the function signature cleaner and more maintainable.
183-183: Excellent constructor pattern!
Using Self for struct instantiation within impl blocks is idiomatic Rust and improves code readability.
247-247: Great constructor improvement!
Using Self instead 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 of Self in constructor.
This change improves code maintainability by using the idiomatic Self keyword instead of the explicit struct name in the constructor.
146-146: LGTM! Consistent use of Self::new in method.
Using Self::new instead of the explicit constructor call follows Rust best practices and improves code consistency.
176-179: LGTM! Proper use of Self in constructor.
This change enhances code readability and maintainability by using the Self keyword consistently in the constructor.
219-219: LGTM! Consistent constructor pattern.
Using Self::new maintains consistency with the pattern established in other methods and follows Rust conventions.
370-373: LGTM! Clean constructor implementation.
The use of Self in the constructor improves code clarity and follows idiomatic Rust practices.
406-410: LGTM! Consistent enum variant usage.
Using Self::Shake128 and Self::Shake256 instead of the fully qualified enum paths improves code readability and maintains consistency within the impl block.
Also applies to: 414-418
423-425: LGTM! Consistent pattern matching with Self.
The pattern matching consistently uses Self::Variant syntax, which improves code maintainability and follows Rust best practices for enum handling within impl blocks.
Also applies to: 430-432, 437-439
vm/src/builtins/list.rs (3)
40-43: LGTM! Clean constructor implementation with Self.
Using Self in the From trait implementation improves code readability and follows Rust idioms for constructor patterns.
134-134: LGTM! Consistent use of Self in generic context.
Using Self as 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 the Constructor trait follows Rust conventions and improves code maintainability.
vm/src/builtins/genericalias.rs (3)
71-71: LGTM! Clean constructor trait implementation.
Using Self::new in the Constructor trait implementation improves code consistency and follows Rust best practices for type references within impl blocks.
204-204: LGTM! Consistent constructor usage in method.
The use of Self::new maintains consistency and improves code readability in the __getitem__ method implementation.
599-604: LGTM! Proper use of Self::new in iterator implementation.
Using Self::new for creating the starred alias follows Rust conventions and improves code maintainability in the Iterable trait implementation.
vm/src/builtins/function.rs (6)
81-95: LGTM! Excellent constructor implementation with Self.
Using Self in the constructor improves code readability and maintainability. The implementation follows Rust best practices for struct initialization within impl blocks.
452-452: LGTM! Clean downcast operation with Self.
Using Self in the downcast operation improves type safety and code consistency while maintaining the same functionality.
463-463: LGTM! Consistent type reference with Self.
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::new in the Constructor trait implementation maintains consistency and follows Rust best practices for method calls within impl blocks.
718-718: LGTM! Clean constructor delegation.
Using Self::new in the Constructor trait implementation improves code consistency and readability.
726-726: LGTM! Consistent struct literal with Self.
Using Self in the struct literal follows Rust idioms and improves code maintainability within the impl block.
vm/src/builtins/memory.rs (3)
80-83: Idiomatic use of Self – looks good
Switching to Self::from_buffer keeps the code concise and resilient to future type-renames.
94-104: Consistent struct construction with Self – no issues
The move to Ok(Self { .. }) is purely stylistic and correct.
123-130: new_view refactor complete
Replacing PyMemoryView with Self maintains clarity and adheres to the PR objective.
compiler/codegen/src/ir.rs (3)
14-15: Const definition updated to Self – approved
This change is straightforward and preserves behaviour.
60-64: Default impl now returns Self – approved
The refactor is idiomatic and has no functional impact.
94-111: Destructuring with let Self { .. } – approved
The pattern remains correct and improves readability without altering semantics.
stdlib/src/socket.rs (3)
800-810: LGTM: Idiomatic use of Self in Default implementation
The replacement of PySocket with Self in the constructor follows Rust best practices and improves code maintainability.
1660-1667: LGTM: Proper use of Self in constructor
The change from Address { host, port } to Self { host, port } is idiomatic Rust and improves code consistency within the impl block.
1669-1688: LGTM: Consistent use of Self for associated function call
The replacement of Address::from_tuple with Self::from_tuple maintains consistency with the use of Self throughout the impl block and follows Rust conventions.
vm/src/builtins/asyncgenerator.rs (2)
36-41: LGTM: Idiomatic use of Self in constructor
The replacement of PyAsyncGen with Self in the constructor follows Rust best practices and improves code readability within the impl block.
78-81: LGTM: Proper use of Self in method return type
The change from PyRef<PyAsyncGen> to Self is correct since this method is in an impl PyRef<PyAsyncGen> block, making Self equivalent to PyRef<PyAsyncGen>. This follows Rust idioms and improves maintainability.
vm/src/builtins/range.rs (5)
188-193: Excellent use of Self for struct construction.
This change correctly replaces the explicit PyRange type name with Self within the impl block, making the code more concise and idiomatic.
207-212: Good refactoring to use idiomatic Rust syntax.
Using Self instead of the explicit type name improves code readability and maintainability within impl blocks.
299-305: Correct usage of Self for struct construction.
The change from PyRange { ... } to Self { ... } is appropriate and follows Rust conventions.
318-322: Proper use of Self:: for associated functions.
These changes correctly replace PyRange::new and PyRange::new_from with Self::new and Self::new_from respectively.
700-708: Excellent enum variant refactoring.
The changes from RangeIndex::Int and RangeIndex::Slice to Self::Int and Self::Slice are correct and make the code more concise within the TryFromObject implementation.
stdlib/src/select.rs (4)
149-150: Good use of Self for struct construction.
Replacing Selectable { obj, fno } with Self { 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 and Self(fdset) for tuple struct construction.
443-444: Proper tuple struct construction with Self.
The change from EventMask(mask) to Self(mask) correctly uses the Self keyword for tuple struct construction.
605-606: Clean struct construction using Self.
This change improves code consistency by using Self instead of the explicit PyEpoll type name.
stdlib/src/contextvars.rs (3)
153-154: Excellent use of Self for associated function call.
Replacing PyContext::empty(vm) with Self::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 with Self.
The change from ContextVar { ... } to Self { ... } follows Rust conventions for struct construction within impl blocks.
vm/src/object/traverse_object.rs (2)
20-31: Correct use of Self in const context.
Replacing PyObjVTable { ... } with Self { ... } is appropriate and works correctly in const contexts.
52-53: Proper type cast using Self.
The change from PyInner<Erased> to Self in 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. to Self::Nfc, Self::Nfkc, etc. are correct and make the code more concise.
224-230: Clean enum pattern matching with Self::.
Replacing the explicit EastAsianWidth:: qualifiers with Self:: improves readability and follows Rust conventions for pattern matching within impl blocks.
vm/src/codecs.rs (3)
45-45: Excellent use of Self for improved idiomatic Rust style!
Using Self(tuple) instead of PyCodec(tuple) makes the code more maintainable and follows Rust best practices.
142-142: Good consistency in using Self for method calls.
The change to Self::from_tuple maintains consistency with the other Self usage 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 of PyResult<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 the PyResult<Self> return type change above.
122-124: Great improvement to enum variant references!
Using Self::Path and Self::Fd instead of the fully qualified OsPathOrFd:: 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 of Option<ParameterKind> makes the method signature more idiomatic and maintainable.
19-22: Perfect enum variant style improvements!
Replacing ParameterKind:: with Self:: 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 using Self in return types within impl blocks.
55-59: Great constructor consistency with the return type changes.
Using Self { ... } for the constructor aligns perfectly with the Option<Result<Self>> return type improvement.
vm/src/function/protocol.rs (3)
53-53: Excellent trait implementation improvement!
Using Self in the From trait 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 Self in both From trait 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 the From trait implementation is more idiomatic and maintainable than the explicit type name.
164-164: Great use of Self in 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 Self in 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 other Self improvements and enhances maintainability.
vm/src/builtins/code.rs (3)
205-207: LGTM: Idiomatic use of Self in constructor
The change from explicit PyCode to Self in both the return type and struct instantiation follows Rust best practices for impl blocks.
338-338: LGTM: Consistent use of Self in return type
The return type change from PyResult<PyCode> to PyResult<Self> is idiomatic and maintains consistency with the constructor pattern.
395-421: LGTM: Proper use of Self in struct instantiation
The struct instantiation using Self instead of explicit PyCode is more concise and follows Rust conventions within impl blocks.
vm/src/frame.rs (3)
145-145: LGTM: Idiomatic use of Self in constructor return type
The change from explicit Frame to Self in the return type follows Rust best practices for impl blocks.
158-171: LGTM: Consistent struct instantiation with Self
Using Self instead of explicit Frame in the struct instantiation is more concise and idiomatic within impl blocks.
2288-2288: LGTM: Proper use of Self in generic type parameter
The change from elem.payload_is::<Frame>() to elem.payload_is::<Self>() maintains correctness while following the consistent pattern of using Self throughout the codebase.
vm/src/builtins/int.rs (1)
226-226: Excellent use of Self keyword for improved code consistency.
The systematic replacement of explicit PyInt type references with Self throughout the implementation significantly improves code maintainability and follows Rust idiomatic patterns. All changes are correctly applied within impl PyInt blocks where Self appropriately 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 using Self keyword.
The changes appropriately replace explicit type names with Self in constructors, enum variant patterns, and type annotations. This enhances code maintainability and follows Rust best practices for code within impl blocks.
Also applies to: 90-95, 157-163, 296-296
vm/src/scope.rs (1)
19-22: Proper application of Self keyword in method signatures and constructors.
The changes correctly replace explicit Scope type references with Self in return types and constructors, improving code consistency and following Rust idiomatic patterns within the impl block.
Also applies to: 28-35
common/src/boxvec.rs (1)
41-46: Consistent and correct use of Self keyword throughout.
The changes systematically replace explicit type names with Self in constructors and return types for both BoxVec<T> and CapacityError<T>. This improves code maintainability and follows Rust idiomatic practices within impl blocks.
Also applies to: 596-596, 679-681
common/src/lock/cell_lock.rs (1)
14-16: LGTM! Excellent use of Self in const declarations.
These changes properly replace explicit type names with Self in 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 with Self.
The From trait implementation is correctly generalized to use PyIter<Self> instead of the explicit PyIter<PyObjectRef>, making it more flexible and idiomatic.
135-135: LGTM! Appropriate use of Self::check.
Using Self::check instead of PyIter::check is correct within the TryFromObject implementation context and improves readability.
163-164: LGTM! Clean enum variant pattern matching.
Replacing explicit PyIterReturn:: prefixes with Self:: 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 of Self in 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 Self as the return type is more idiomatic and consistent with Rust conventions.
derive-impl/src/error.rs (4)
78-85: LGTM! Consistent use of Self in constructor.
The error method properly uses Self for both return type and struct construction, improving code consistency.
87-94: LGTM! Clean method signature and construction.
The spans_error method correctly uses Self throughout, making it more concise and idiomatic.
96-104: LGTM! Proper use of Self in generic contexts.
The from_vec method appropriately uses Self in both the parameter type Vec<Self> and return type, maintaining semantic correctness.
116-120: LGTM! Idiomatic trait implementation.
The From<Error> trait implementation correctly uses Self for 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_constant properly uses Self:: prefixes for enum variants, making the code more concise and maintainable.
139-148: LGTM! Consistent flag constant definitions.
The NAME_MAPPING constant correctly uses Self:: prefixes for the flag values, improving readability and maintainability.
157-158: LGTM! Idiomatic constructor implementations.
The null() and marker() methods properly use Self in constructor calls, following Rust conventions for associated functions.
Also applies to: 172-173, 284-285
336-337: LGTM! Proper OpArgType trait implementations.
The trait implementations correctly use Self for constructor calls and enum variants, improving code consistency.
Also applies to: 354-358
634-637: LGTM! Clean trait implementations.
The From and TryFrom trait implementations properly use Self for 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_bits instead of the explicit type name is more idiomatic and maintainable.
compiler/src/lib.rs (1)
60-62: Good use of Self for enum variants
Replacing the fully-qualified names with Self::{Codegen, Parse} inside the impl CompileError block 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 via as Self remains correct
The switch from explicit u8 casts to as Self keeps the impl From<MachineFormatCode> for u8 concise while preserving the original logic.
vm/src/builtins/set.rs (4)
85-89: LGTM: Idiomatic use of Self in Default implementation.
The replacement of PyFrozenSet with Self in the struct construction is more concise and follows Rust best practices.
214-218: LGTM: Consistent use of Self in 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 Self across 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 with Self.
The TryFromObject implementation now uses idiomatic Self construction.
common/src/format.rs (5)
41-58: LGTM: Excellent enum method refactoring.
The conversion from explicit FormatConversion variants to Self:: variants in both from_char and from_string methods demonstrates consistent application of idiomatic Rust patterns.
70-78: LGTM: Clean FormatAlign implementation.
The method signature and variant references now use Self consistently, improving code readability.
144-144: LGTM: Proper trait implementation with Self.
The From trait implementation correctly uses Self as the return type, following Rust conventions.
302-312: LGTM: Comprehensive FormatSpec construction.
The struct construction using Self maintains 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:: and FormatParseError::) with Self:: 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 of Self in pattern matching.
The pattern matching update from explicit StrKind:: variants to Self:: variants is idiomatic and improves code conciseness while maintaining identical functionality.
common/src/refcount.rs (1)
24-26: LGTM: Idiomatic use of Self in constructor.
Using Self instead of the explicit RefCount type name in the constructor follows Rust best practices and improves maintainability.
vm/src/builtins/object.rs (1)
72-72: LGTM: Consistent use of Self with PyRef::new_ref pattern.
The change to use Self instead of PyBaseObject is consistent with the pattern used throughout the codebase for PyRef::new_ref calls, as seen in similar constructors across other builtin types.
vm/src/protocol/sequence.rs (1)
53-62: LGTM: Improved constant declaration with Self.
Using Self instead of the explicit PySequenceMethods type 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 with Self.
Using Self instead of the explicit CStrPathLike type name in the constructor is more concise and follows Rust best practices.
179-181: LGTM: Clean pattern matching with Self.
The pattern matching update from explicit ExecErrorContext:: variants to Self:: variants improves code readability and follows idiomatic Rust style within impl blocks.
vm/src/protocol/mapping.rs (1)
44-44: Excellent use of Self for improved consistency.
This change properly uses Self instead 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 of Self in trait implementation.
Using Self instead of the explicit bool type 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 of Self in constructor.
Using Self instead of the explicit LinkedList<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 with Self in the constructor follows Rust best practices and improves code consistency.
vm/src/protocol/number.rs (2)
162-162: Excellent use of Self in constant declaration.
Using Self instead of the explicit PyNumberMethods type in the constant declaration is more idiomatic and improves code maintainability.
200-200: Good improvement in function return type.
Replacing &'static PyNumberMethods with &'static Self follows Rust best practices and makes the code more consistent.
vm/src/stdlib/ast/statement.rs (3)
7-34: Excellent use of Self in pattern matching.
The consistent replacement of ruff::Stmt:: with Self:: in all match arms makes the code more idiomatic and easier to maintain. This change properly leverages Rust's Self keyword within the impl block.
45-159: Good improvement in constructor calls.
Using Self:: instead of ruff::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 of Self in struct destructuring and construction.
The consistent replacement of explicit struct names with Self in 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 of Self in constructor method.
The change from PyDialect::try_from_object to Self::try_from_object improves code consistency and follows Rust idioms within impl blocks.
428-432: Great consistency improvement with Self:: enum variants.
Using Self::Always, Self::NonNumeric, and Self::Never instead of fully qualified variants makes the code more concise and maintainable within the impl block.
447-456: Consistent enum variant usage with Self::.
The refactor from QuoteStyle::* to Self::* variants maintains consistency with the codebase style improvements.
490-490: Proper use of Self in struct instantiation.
Using Self { ... } instead of FormatOptions { ... } follows Rust best practices within impl blocks.
560-560: Clean use of Self::default().
This change improves consistency and follows the pattern established throughout the refactor.
vm/src/stdlib/ast/exception.rs (3)
7-7: Proper use of Self:: in pattern matching.
The change from fully qualified enum variant to Self::ExceptHandler improves code consistency within the impl block.
18-22: Improved constructor formatting with Self::.
The refactor to use Self::ExceptHandler with better multiline formatting enhances both consistency and readability.
35-40: Clean destructuring pattern with Self.
Using Self in 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 with Self::new().
Using Self::new() instead of PyModule::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> to PyResult<Self> follows Rust conventions and improves consistency.
130-131: Consistent enum variant usage.
Using Self::Standard and Self::Gzip instead 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, and Self::Sync in trait implementations follows Rust best practices and maintains consistency across the codebase.
Also applies to: 434-435, 522-522
517-517: Clean enum comparison with Self::.
Using Self::StreamEnd instead 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 Self instead of the explicit type name in the unsafe cast is more idiomatic and maintainable.
893-893: LGTM! Consistent use of Self in associated type.
This change improves code maintainability by using Self instead of the explicit type name.
954-954: LGTM! Consistent use of Self in associated type.
Using Self instead of Wtf8Buf improves code consistency and maintainability.
1015-1015: LGTM! Consistent use of Self in associated type.
The change from Vec<u8> to Self enhances code consistency across the DictKey implementations.
1040-1040: LGTM! Consistent use of Self in associated type.
Using Self instead of usize maintains consistency with the codebase-wide refactoring.
vm/src/exceptions.rs (4)
550-550: LGTM! Improved constructor return type.
Using Self instead of the explicit type name follows Rust conventions and improves code maintainability.
551-551: LGTM! Consistent use of Self in struct instantiation.
This change aligns with Rust best practices for using Self in constructor methods.
691-691: LGTM! Consistent use of Self in method call.
Using Self::class instead of the explicit type improves code consistency and maintainability.
694-694: LGTM! Improved constructor call style.
Using Self::new follows Rust conventions and enhances code readability within the impl block.
vm/src/buffer.rs (4)
30-43: LGTM: Idiomatic use of Self in enum implementation
The changes to use Self for the return type and enum variant references follow Rust best practices and improve code maintainability.
270-275: LGTM: Constructor using Self
Using Self for the constructor is the idiomatic Rust approach within impl blocks.
324-340: LGTM: Method signature and constructor improvements
The use of Self for both the return type and constructor follows Rust conventions and makes the code more concise.
547-558: LGTM: Self usage in trait implementation
Using Self instead of explicit f16 type references is more maintainable and follows Rust idioms for trait implementations.
vm/src/builtins/dict.rs (6)
66-67: LGTM: Idiomatic downcasting with Self
Using Self for the downcast operation is more maintainable and follows Rust conventions.
190-191: LGTM: Generic downcast with Self
The use of Self in the generic downcast operation is the idiomatic approach.
266-270: LGTM: Method signature and constructor using Self
Both the return type and constructor usage of Self follow Rust best practices and improve code clarity.
334-334: LGTM: Parameter type using Self
Using Self for the parameter type is more concise and maintainable.
406-406: LGTM: Downcast result type with Self
The use of Self for the downcast result type follows Rust idioms.
695-697: LGTM: Constructor improvements with Self
Both the return type and constructor call using Self are idiomatic Rust and improve maintainability.
vm/src/builtins/type.rs (5)
262-271: Use of Self here is correct and improves readability.
The switch from the concrete PyType name to Self inside PyRef::new_ref is totally safe and eliminates repetition without altering semantics.
No additional action required.
307-316: Consistent replacement with Self looks good.
Same comment as above – the static‐type constructor now matches the heap‐type constructor stylistically.
536-538: Iterator helper remains sound after Self refactor.
Option::as_deref() converts Option<&PyRef<_>> to Option<&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 of PyRef<PyType> which is idiomatic inside the impl block and doesn’t affect logic.
489-497: Helpers is_subtype / check_exact migrated to Self – 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_issubclass keeps identical control-flow and error paths. ✔️
540-547: real_is_instance → object_isinstance chain unaffected.
Just confirming: the switch to &Self does not change borrow semantics and still satisfies trait bounds (TryFromObject etc.).
vm/src/builtins/bytearray.rs (3)
81-85: Constructor helper now returns Self – fine.
from_inner is clearer and gate-keeps the struct invariants as before.
338-360: Padding helpers (center, ljust, rjust, join) converted to Self.
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 to cformat.
vm/src/builtins/bytes.rs (4)
119-119: LGTM: Idiomatic use of Self in return type.
The change from PyResult<PyBytes> to PyResult<Self> follows Rust best practices and improves code maintainability.
273-283: LGTM: Consistent use of Self in padding method return types.
The systematic replacement of PyResult<PyBytes> with PyResult<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 of PyResult<PyBytes> in the join, translate, replace, and mod_ methods follow Rust conventions and improve code maintainability.
514-533: LGTM: Appropriate use of Self in PyRef implementation.
The changes to use Self instead 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 Self instead of PyStr in 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 of Self in type parameters.
The changes to use Self instead of PyStr in 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 Self instead of PyStr in 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 of Self in trait implementation.
The systematic replacement of PyStr with Self throughout 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: Prefer Self – stylistic improvement looks good
Replacing the explicit struct name with Self makes the conversion impl shorter and keeps it in-sync if the type is ever renamed.
551-554: No regression introduced
Behaviour is unchanged; signature is now cleaner.
Nothing else to flag.
609-633: Strip helpers – signature polish LGTM
The switch to Self in the optional parameters keeps the public API unchanged while reducing verbosity.
636-651: Prefix / suffix helpers – stylistic change only
Nothing behavioural changed; good to merge.
694-712: Partition helpers – looks correct
Self substitution is safe here; no further remarks.