mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Merge pull request #3562 from fanninpm/new-clippy-lints-1.59
Fix Clippy lints introduced in Rust 1.59
This commit is contained in:
1
Lib/test/test_threading.py
vendored
1
Lib/test/test_threading.py
vendored
@@ -1061,6 +1061,7 @@ class ThreadingExceptionTests(BaseTestCase):
|
||||
lock = threading.Lock()
|
||||
self.assertRaises(RuntimeError, lock.release)
|
||||
|
||||
@unittest.skip("TODO: RUSTPYTHON, flaky test")
|
||||
def test_recursion_limit(self):
|
||||
# Issue 9670
|
||||
# test that excessive recursion within a non-main thread causes
|
||||
|
||||
@@ -15,15 +15,11 @@ pub fn timing_safe_cmp(a: &[u8], b: &[u8]) -> bool {
|
||||
* chance to optimize and fold the code in any way that may change
|
||||
* the timing.
|
||||
*/
|
||||
let length: Volatile<usize>;
|
||||
let mut left: Volatile<*const u8>;
|
||||
let mut right: Volatile<*const u8>;
|
||||
let mut result: u8 = 0;
|
||||
|
||||
/* loop count depends on length of b */
|
||||
length = Volatile::new(len_b);
|
||||
left = Volatile::new(std::ptr::null());
|
||||
right = Volatile::new(b);
|
||||
let length: Volatile<usize> = Volatile::new(len_b);
|
||||
let mut left: Volatile<*const u8> = Volatile::new(std::ptr::null());
|
||||
let mut right: Volatile<*const u8> = Volatile::new(b);
|
||||
|
||||
/* don't use else here to keep the amount of CPU instructions constant,
|
||||
* volatile forces re-evaluation
|
||||
|
||||
@@ -636,7 +636,7 @@ impl GetSetNursery {
|
||||
for ((name, _cfgs), (getter, setter, deleter)) in self.map.iter() {
|
||||
if getter.is_none() {
|
||||
errors.push(syn::Error::new_spanned(
|
||||
setter.as_ref().or_else(|| deleter.as_ref()).unwrap(),
|
||||
setter.as_ref().or(deleter.as_ref()).unwrap(),
|
||||
format!("Property '{}' is missing a getter", name),
|
||||
));
|
||||
};
|
||||
|
||||
@@ -119,7 +119,7 @@ fn new_module_item(
|
||||
}),
|
||||
"pyclass" => Box::new(ClassItem {
|
||||
inner: ContentItemInner { index, attr_name },
|
||||
pyattrs: pyattrs.unwrap_or_else(Vec::new),
|
||||
pyattrs: pyattrs.unwrap_or_default(),
|
||||
}),
|
||||
other => unreachable!("#[pymodule] doesn't accept #[{}]", other),
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,7 @@ mod _socket {
|
||||
let abstractpath = &path_u8[..abstractaddrlen];
|
||||
vm.ctx.new_bytes(abstractpath.to_vec()).into()
|
||||
} else {
|
||||
let len = memchr::memchr(b'\0', path_u8).unwrap_or_else(|| path_u8.len());
|
||||
let len = memchr::memchr(b'\0', path_u8).unwrap_or(path_u8.len());
|
||||
let path = &path_u8[..len];
|
||||
vm.ctx.new_str(String::from_utf8_lossy(path)).into()
|
||||
}
|
||||
|
||||
@@ -395,12 +395,10 @@ fn to_isize_index(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Option<isize>
|
||||
})?;
|
||||
let value = result.as_bigint();
|
||||
let is_negative = value.is_negative();
|
||||
Ok(Some(value.to_isize().unwrap_or_else(|| {
|
||||
if is_negative {
|
||||
isize::MIN
|
||||
} else {
|
||||
isize::MAX
|
||||
}
|
||||
Ok(Some(value.to_isize().unwrap_or(if is_negative {
|
||||
isize::MIN
|
||||
} else {
|
||||
isize::MAX
|
||||
})))
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ impl CFormatSpec {
|
||||
let precision = parse_precision(iter)?;
|
||||
consume_length(iter);
|
||||
let (format_type, format_char) = parse_format_type(iter)?;
|
||||
let precision = precision.or_else(|| match format_type {
|
||||
let precision = precision.or(match format_type {
|
||||
CFormatType::Float(_) => Some(CFormatQuantity::Amount(6)),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
@@ -1567,7 +1567,7 @@ mod _io {
|
||||
let mut data = self.reader().lock(vm)?;
|
||||
let raw = data.check_init(vm)?;
|
||||
ensure_unclosed(raw, "read of closed file", vm)?;
|
||||
let n = size.to_usize().unwrap_or_else(|| data.buffer.len());
|
||||
let n = size.to_usize().unwrap_or(data.buffer.len());
|
||||
if n == 0 {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
@@ -3214,10 +3214,7 @@ mod _io {
|
||||
#[pymethod]
|
||||
#[pymethod(name = "read1")]
|
||||
fn read(self, size: OptionalSize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
|
||||
let buf = self
|
||||
.buffer(vm)?
|
||||
.read(size.to_usize())
|
||||
.unwrap_or_else(Vec::new);
|
||||
let buf = self.buffer(vm)?.read(size.to_usize()).unwrap_or_default();
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
@@ -3277,7 +3274,7 @@ mod _io {
|
||||
|
||||
#[pymethod]
|
||||
fn close(self, vm: &VirtualMachine) -> PyResult<()> {
|
||||
let _ = self.try_resizable(vm)?;
|
||||
drop(self.try_resizable(vm)?);
|
||||
self.closed.store(true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user