From da9be2f7efd2feee27ea2be85fa3bb47e131f89c Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Wed, 11 Nov 2020 15:48:22 -0600 Subject: [PATCH] Fix clippy lint and unblock a test case --- Lib/test/test_long.py | 1 - vm/src/builtins/complex.rs | 12 ++---------- vm/src/builtins/float.rs | 12 ++---------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 348416e1e..687944fd3 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -381,7 +381,6 @@ class LongTest(unittest.TestCase): self.assertRaises(ValueError, int, '-012395', 0) - @unittest.expectedFailure # TODO: RUSTPYTHON def test_conversion(self): class JustLong: diff --git a/vm/src/builtins/complex.rs b/vm/src/builtins/complex.rs index 8ba88d419..db18bd787 100644 --- a/vm/src/builtins/complex.rs +++ b/vm/src/builtins/complex.rs @@ -21,14 +21,6 @@ pub struct PyComplex { value: Complex64, } -impl<'a> BorrowValue<'a> for PyComplex { - type Borrowed = &'a Complex64; - - fn borrow_value(&'a self) -> Self::Borrowed { - &self.value - } -} - impl PyValue for PyComplex { fn class(vm: &VirtualMachine) -> &PyTypeRef { &vm.ctx.types.complex_type @@ -53,13 +45,13 @@ pub fn init(context: &PyContext) { fn try_complex(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult> { if let Some(complex) = obj.payload_if_exact::(vm) { - return Ok(Some(complex.borrow_value().clone())); + return Ok(Some(complex.value)); } if let Some(method) = vm.get_method(obj.clone(), "__complex__") { let result = vm.invoke(&method?, ())?; // TODO: returning strict subclasses of complex in __complex__ is deprecated return match result.payload::() { - Some(complex_obj) => Ok(Some(complex_obj.borrow_value().clone())), + Some(complex_obj) => Ok(Some(complex_obj.value)), None => Err(vm.new_type_error(format!( "__complex__ returned non-complex (type '{}')", result.class().name diff --git a/vm/src/builtins/float.rs b/vm/src/builtins/float.rs index c30d2f7ee..d02b21682 100644 --- a/vm/src/builtins/float.rs +++ b/vm/src/builtins/float.rs @@ -26,14 +26,6 @@ pub struct PyFloat { value: f64, } -impl<'a> BorrowValue<'a> for PyFloat { - type Borrowed = &'a f64; - - fn borrow_value(&'a self) -> Self::Borrowed { - &self.value - } -} - impl PyFloat { pub fn to_f64(self) -> f64 { self.value @@ -65,13 +57,13 @@ impl From for PyFloat { pub(crate) fn try_float(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult> { if let Some(float) = obj.payload_if_exact::(vm) { - return Ok(Some(float.borrow_value().clone())); + return Ok(Some(float.value)); } if let Some(method) = vm.get_method(obj.clone(), "__float__") { let result = vm.invoke(&method?, ())?; // TODO: returning strict subclasses of float in __float__ is deprecated return match result.payload::() { - Some(float_obj) => Ok(Some(float_obj.borrow_value().clone())), + Some(float_obj) => Ok(Some(float_obj.value)), None => Err(vm.new_type_error(format!( "__float__ returned non-float (type '{}')", result.class().name