Fix 1.75 clippy warnings

This commit is contained in:
Jeong YunWon
2023-12-30 04:09:02 +09:00
parent 459cad8407
commit a309cb5d2c
6 changed files with 17 additions and 22 deletions

View File

@@ -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>

View File

@@ -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__" {

View File

@@ -54,7 +54,7 @@ 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_ICMPV6, IPPROTO_IP, 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,

View File

@@ -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!(),
}
}
}

View File

@@ -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(())
}
}

View File

@@ -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()))