mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Merge pull request #5144 from youknowone/clippy
Fix 1.75 clippy warnings
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -1120,9 +1120,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.141"
|
||||
version = "0.2.151"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5"
|
||||
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
|
||||
|
||||
[[package]]
|
||||
name = "libffi"
|
||||
|
||||
@@ -56,7 +56,7 @@ indexmap = { version = "1.9.3", features = ["std"] }
|
||||
insta = "1.33.0"
|
||||
itertools = "0.11.0"
|
||||
is-macro = "0.3.0"
|
||||
libc = "0.2.133"
|
||||
libc = "0.2.151"
|
||||
log = "0.4.16"
|
||||
nix = "0.26"
|
||||
malachite-bigint = "0.2.0"
|
||||
|
||||
@@ -59,9 +59,7 @@ impl HashSecret {
|
||||
|
||||
impl HashSecret {
|
||||
pub fn hash_value<T: Hash + ?Sized>(&self, data: &T) -> PyHash {
|
||||
let mut hasher = self.build_hasher();
|
||||
data.hash(&mut hasher);
|
||||
fix_sentinel(mod_int(hasher.finish() as PyHash))
|
||||
fix_sentinel(mod_int(self.hash_one(data) as _))
|
||||
}
|
||||
|
||||
pub fn hash_iter<'a, T: 'a, I, F, E>(&self, iter: I, hashf: F) -> Result<PyHash, E>
|
||||
|
||||
@@ -507,9 +507,8 @@ impl Compiler {
|
||||
SymbolScope::Cell => {
|
||||
cache = &mut info.cellvar_cache;
|
||||
NameOpType::Deref
|
||||
}
|
||||
// // TODO: is this right?
|
||||
// SymbolScope::Unknown => NameOpType::Global,
|
||||
} // TODO: is this right?
|
||||
// SymbolScope::Unknown => NameOpType::Global,
|
||||
};
|
||||
|
||||
if NameUsage::Load == usage && name == "__debug__" {
|
||||
|
||||
@@ -230,10 +230,10 @@ mod stack {
|
||||
res.unwrap_or_else(|x| panic::resume_unwind(x))
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> + DoubleEndedIterator + '_ {
|
||||
pub fn iter(&self) -> impl DoubleEndedIterator<Item = &T> + '_ {
|
||||
self.as_ref().iter().copied()
|
||||
}
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> + DoubleEndedIterator + '_ {
|
||||
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut T> + '_ {
|
||||
self.as_mut().iter_mut().map(|x| &mut **x)
|
||||
}
|
||||
// pub fn top(&self) -> Option<&T> {
|
||||
|
||||
@@ -11,10 +11,10 @@ mod resource {
|
||||
use std::{io, mem};
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(target_os = "linux", target_os = "android"))] {
|
||||
if #[cfg(target_os = "android")] {
|
||||
use libc::RLIM_NLIMITS;
|
||||
} else {
|
||||
// in bsd-ish platforms, this constant isn't abi-stable across os versions, so we just
|
||||
// This constant isn't abi-stable across os versions, so we just
|
||||
// pick a high number so we don't get false positive ValueErrors and just bubble up the
|
||||
// EINVAL that get/setrlimit return on an invalid resource
|
||||
const RLIM_NLIMITS: i32 = 256;
|
||||
|
||||
@@ -82,19 +82,19 @@ mod _socket {
|
||||
// put IPPROTO_MAX later
|
||||
use c::{
|
||||
AF_INET, AF_INET6, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK, INADDR_NONE, IPPROTO_ICMP,
|
||||
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_TCP,
|
||||
IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK,
|
||||
MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST, NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST,
|
||||
NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET,
|
||||
SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE, SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
|
||||
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IPV6, IPPROTO_TCP, IPPROTO_TCP as SOL_TCP, IPPROTO_UDP,
|
||||
MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST,
|
||||
NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST, NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR,
|
||||
SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE,
|
||||
SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
|
||||
};
|
||||
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
#[pyattr]
|
||||
use c::{
|
||||
AF_DECnet, AF_APPLETALK, AF_IPX, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP,
|
||||
IPPROTO_FRAGMENT, IPPROTO_HOPOPTS, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_NONE, IPPROTO_PIM,
|
||||
IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING,
|
||||
IPPROTO_FRAGMENT, IPPROTO_HOPOPTS, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IPIP, IPPROTO_NONE,
|
||||
IPPROTO_PIM, IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING,
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
@@ -61,7 +61,9 @@ impl Constructor for PyBaseObject {
|
||||
name, methods
|
||||
)));
|
||||
}
|
||||
_ => unreachable!("unimplemented_abstract_method_count is always positive"),
|
||||
// TODO: remove `allow` when redox build doesn't complain about it
|
||||
#[allow(unreachable_patterns)]
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ impl PyType {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter_mro(&self) -> impl Iterator<Item = &PyType> + DoubleEndedIterator {
|
||||
pub fn iter_mro(&self) -> impl DoubleEndedIterator<Item = &PyType> {
|
||||
std::iter::once(self).chain(self.mro.iter().map(|cls| -> &PyType { cls }))
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ impl Py<PyType> {
|
||||
self.as_object().is(cls.borrow()) || self.mro.iter().any(|c| c.is(cls.borrow()))
|
||||
}
|
||||
|
||||
pub fn iter_mro(&self) -> impl Iterator<Item = &Py<PyType>> + DoubleEndedIterator {
|
||||
pub fn iter_mro(&self) -> impl DoubleEndedIterator<Item = &Py<PyType>> {
|
||||
std::iter::once(self).chain(self.mro.iter().map(|x| x.deref()))
|
||||
}
|
||||
|
||||
|
||||
@@ -779,7 +779,7 @@ impl ExceptionZoo {
|
||||
let errno_getter =
|
||||
ctx.new_readonly_getset("errno", excs.os_error, |exc: PyBaseExceptionRef| {
|
||||
let args = exc.args();
|
||||
args.get(0)
|
||||
args.first()
|
||||
.filter(|_| args.len() > 1 && args.len() <= 5)
|
||||
.cloned()
|
||||
});
|
||||
@@ -1116,7 +1116,7 @@ pub(super) mod types {
|
||||
args: ::rustpython_vm::function::FuncArgs,
|
||||
vm: &::rustpython_vm::VirtualMachine,
|
||||
) -> ::rustpython_vm::PyResult<()> {
|
||||
zelf.set_attr("value", vm.unwrap_or_none(args.args.get(0).cloned()), vm)?;
|
||||
zelf.set_attr("value", vm.unwrap_or_none(args.args.first().cloned()), vm)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,17 +87,13 @@ pub fn warn(
|
||||
}
|
||||
|
||||
fn get_default_action(vm: &VirtualMachine) -> PyResult<PyObjectRef> {
|
||||
vm.state
|
||||
.warnings
|
||||
.default_action
|
||||
.clone()
|
||||
.try_into()
|
||||
.map_err(|_| {
|
||||
vm.new_value_error(format!(
|
||||
"_warnings.defaultaction must be a string, not '{}'",
|
||||
vm.state.warnings.default_action
|
||||
))
|
||||
})
|
||||
Ok(vm.state.warnings.default_action.clone().into())
|
||||
// .map_err(|_| {
|
||||
// vm.new_value_error(format!(
|
||||
// "_warnings.defaultaction must be a string, not '{}'",
|
||||
// vm.state.warnings.default_action
|
||||
// ))
|
||||
// })
|
||||
}
|
||||
|
||||
fn get_filter(
|
||||
@@ -125,7 +121,7 @@ fn get_filter(
|
||||
.ok_or_else(|| vm.new_value_error(format!("_warnings.filters item {i} isn't a 5-tuple")))?;
|
||||
|
||||
/* Python code: action, msg, cat, mod, ln = item */
|
||||
let action = if let Some(action) = tmp_item.get(0) {
|
||||
let action = if let Some(action) = tmp_item.first() {
|
||||
action.str(vm).map(|action| action.into_object())
|
||||
} else {
|
||||
Err(vm.new_type_error("action must be a string".to_string()))
|
||||
|
||||
Reference in New Issue
Block a user