mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Remove Copy from PyPayload
This commit is contained in:
@@ -222,7 +222,6 @@ wasm-bindgen = "0.2.106"
|
||||
unsafe_code = "allow"
|
||||
unsafe_op_in_unsafe_fn = "deny"
|
||||
elided_lifetimes_in_paths = "warn"
|
||||
missing_copy_implementations = "warn"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
# alloc_instead_of_core = "warn"
|
||||
|
||||
@@ -16,13 +16,13 @@ pub struct SplitArgs<T: TryFromObject> {
|
||||
maxsplit: isize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, FromArgs)]
|
||||
#[derive(FromArgs)]
|
||||
pub struct SplitLinesArgs {
|
||||
#[pyarg(any, default = false)]
|
||||
pub keepends: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, FromArgs)]
|
||||
#[derive(FromArgs)]
|
||||
pub struct ExpandTabsArgs {
|
||||
#[pyarg(any, default = 8)]
|
||||
tabsize: isize,
|
||||
|
||||
@@ -168,7 +168,7 @@ impl Representable for PyMethodDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub enum MemberKind {
|
||||
Bool = 14,
|
||||
ObjectEx = 16,
|
||||
@@ -176,13 +176,11 @@ pub enum MemberKind {
|
||||
|
||||
pub type MemberSetterFunc = Option<fn(&VirtualMachine, PyObjectRef, PySetterValue) -> PyResult<()>>;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum MemberGetter {
|
||||
Getter(fn(&VirtualMachine, PyObjectRef) -> PyResult),
|
||||
Offset(usize),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum MemberSetter {
|
||||
Setter(MemberSetterFunc),
|
||||
Offset(usize),
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[pyclass(module = false, name = "module")]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct PyModuleDef {
|
||||
// pub index: usize,
|
||||
pub name: &'static PyStrInterned,
|
||||
@@ -26,7 +26,7 @@ pub type ModuleCreate =
|
||||
fn(&VirtualMachine, &PyObject, &'static PyModuleDef) -> PyResult<PyRef<PyModule>>;
|
||||
pub type ModuleExec = fn(&VirtualMachine, &Py<PyModule>) -> PyResult<()>;
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
#[derive(Default)]
|
||||
pub struct PyModuleSlots {
|
||||
pub create: Option<ModuleCreate>,
|
||||
pub exec: Option<ModuleExec>,
|
||||
@@ -83,7 +83,7 @@ impl PyModuleDef {
|
||||
|
||||
#[allow(clippy::new_without_default)] // avoid Default implementation
|
||||
#[pyclass(module = false, name = "module")]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct PyModule {
|
||||
// PyObject *md_dict;
|
||||
pub def: Option<&'static PyModuleDef>,
|
||||
|
||||
@@ -14,8 +14,8 @@ use crate::{
|
||||
///
|
||||
/// SimpleNamespace(**kwargs)
|
||||
#[pyclass(module = "types", name = "SimpleNamespace")]
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub struct PyNamespace;
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PyNamespace {}
|
||||
|
||||
impl PyPayload for PyNamespace {
|
||||
#[inline]
|
||||
|
||||
@@ -18,7 +18,7 @@ use itertools::Itertools;
|
||||
/// When called, it accepts no arguments and returns a new featureless
|
||||
/// instance that has no instance attributes and cannot be given any.
|
||||
#[pyclass(module = false, name = "object")]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct PyBaseObject;
|
||||
|
||||
impl PyPayload for PyBaseObject {
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[pyclass(module = false, name = "NoneType")]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct PyNone;
|
||||
|
||||
impl PyPayload for PyNone {
|
||||
@@ -75,7 +75,7 @@ impl AsNumber for PyNone {
|
||||
}
|
||||
|
||||
#[pyclass(module = false, name = "NotImplementedType")]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct PyNotImplemented;
|
||||
|
||||
impl PyPayload for PyNotImplemented {
|
||||
|
||||
@@ -301,7 +301,7 @@ impl Representable for PySlice {
|
||||
}
|
||||
|
||||
#[pyclass(module = false, name = "EllipsisType")]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct PyEllipsis;
|
||||
|
||||
impl PyPayload for PyEllipsis {
|
||||
|
||||
@@ -24,7 +24,7 @@ impl PyPayload for PyZip {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, FromArgs)]
|
||||
#[derive(FromArgs)]
|
||||
pub struct PyZipNewArgs {
|
||||
#[pyarg(named, optional)]
|
||||
strict: OptionalArg<bool>,
|
||||
|
||||
@@ -124,7 +124,7 @@ struct DictEntry<T> {
|
||||
}
|
||||
static_assertions::assert_eq_size!(DictEntry<PyObjectRef>, Option<DictEntry<PyObjectRef>>);
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct DictSize {
|
||||
indices_size: usize,
|
||||
pub entries_size: usize,
|
||||
|
||||
@@ -63,7 +63,7 @@ macro_rules! define_methods {
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone)]
|
||||
pub struct PyMethodDef {
|
||||
pub name: &'static str, // TODO: interned
|
||||
pub func: &'static dyn PyNativeFn,
|
||||
@@ -270,7 +270,7 @@ impl core::fmt::Debug for PyMethodDef {
|
||||
// This is not a part of CPython API.
|
||||
// But useful to support dynamically generated methods
|
||||
#[pyclass(name, module = false, ctx = "method_def")]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct HeapMethodDef {
|
||||
method: PyMethodDef,
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use num_traits::PrimInt;
|
||||
/// method, this method will first be called to convert the object into a float.
|
||||
/// If `__complex__()` is not defined then it falls back to `__float__()`. If
|
||||
/// `__float__()` is not defined it falls back to `__index__()`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct ArgIntoComplex {
|
||||
value: Complex64,
|
||||
@@ -52,7 +52,7 @@ impl TryFromObject for ArgIntoComplex {
|
||||
/// If the object is not a Python floating point object but has a `__float__()`
|
||||
/// method, this method will first be called to convert the object into a float.
|
||||
/// If `__float__()` is not defined then it falls back to `__index__()`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct ArgIntoFloat {
|
||||
value: f64,
|
||||
@@ -95,7 +95,7 @@ impl TryFromObject for ArgIntoFloat {
|
||||
/// By default an object is considered true unless its class defines either a
|
||||
/// `__bool__()` method that returns False or a `__len__()` method that returns
|
||||
/// zero, when called with the object.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
pub struct ArgIntoBool {
|
||||
value: bool,
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ use alloc::borrow::Cow;
|
||||
use core::{fmt::Debug, ops::Range};
|
||||
use itertools::Itertools;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct BufferMethods {
|
||||
pub obj_bytes: fn(&PyBuffer) -> BorrowedValue<'_, [u8]>,
|
||||
pub obj_bytes_mut: fn(&PyBuffer) -> BorrowedValueMut<'_, [u8]>,
|
||||
|
||||
@@ -48,7 +48,7 @@ impl PyMappingSlots {
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
#[derive(Default)]
|
||||
pub struct PyMappingMethods {
|
||||
pub length: Option<fn(PyMapping<'_>, &VirtualMachine) -> PyResult<usize>>,
|
||||
pub subscript: Option<fn(PyMapping<'_>, &PyObject, &VirtualMachine) -> PyResult>,
|
||||
|
||||
@@ -70,7 +70,7 @@ impl PySequenceSlots {
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
#[derive(Default)]
|
||||
pub struct PySequenceMethods {
|
||||
pub length: Option<fn(PySequence<'_>, &VirtualMachine) -> PyResult<usize>>,
|
||||
pub concat: Option<fn(PySequence<'_>, &PyObject, &VirtualMachine) -> PyResult>,
|
||||
|
||||
@@ -252,7 +252,6 @@ impl<T: Clone> SliceableSequenceOp for [T] {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum SequenceIndex {
|
||||
Int(isize),
|
||||
Slice(SaturatedSlice),
|
||||
@@ -404,7 +403,6 @@ impl SaturatedSlice {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct SaturatedSliceIter {
|
||||
index: isize,
|
||||
step: isize,
|
||||
|
||||
@@ -25,7 +25,6 @@ mod decl {
|
||||
#[pyattr(name = "version")]
|
||||
use marshal::FORMAT_VERSION;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct DumpError;
|
||||
|
||||
impl marshal::Dumpable for PyObjectRef {
|
||||
|
||||
@@ -35,7 +35,7 @@ impl crate::convert::IntoPyException for rustix::io::Errno {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(FromArgs, Default, Copy, Clone)]
|
||||
#[derive(FromArgs, Default)]
|
||||
pub struct TargetIsDirectory {
|
||||
#[pyarg(any, default = false)]
|
||||
pub(crate) target_is_directory: bool,
|
||||
|
||||
@@ -988,7 +988,7 @@ pub(crate) mod typevar {
|
||||
|
||||
#[pyattr]
|
||||
#[pyclass(name = "Generic", module = "typing")]
|
||||
#[derive(Copy, Clone, Debug, PyPayload)]
|
||||
#[derive(Debug, PyPayload)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Generic;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ pub(crate) mod decl {
|
||||
}
|
||||
|
||||
#[pyclass(no_attr, name = "NoDefaultType", module = "typing")]
|
||||
#[derive(Clone, Copy, Debug, PyPayload)]
|
||||
#[derive(Debug, PyPayload)]
|
||||
pub struct NoDefault;
|
||||
|
||||
#[pyclass(with(Constructor, Representable), flags(BASETYPE))]
|
||||
|
||||
Reference in New Issue
Block a user