From 5a8fd2febcf37182c8b11df33a35a69de8af8ade Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 18 Jul 2017 22:10:56 +0800 Subject: [PATCH] Some more clippy warning fixes [rustfix](https://github.com/killercup/rustfix) makes it much easier. --- pyo3cls/src/py_class.rs | 2 +- src/class/methods.rs | 2 +- src/object.rs | 2 +- src/pythonrun.rs | 2 +- tests/test_class.rs | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyo3cls/src/py_class.rs b/pyo3cls/src/py_class.rs index 34b8a343..439faaa9 100644 --- a/pyo3cls/src/py_class.rs +++ b/pyo3cls/src/py_class.rs @@ -151,7 +151,7 @@ fn impl_class(cls: &syn::Ident, base: &syn::Ident, <#cls as _pyo3::typeob::PyTypeObject>::init_type( _pyo3::Python::assume_gil_acquired()); } - std::mem::transmute(FREELIST) + &mut *FREELIST } } } diff --git a/src/class/methods.rs b/src/class/methods.rs index 41fde6f0..6661a8f8 100644 --- a/src/class/methods.rs +++ b/src/class/methods.rs @@ -101,7 +101,7 @@ impl PyGetterDef { dst.name = CString::new(self.name).expect( "Method name must not contain NULL byte").into_raw(); } - dst.get = Some(self.meth.clone()); + dst.get = Some(self.meth); } } diff --git a/src/object.rs b/src/object.rs index ec11a550..cfb51ca9 100644 --- a/src/object.rs +++ b/src/object.rs @@ -213,7 +213,7 @@ impl AsPyRef for PyObject { } #[inline] fn as_mut(&self, _py: Python) -> &mut PyObjectRef { - unsafe {std::mem::transmute(self as *const _ as *mut PyObjectRef)} + unsafe {&mut *(self as *const _ as *mut PyObjectRef)} } } diff --git a/src/pythonrun.rs b/src/pythonrun.rs index 94ca8479..bbab81d5 100644 --- a/src/pythonrun.rs +++ b/src/pythonrun.rs @@ -216,7 +216,7 @@ pub unsafe fn register_pointer(obj: *mut ffi::PyObject) pub unsafe fn register_owned(_py: Python, obj: *mut ffi::PyObject) -> &PyObjectRef { - let pool: &'static mut Pointers = mem::transmute(POINTERS); + let pool: &'static mut Pointers = &mut *POINTERS; pool.owned.push(obj); mem::transmute(&pool.owned[pool.owned.len()-1]) } diff --git a/tests/test_class.rs b/tests/test_class.rs index 4179746d..0ff45a82 100644 --- a/tests/test_class.rs +++ b/tests/test_class.rs @@ -225,13 +225,13 @@ fn data_is_dropped() { member2: TestDropCall { drop_called: drop_called2.clone() }, token: t }).unwrap(); - assert!(drop_called1.load(Ordering::Relaxed) == false); - assert!(drop_called2.load(Ordering::Relaxed) == false); + assert!(!drop_called1.load(Ordering::Relaxed)); + assert!(!drop_called2.load(Ordering::Relaxed)); drop(inst); } - assert!(drop_called1.load(Ordering::Relaxed) == true); - assert!(drop_called2.load(Ordering::Relaxed) == true); + assert!(drop_called1.load(Ordering::Relaxed)); + assert!(drop_called2.load(Ordering::Relaxed)); } #[py::class]