From 4d8ffc70ad7c82aeae2356e4611a1abbf66c97d0 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sat, 22 Aug 2020 13:41:35 -0500 Subject: [PATCH 1/4] Just use normal Box for PyNativeFunc --- Cargo.lock | 7 ----- derive/src/pyclass.rs | 2 +- vm/Cargo.toml | 1 - vm/src/function.rs | 63 ++++++++++++++++++++++++----------------- vm/src/lib.rs | 5 ---- vm/src/obj/objgetset.rs | 14 ++++----- vm/src/slots.rs | 4 +-- 7 files changed, 47 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b62146d3..b6e0b56be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1444,7 +1444,6 @@ dependencies = [ "sha-1", "sha2", "sha3", - "smallbox", "socket2", "statrs", "thread_local", @@ -1625,12 +1624,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" -[[package]] -name = "smallbox" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa0eec6425219a55511a35afac416a2eecc62f5fa1bec14f9b97de0caa7daebe" - [[package]] name = "smallvec" version = "1.4.1" diff --git a/derive/src/pyclass.rs b/derive/src/pyclass.rs index 6e4a0491c..318ada91a 100644 --- a/derive/src/pyclass.rs +++ b/derive/src/pyclass.rs @@ -272,7 +272,7 @@ fn extract_impl_items(mut items: Vec) -> Result #transform(Self::#item_ident) diff --git a/vm/Cargo.toml b/vm/Cargo.toml index 5d0481834..0e49c65d4 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -69,7 +69,6 @@ is-macro = "0.1" result-like = "^0.2.1" foreign-types-shared = "0.1" num_enum = "0.4" -smallbox = "0.8" bstr = "0.2.12" crossbeam-utils = "0.7" generational-arena = "0.2" diff --git a/vm/src/function.rs b/vm/src/function.rs index 458cff2fa..591f70f70 100644 --- a/vm/src/function.rs +++ b/vm/src/function.rs @@ -4,7 +4,6 @@ use std::ops::RangeInclusive; use indexmap::IndexMap; use result_like::impl_option_like; -use smallbox::{smallbox, space::S1, SmallBox}; use crate::exceptions::PyBaseExceptionRef; use crate::obj::objtuple::PyTupleRef; @@ -477,12 +476,15 @@ tuple_from_py_func_args!(A, B, C, D); tuple_from_py_func_args!(A, B, C, D, E); tuple_from_py_func_args!(A, B, C, D, E, F); -/// A container that can hold a `dyn Fn*` trait object, but doesn't allocate if it's only a fn() pointer -pub type FunctionBox = SmallBox; +// can't use PyThreadingConstraint for this since it's not an auto trait, and therefore we can't +// add it ad-hoc to a trait object +#[cfg(not(feature = "threading"))] +pub type NativeFuncObj = dyn Fn(&VirtualMachine, PyFuncArgs) -> PyResult + 'static; +#[cfg(feature = "threading")] +pub type NativeFuncObj = dyn Fn(&VirtualMachine, PyFuncArgs) -> PyResult + Send + Sync + 'static; /// A built-in Python function. -pub type PyNativeFunc = - FunctionBox PyResult + 'static + Send + Sync>; +pub type PyNativeFunc = Box; /// Implemented by types that are or can generate built-in functions. /// @@ -498,16 +500,19 @@ pub type PyNativeFunc = /// /// A bare `PyNativeFunc` also implements this trait, allowing the above to be /// done manually, for rare situations that don't fit into this model. -pub trait IntoPyNativeFunc { - fn into_func(self) -> PyNativeFunc; +pub trait IntoPyNativeFunc: Sized + Send + Sync + 'static { + fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult; + fn into_func(self) -> PyNativeFunc { + Box::new(move |vm: &VirtualMachine, args| self.call(vm, args)) + } } impl IntoPyNativeFunc for F where F: Fn(&VirtualMachine, PyFuncArgs) -> PyResult + 'static + Send + Sync, { - fn into_func(self) -> PyNativeFunc { - smallbox!(self) + fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult { + (self)(vm, args) } } @@ -526,12 +531,10 @@ macro_rules! into_py_native_func_tuple { $($T: FromArgs,)* R: IntoPyResult, { - fn into_func(self) -> PyNativeFunc { - smallbox!(move |vm: &VirtualMachine, args: PyFuncArgs| { - let ($($n,)*) = args.bind::<($($T,)*)>(vm)?; + fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult { + let ($($n,)*) = args.bind::<($($T,)*)>(vm)?; - (self)($($n,)* vm).into_pyresult(vm) - }) + (self)($($n,)* vm).into_pyresult(vm) } } @@ -542,12 +545,10 @@ macro_rules! into_py_native_func_tuple { $($T: FromArgs,)* R: IntoPyResult, { - fn into_func(self) -> PyNativeFunc { - smallbox!(move |vm: &VirtualMachine, args: PyFuncArgs| { - let (zelf, $($n,)*) = args.bind::<(PyRef, $($T,)*)>(vm)?; + fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult { + let (zelf, $($n,)*) = args.bind::<(PyRef, $($T,)*)>(vm)?; - (self)(&zelf, $($n,)* vm).into_pyresult(vm) - }) + (self)(&zelf, $($n,)* vm).into_pyresult(vm) } } @@ -557,8 +558,10 @@ macro_rules! into_py_native_func_tuple { $($T: FromArgs,)* R: IntoPyResult, { - fn into_func(self) -> PyNativeFunc { - IntoPyNativeFunc::into_func(move |$($n,)* _vm: &VirtualMachine| (self)($($n,)*)) + fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult { + let ($($n,)*) = args.bind::<($($T,)*)>(vm)?; + + (self)($($n,)*).into_pyresult(vm) } } @@ -569,8 +572,10 @@ macro_rules! into_py_native_func_tuple { $($T: FromArgs,)* R: IntoPyResult, { - fn into_func(self) -> PyNativeFunc { - IntoPyNativeFunc::into_func(move |zelf: &S, $($n,)* _vm: &VirtualMachine| (self)(zelf, $($n,)*)) + fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult { + let (zelf, $($n,)*) = args.bind::<(PyRef, $($T,)*)>(vm)?; + + (self)(&zelf, $($n,)*).into_pyresult(vm) } } }; @@ -641,11 +646,17 @@ where #[cfg(test)] mod tests { #[test] - fn test_functionbox_noalloc() { + fn test_intonativefunc_noalloc() { + macro_rules! check_size { + ($f:expr) => { + let f = super::IntoPyNativeFunc::into_func(py_func); + assert_eq!(std::mem::size_of_val(f.as_ref()), 0); + }; + } fn py_func(_b: bool, _vm: &crate::VirtualMachine) -> i32 { 1 } - let f = super::IntoPyNativeFunc::into_func(py_func); - assert!(!f.is_heap()); + check_size!(py_func); + check_size!(|| "foo".to_owned()); } } diff --git a/vm/src/lib.rs b/vm/src/lib.rs index 0ab03beac..3fec9fc5f 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -73,8 +73,3 @@ mod vm; pub use self::vm::{InitParameter, PySettings, VirtualMachine}; pub use rustpython_bytecode::*; pub use rustpython_common as common; - -#[doc(hidden)] -pub mod __exports { - pub use smallbox::smallbox; -} diff --git a/vm/src/obj/objgetset.rs b/vm/src/obj/objgetset.rs index 2bdd41cfb..32261963b 100644 --- a/vm/src/obj/objgetset.rs +++ b/vm/src/obj/objgetset.rs @@ -2,7 +2,7 @@ */ use super::objtype::PyClassRef; -use crate::function::{FunctionBox, OptionalArg, OwnedParam, RefParam}; +use crate::function::{OptionalArg, OwnedParam, RefParam}; use crate::pyobject::{ IntoPyResult, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol, @@ -10,9 +10,9 @@ use crate::pyobject::{ use crate::slots::SlotDescriptor; use crate::vm::VirtualMachine; -pub type PyGetterFunc = FunctionBox PyResult + Send + Sync>; +pub type PyGetterFunc = Box PyResult + Send + Sync>; pub type PySetterFunc = - FunctionBox PyResult<()> + Send + Sync>; + Box PyResult<()> + Send + Sync>; pub trait IntoPyGetterFunc { fn into_getter(self) -> PyGetterFunc; @@ -25,7 +25,7 @@ where R: IntoPyResult, { fn into_getter(self) -> PyGetterFunc { - smallbox::smallbox!(move |vm: &VirtualMachine, obj| { + Box::new(move |vm: &VirtualMachine, obj| { let obj = T::try_from_object(vm, obj)?; (self)(obj, vm).into_pyresult(vm) }) @@ -39,7 +39,7 @@ where R: IntoPyResult, { fn into_getter(self) -> PyGetterFunc { - smallbox::smallbox!(move |vm: &VirtualMachine, obj| { + Box::new(move |vm: &VirtualMachine, obj| { let zelf = PyRef::::try_from_object(vm, obj)?; (self)(&zelf, vm).into_pyresult(vm) }) @@ -96,7 +96,7 @@ where R: IntoPyNoResult, { fn into_setter(self) -> PySetterFunc { - smallbox::smallbox!(move |vm: &VirtualMachine, obj, value| { + Box::new(move |vm: &VirtualMachine, obj, value| { let obj = T::try_from_object(vm, obj)?; let value = V::try_from_object(vm, value)?; (self)(obj, value, vm).into_noresult() @@ -112,7 +112,7 @@ where R: IntoPyNoResult, { fn into_setter(self) -> PySetterFunc { - smallbox::smallbox!(move |vm: &VirtualMachine, obj, value| { + Box::new(move |vm: &VirtualMachine, obj, value| { let zelf = PyRef::::try_from_object(vm, obj)?; let value = V::try_from_object(vm, value)?; (self)(&zelf, value, vm).into_noresult() diff --git a/vm/src/slots.rs b/vm/src/slots.rs index 4422043c8..9ef3fbca2 100644 --- a/vm/src/slots.rs +++ b/vm/src/slots.rs @@ -1,4 +1,4 @@ -use crate::function::{FunctionBox, OptionalArg, PyFuncArgs, PyNativeFunc}; +use crate::function::{OptionalArg, PyFuncArgs, PyNativeFunc}; use crate::pyobject::{IdProtocol, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject}; use crate::VirtualMachine; @@ -53,7 +53,7 @@ pub trait SlotCall: PyValue { fn call(&self, args: PyFuncArgs, vm: &VirtualMachine) -> PyResult; } -pub type PyDescrGetFunc = FunctionBox< +pub type PyDescrGetFunc = Box< dyn Fn(&VirtualMachine, PyObjectRef, Option, OptionalArg) -> PyResult + Send + Sync, From 7218d1d99812dfe5f1c88fb5687b0fe21cf0a988 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sat, 22 Aug 2020 16:14:50 -0500 Subject: [PATCH 2/4] Make more dyn Fn()s threading-optional --- vm/src/function.rs | 38 ++++++++++++++--------------------- vm/src/macros.rs | 18 +++++++++++++++++ vm/src/obj/objgetset.rs | 4 ++-- vm/src/stdlib/mod.rs | 2 +- wasm/lib/src/convert.rs | 28 +------------------------- wasm/lib/src/vm_class.rs | 5 ++--- wasm/lib/src/wasm_builtins.rs | 2 +- 7 files changed, 40 insertions(+), 57 deletions(-) diff --git a/vm/src/function.rs b/vm/src/function.rs index 591f70f70..65e77ecc0 100644 --- a/vm/src/function.rs +++ b/vm/src/function.rs @@ -9,7 +9,8 @@ use crate::exceptions::PyBaseExceptionRef; use crate::obj::objtuple::PyTupleRef; use crate::obj::objtype::{isinstance, PyClassRef}; use crate::pyobject::{ - BorrowValue, IntoPyResult, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol, + BorrowValue, IntoPyResult, PyObjectRef, PyRef, PyResult, PyThreadingConstraint, PyValue, + TryFromObject, TypeProtocol, }; use crate::vm::VirtualMachine; @@ -476,15 +477,8 @@ tuple_from_py_func_args!(A, B, C, D); tuple_from_py_func_args!(A, B, C, D, E); tuple_from_py_func_args!(A, B, C, D, E, F); -// can't use PyThreadingConstraint for this since it's not an auto trait, and therefore we can't -// add it ad-hoc to a trait object -#[cfg(not(feature = "threading"))] -pub type NativeFuncObj = dyn Fn(&VirtualMachine, PyFuncArgs) -> PyResult + 'static; -#[cfg(feature = "threading")] -pub type NativeFuncObj = dyn Fn(&VirtualMachine, PyFuncArgs) -> PyResult + Send + Sync + 'static; - /// A built-in Python function. -pub type PyNativeFunc = Box; +pub type PyNativeFunc = Box PyResult)>; /// Implemented by types that are or can generate built-in functions. /// @@ -500,7 +494,7 @@ pub type PyNativeFunc = Box; /// /// A bare `PyNativeFunc` also implements this trait, allowing the above to be /// done manually, for rare situations that don't fit into this model. -pub trait IntoPyNativeFunc: Sized + Send + Sync + 'static { +pub trait IntoPyNativeFunc: Sized + PyThreadingConstraint + 'static { fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult; fn into_func(self) -> PyNativeFunc { Box::new(move |vm: &VirtualMachine, args| self.call(vm, args)) @@ -509,7 +503,7 @@ pub trait IntoPyNativeFunc: Sized + Send + Sync + 'static { impl IntoPyNativeFunc for F where - F: Fn(&VirtualMachine, PyFuncArgs) -> PyResult + 'static + Send + Sync, + F: Fn(&VirtualMachine, PyFuncArgs) -> PyResult + PyThreadingConstraint + 'static, { fn call(&self, vm: &VirtualMachine, args: PyFuncArgs) -> PyResult { (self)(vm, args) @@ -527,7 +521,7 @@ macro_rules! into_py_native_func_tuple { ($(($n:tt, $T:ident)),*) => { impl IntoPyNativeFunc<($(OwnedParam<$T>,)*), R, VirtualMachine> for F where - F: Fn($($T,)* &VirtualMachine) -> R + 'static + Send + Sync, + F: Fn($($T,)* &VirtualMachine) -> R + PyThreadingConstraint + 'static, $($T: FromArgs,)* R: IntoPyResult, { @@ -540,7 +534,7 @@ macro_rules! into_py_native_func_tuple { impl IntoPyNativeFunc<(RefParam, $(OwnedParam<$T>,)*), R, VirtualMachine> for F where - F: Fn(&S, $($T,)* &VirtualMachine) -> R + 'static + Send + Sync, + F: Fn(&S, $($T,)* &VirtualMachine) -> R + PyThreadingConstraint + 'static, S: PyValue, $($T: FromArgs,)* R: IntoPyResult, @@ -554,7 +548,7 @@ macro_rules! into_py_native_func_tuple { impl IntoPyNativeFunc<($(OwnedParam<$T>,)*), R, ()> for F where - F: Fn($($T,)*) -> R + 'static + Send + Sync, + F: Fn($($T,)*) -> R + PyThreadingConstraint + 'static, $($T: FromArgs,)* R: IntoPyResult, { @@ -567,7 +561,7 @@ macro_rules! into_py_native_func_tuple { impl IntoPyNativeFunc<(RefParam, $(OwnedParam<$T>,)*), R, ()> for F where - F: Fn(&S, $($T,)*) -> R + 'static + Send + Sync, + F: Fn(&S, $($T,)*) -> R + PyThreadingConstraint + 'static, S: PyValue, $($T: FromArgs,)* R: IntoPyResult, @@ -645,18 +639,16 @@ where #[cfg(test)] mod tests { + use super::*; + #[test] fn test_intonativefunc_noalloc() { - macro_rules! check_size { - ($f:expr) => { - let f = super::IntoPyNativeFunc::into_func(py_func); - assert_eq!(std::mem::size_of_val(f.as_ref()), 0); - }; - } + let check_zst = |f: PyNativeFunc| assert_eq!(std::mem::size_of_val(f.as_ref()), 0); fn py_func(_b: bool, _vm: &crate::VirtualMachine) -> i32 { 1 } - check_size!(py_func); - check_size!(|| "foo".to_owned()); + check_zst(py_func.into_func()); + let empty_closure = || "foo".to_owned(); + check_zst(empty_closure.into_func()); } } diff --git a/vm/src/macros.rs b/vm/src/macros.rs index ee56bed03..9349c7c09 100644 --- a/vm/src/macros.rs +++ b/vm/src/macros.rs @@ -240,3 +240,21 @@ macro_rules! named_function { } }}; } + +// can't use PyThreadingConstraint for stuff like this since it's not an auto trait, and +// therefore we can't add it ad-hoc to a trait object +cfg_if::cfg_if! { + if #[cfg(feature = "threading")] { + macro_rules! py_dyn_fn { + (dyn Fn($($arg:ty),*$(,)*) -> $ret:ty) => { + dyn Fn($($arg),*) -> $ret + Send + Sync + 'static + }; + } + } else { + macro_rules! py_dyn_fn { + (dyn Fn($($arg:ty),*$(,)*) -> $ret:ty) => { + dyn Fn($($arg),*) -> $ret + 'static + }; + } + } +} diff --git a/vm/src/obj/objgetset.rs b/vm/src/obj/objgetset.rs index 32261963b..b7c43358e 100644 --- a/vm/src/obj/objgetset.rs +++ b/vm/src/obj/objgetset.rs @@ -10,9 +10,9 @@ use crate::pyobject::{ use crate::slots::SlotDescriptor; use crate::vm::VirtualMachine; -pub type PyGetterFunc = Box PyResult + Send + Sync>; +pub type PyGetterFunc = Box PyResult)>; pub type PySetterFunc = - Box PyResult<()> + Send + Sync>; + Box PyResult<()>)>; pub trait IntoPyGetterFunc { fn into_getter(self) -> PyGetterFunc; diff --git a/vm/src/stdlib/mod.rs b/vm/src/stdlib/mod.rs index 880c1f9f2..d62bec6c4 100644 --- a/vm/src/stdlib/mod.rs +++ b/vm/src/stdlib/mod.rs @@ -68,7 +68,7 @@ mod winreg; #[cfg(not(any(target_arch = "wasm32", target_os = "redox")))] mod zlib; -pub type StdlibInitFunc = Box PyObjectRef + Send + Sync>; +pub type StdlibInitFunc = Box PyObjectRef)>; pub fn get_module_inits() -> HashMap { #[allow(unused_mut)] diff --git a/wasm/lib/src/convert.rs b/wasm/lib/src/convert.rs index 7626434fa..5cbc5ce56 100644 --- a/wasm/lib/src/convert.rs +++ b/wasm/lib/src/convert.rs @@ -17,31 +17,6 @@ use rustpython_vm::{exceptions, py_serde}; use crate::browser_module; use crate::vm_class::{stored_vm_from_wasm, WASMVirtualMachine}; -// Currently WASM do not support multithreading. We should change this once it is enabled. -thread_local!(static JS_HANDLES: RefCell> = RefCell::new(Arena::new())); - -pub struct JsHandle(generational_arena::Index); -impl JsHandle { - pub fn new(js: JsValue) -> Self { - let idx = JS_HANDLES.with(|arena| arena.borrow_mut().insert(js)); - JsHandle(idx) - } - pub fn get(&self) -> JsValue { - JS_HANDLES.with(|arena| { - arena - .borrow() - .get(self.0) - .expect("index was removed") - .clone() - }) - } -} -impl Drop for JsHandle { - fn drop(&mut self) { - JS_HANDLES.with(|arena| arena.borrow_mut().remove(self.0)); - } -} - #[wasm_bindgen(inline_js = r" export class PyError extends Error { constructor(info) { @@ -223,7 +198,7 @@ pub fn js_to_py(vm: &VirtualMachine, js_val: JsValue) -> PyObjectRef { dict.into_object() } } else if js_val.is_function() { - let js_handle = JsHandle::new(js_val); + let func = js_sys::Function::from(js_val); vm.ctx .new_method(move |vm: &VirtualMachine, args: PyFuncArgs| -> PyResult { let this = Object::new(); @@ -235,7 +210,6 @@ pub fn js_to_py(vm: &VirtualMachine, js_val: JsValue) -> PyObjectRef { for v in args.args { js_args.push(&py_to_js(vm, v)); } - let func = js_sys::Function::from(js_handle.get()); func.apply(&this, &js_args) .map(|val| js_to_py(vm, val)) .map_err(|err| js_err_to_py_err(vm, &err)) diff --git a/wasm/lib/src/vm_class.rs b/wasm/lib/src/vm_class.rs index 76b1cb082..8483b99d4 100644 --- a/wasm/lib/src/vm_class.rs +++ b/wasm/lib/src/vm_class.rs @@ -12,7 +12,7 @@ use rustpython_vm::scope::{NameProtocol, Scope}; use rustpython_vm::{InitParameter, PySettings, VirtualMachine}; use crate::browser_module::setup_browser_module; -use crate::convert::{self, JsHandle, PyResultExt}; +use crate::convert::{self, PyResultExt}; use crate::js_module; use crate::wasm_builtins; use rustpython_compiler::mode::Mode; @@ -227,9 +227,8 @@ impl WASMVirtualMachine { _ => return Err(error()), } } else if stdout.is_function() { - let func_handle = JsHandle::new(stdout); + let func = js_sys::Function::from(stdout); make_stdout_object(vm, move |data, vm| { - let func = js_sys::Function::from(func_handle.get()); func.call1(&JsValue::UNDEFINED, &data.into()) .map_err(|err| convert::js_py_typeerror(vm, err))?; Ok(()) diff --git a/wasm/lib/src/wasm_builtins.rs b/wasm/lib/src/wasm_builtins.rs index fd565d0df..2366ff903 100644 --- a/wasm/lib/src/wasm_builtins.rs +++ b/wasm/lib/src/wasm_builtins.rs @@ -21,7 +21,7 @@ pub fn sys_stdout_write_console(data: &str, _vm: &VirtualMachine) -> PyResult<() pub fn make_stdout_object( vm: &VirtualMachine, - write_f: impl Fn(&str, &VirtualMachine) -> PyResult<()> + Send + Sync + 'static, + write_f: impl Fn(&str, &VirtualMachine) -> PyResult<()> + 'static, ) -> PyObjectRef { let ctx = &vm.ctx; let write_method = ctx.new_method( From 794c91be6e229d67f76a02801b10d37e6486f7fb Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sat, 22 Aug 2020 16:27:00 -0500 Subject: [PATCH 3/4] Remove generational-arena dependency --- Cargo.lock | 11 ----------- vm/Cargo.toml | 1 - wasm/lib/Cargo.toml | 1 - wasm/lib/src/convert.rs | 1 - 4 files changed, 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6e0b56be..78f26b6d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -552,15 +552,6 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" -[[package]] -name = "generational-arena" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d3b771574f62d0548cee0ad9057857e9fc25d7a3335f140c84f6acd0bf601" -dependencies = [ - "cfg-if", -] - [[package]] name = "generic-array" version = "0.12.3" @@ -1398,7 +1389,6 @@ dependencies = [ "flamer", "flate2", "foreign-types-shared", - "generational-arena", "gethostname", "getrandom", "hex", @@ -1469,7 +1459,6 @@ version = "0.1.2" dependencies = [ "cfg-if", "futures", - "generational-arena", "js-sys", "parking_lot", "rustpython-compiler", diff --git a/vm/Cargo.toml b/vm/Cargo.toml index 0e49c65d4..521e7626b 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -71,7 +71,6 @@ foreign-types-shared = "0.1" num_enum = "0.4" bstr = "0.2.12" crossbeam-utils = "0.7" -generational-arena = "0.2" parking_lot = "0.11" thread_local = "1.0" cfg-if = "0.1.10" diff --git a/wasm/lib/Cargo.toml b/wasm/lib/Cargo.toml index 9f74c5a98..9004816cf 100644 --- a/wasm/lib/Cargo.toml +++ b/wasm/lib/Cargo.toml @@ -26,7 +26,6 @@ serde-wasm-bindgen = "0.1" serde = "1.0" js-sys = "0.3" futures = "0.1" -generational-arena = "0.2" # make parking_lot use wasm-bingden for instant parking_lot = { version = "0.11", features = ["wasm-bindgen"] } diff --git a/wasm/lib/src/convert.rs b/wasm/lib/src/convert.rs index 5cbc5ce56..df2d9741a 100644 --- a/wasm/lib/src/convert.rs +++ b/wasm/lib/src/convert.rs @@ -1,4 +1,3 @@ -use generational_arena::Arena; use std::cell::RefCell; use js_sys::{Array, ArrayBuffer, Object, Promise, Reflect, SyntaxError, Uint8Array}; From 513bf1638bc2ee7078de6d8eec68ebccc53a1d61 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sat, 22 Aug 2020 21:32:54 -0500 Subject: [PATCH 4/4] Don't pass --all to cargo in ci --- .github/workflows/ci.yaml | 7 ++++++- wasm/lib/src/convert.rs | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d30eb909f..5efca9a45 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,7 +6,7 @@ on: name: CI env: - CARGO_ARGS: --all --features ssl + CARGO_ARGS: --features ssl jobs: rust_tests: @@ -112,6 +112,11 @@ jobs: with: command: clippy args: ${{ env.CARGO_ARGS }} -- -Dwarnings + - name: run clippy on wasm + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --manifest-path=wasm/lib/Cargo.toml -- -Dwarnings - uses: actions/setup-python@v1 with: python-version: 3.8 diff --git a/wasm/lib/src/convert.rs b/wasm/lib/src/convert.rs index df2d9741a..793fa3f15 100644 --- a/wasm/lib/src/convert.rs +++ b/wasm/lib/src/convert.rs @@ -1,5 +1,3 @@ -use std::cell::RefCell; - use js_sys::{Array, ArrayBuffer, Object, Promise, Reflect, SyntaxError, Uint8Array}; use wasm_bindgen::{closure::Closure, prelude::*, JsCast};