◐ Shell
clean mode source ↗

Remove Copy from PyPayload by youknowone · Pull Request #6865 · RustPython/RustPython

📝 Walkthrough

Walkthrough

This PR removes Clone and Copy derives from numerous structs and enums across the VM codebase, alongside removing a workspace lint setting, to reduce automatic copy semantics on public types while adding new module creation methods to PyModuleDef.

Changes

Cohort / File(s) Summary
Configuration and workspace
Cargo.toml
Removed missing_copy_implementations = "warn" workspace lint
Builtin singleton and primitive types
crates/vm/src/builtins/singletons.rs, crates/vm/src/builtins/slice.rs, crates/vm/src/builtins/object.rs
Removed Clone, Copy derives from PyNone, PyNotImplemented, PyEllipsis, PyBaseObject
Module definition and related types
crates/vm/src/builtins/module.rs
Removed Clone, Copy from PyModuleDef, PyModuleSlots, PyModule; added public methods create_module() and exec_module() to PyModuleDef for phase-based initialization
Namespace and descriptor types
crates/vm/src/builtins/namespace.rs, crates/vm/src/builtins/descriptor.rs
Changed PyNamespace from unit-like to empty struct and removed Clone, Copy; removed Clone, Copy from MemberGetter, MemberSetter; removed Clone, Copy from MemberKind
Protocol and method types
crates/vm/src/protocol/mapping.rs, crates/vm/src/protocol/sequence.rs, crates/vm/src/protocol/buffer.rs, crates/vm/src/function/method.rs
Removed Clone, Copy from PyMappingMethods, PySequenceMethods, BufferMethods; removed Copy from PyMethodDef and HeapMethodDef
Numeric argument conversion types
crates/vm/src/function/number.rs
Removed Clone, Copy from ArgIntoComplex, ArgIntoFloat, ArgIntoBool
String and collection argument types
crates/vm/src/anystr.rs, crates/vm/src/builtins/zip.rs, crates/vm/src/dict_inner.rs
Removed Clone, Copy from SplitLinesArgs, ExpandTabsArgs, PyZipNewArgs; removed Clone, Copy from DictSize
Utility and sequence types
crates/vm/src/sliceable.rs, crates/vm/src/stdlib/marshal.rs, crates/vm/src/stdlib/os.rs, crates/vm/src/stdlib/typevar.rs, crates/vm/src/stdlib/typing.rs
Removed Clone, Copy from SequenceIndex, SaturatedSliceIter, DumpError, TargetIsDirectory, Generic, NoDefault

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Implement copyslot #6505: Implements copyslot for protocol methods (PyMappingMethods, PySequenceMethods) whose Copy/Clone traits are modified in this PR
  • Apply some clippy lints #6045: Modifies PyNamespace initialization logic in the same file where PyNamespace struct declaration is updated in this PR
  • derive Copy where possible #6844: Inverse operation that adds Copy derives to many of the same types being modified here, creating potential conflicts

Suggested reviewers

  • ShaharNaveh
  • arihant2math

Poem

🐰 Copy no more, we declare with glee,
Traits refined, now lean and free!
Clone removed from every place,
Ownership reclaims its grace.
Modules craft themselves with care—
A tidy codebase, fresh and fair! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove Copy from PyPayload' accurately summarizes the main change in the PR, which is reverting Copy/Clone implementations from PyPayload and all dependent public structs and enums throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.