From d8a73ead425784ea092a4e23558e63edc27c03ff Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Wed, 30 Sep 2020 11:33:22 -0500 Subject: [PATCH] Make it unnecessary to import PyClassImpl for #[pymodule] --- derive/src/pymodule.rs | 2 +- vm/src/stdlib/collections.rs | 4 +--- vm/src/stdlib/hashlib.rs | 2 +- vm/src/stdlib/itertools.rs | 4 ++-- vm/src/stdlib/json.rs | 4 +--- vm/src/stdlib/os.rs | 2 +- vm/src/stdlib/pystruct.rs | 2 +- vm/src/stdlib/random.rs | 2 +- vm/src/stdlib/symtable.rs | 2 +- vm/src/stdlib/zlib.rs | 2 +- 10 files changed, 11 insertions(+), 15 deletions(-) diff --git a/derive/src/pymodule.rs b/derive/src/pymodule.rs index dac4871967..b861f95656 100644 --- a/derive/src/pymodule.rs +++ b/derive/src/pymodule.rs @@ -318,7 +318,7 @@ impl ModuleItem for ClassItem { .optional_name() .unwrap_or_else(|| class_name.clone()); let new_class = quote_spanned!(ident.span() => - #ident::make_class(&vm.ctx); + <#ident as ::rustpython_vm::pyobject::PyClassImpl>::make_class(&vm.ctx); ); let item = quote! { let new_class = #new_class; diff --git a/vm/src/stdlib/collections.rs b/vm/src/stdlib/collections.rs index 78cba3bd79..49363863d1 100644 --- a/vm/src/stdlib/collections.rs +++ b/vm/src/stdlib/collections.rs @@ -5,9 +5,7 @@ mod _collections { use crate::common::cell::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard}; use crate::function::OptionalArg; use crate::obj::{objiter, objsequence, objtype::PyTypeRef}; - use crate::pyobject::{ - PyClassImpl, PyComparisonValue, PyIterable, PyObjectRef, PyRef, PyResult, PyValue, - }; + use crate::pyobject::{PyComparisonValue, PyIterable, PyObjectRef, PyRef, PyResult, PyValue}; use crate::sequence; use crate::slots::{Comparable, PyComparisonOp}; use crate::vm::ReprGuard; diff --git a/vm/src/stdlib/hashlib.rs b/vm/src/stdlib/hashlib.rs index 645dd4a3f5..9a83fda5ab 100644 --- a/vm/src/stdlib/hashlib.rs +++ b/vm/src/stdlib/hashlib.rs @@ -7,7 +7,7 @@ mod hashlib { use crate::obj::objbytes::{PyBytes, PyBytesRef}; use crate::obj::objstr::PyStrRef; use crate::obj::objtype::PyTypeRef; - use crate::pyobject::{BorrowValue, PyClassImpl, PyResult, PyValue}; + use crate::pyobject::{BorrowValue, PyResult, PyValue}; use crate::vm::VirtualMachine; use std::fmt; diff --git a/vm/src/stdlib/itertools.rs b/vm/src/stdlib/itertools.rs index c9b89402bd..79aef6edf1 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -17,8 +17,8 @@ mod decl { use crate::obj::objtuple::PyTupleRef; use crate::obj::objtype::{self, PyTypeRef}; use crate::pyobject::{ - BorrowValue, IdProtocol, IntoPyRef, PyCallable, PyClassImpl, PyObjectRc, PyObjectRef, - PyObjectWeak, PyRef, PyResult, PyValue, TypeProtocol, + BorrowValue, IdProtocol, IntoPyRef, PyCallable, PyObjectRc, PyObjectRef, PyObjectWeak, + PyRef, PyResult, PyValue, TypeProtocol, }; use crate::vm::VirtualMachine; diff --git a/vm/src/stdlib/json.rs b/vm/src/stdlib/json.rs index 58fb721afb..52c207e12b 100644 --- a/vm/src/stdlib/json.rs +++ b/vm/src/stdlib/json.rs @@ -7,9 +7,7 @@ mod _json { use crate::obj::objiter; use crate::obj::objstr::PyStrRef; use crate::obj::{objbool, objtype::PyTypeRef}; - use crate::pyobject::{ - BorrowValue, IdProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, - }; + use crate::pyobject::{BorrowValue, IdProtocol, PyObjectRef, PyRef, PyResult, PyValue}; use crate::slots::Callable; use crate::VirtualMachine; diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index d0dfc7618f..2c27cdc3fa 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -23,7 +23,7 @@ use crate::obj::objstr::{PyStr, PyStrRef}; use crate::obj::objtuple::PyTupleRef; use crate::obj::objtype::PyTypeRef; use crate::pyobject::{ - BorrowValue, Either, IntoPyObject, ItemProtocol, PyClassImpl, PyObjectRef, PyRef, PyResult, + BorrowValue, Either, IntoPyObject, ItemProtocol, PyObjectRef, PyRef, PyResult, PyStructSequence, PyValue, TryFromObject, TypeProtocol, }; use crate::vm::VirtualMachine; diff --git a/vm/src/stdlib/pystruct.rs b/vm/src/stdlib/pystruct.rs index 0e65942912..0d48c0220c 100644 --- a/vm/src/stdlib/pystruct.rs +++ b/vm/src/stdlib/pystruct.rs @@ -30,7 +30,7 @@ mod _struct { objtuple::PyTupleRef, objtype::PyTypeRef, }; use crate::pyobject::{ - BorrowValue, Either, PyClassImpl, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, + BorrowValue, Either, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, }; use crate::VirtualMachine; diff --git a/vm/src/stdlib/random.rs b/vm/src/stdlib/random.rs index 1570ebf3f7..ada308eb9a 100644 --- a/vm/src/stdlib/random.rs +++ b/vm/src/stdlib/random.rs @@ -8,7 +8,7 @@ mod _random { use crate::function::OptionalOption; use crate::obj::objint::PyIntRef; use crate::obj::objtype::PyTypeRef; - use crate::pyobject::{BorrowValue, PyClassImpl, PyRef, PyResult, PyValue}; + use crate::pyobject::{BorrowValue, PyRef, PyResult, PyValue}; use crate::VirtualMachine; use num_bigint::{BigInt, Sign}; use num_traits::Signed; diff --git a/vm/src/stdlib/symtable.rs b/vm/src/stdlib/symtable.rs index 819c75910d..311184cca4 100644 --- a/vm/src/stdlib/symtable.rs +++ b/vm/src/stdlib/symtable.rs @@ -6,7 +6,7 @@ mod decl { use crate::obj::objstr::PyStrRef; use crate::obj::objtype::PyTypeRef; - use crate::pyobject::{BorrowValue, PyClassImpl, PyRef, PyResult, PyValue}; + use crate::pyobject::{BorrowValue, PyRef, PyResult, PyValue}; use crate::vm::VirtualMachine; use rustpython_compiler::{compile, error::CompileError, symboltable}; use rustpython_parser::parser; diff --git a/vm/src/stdlib/zlib.rs b/vm/src/stdlib/zlib.rs index 1d0f702153..a46e25bee6 100644 --- a/vm/src/stdlib/zlib.rs +++ b/vm/src/stdlib/zlib.rs @@ -8,7 +8,7 @@ mod decl { use crate::function::OptionalArg; use crate::obj::objbytes::{PyBytes, PyBytesRef}; use crate::obj::objtype::PyTypeRef; - use crate::pyobject::{BorrowValue, IntoPyRef, PyClassImpl, PyResult, PyValue}; + use crate::pyobject::{BorrowValue, IntoPyRef, PyResult, PyValue}; use crate::types::create_type; use crate::vm::VirtualMachine;