Skip to content

Commit a309cb5

Browse files
committed
Fix 1.75 clippy warnings
1 parent 459cad8 commit a309cb5

File tree

6 files changed

+17
-22
lines changed

6 files changed

+17
-22
lines changed

common/src/hash.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ impl HashSecret {
5959

6060
impl HashSecret {
6161
pub fn hash_value<T: Hash + ?Sized>(&self, data: &T) -> PyHash {
62-
let mut hasher = self.build_hasher();
63-
data.hash(&mut hasher);
64-
fix_sentinel(mod_int(hasher.finish() as PyHash))
62+
fix_sentinel(mod_int(self.hash_one(data) as _))
6563
}
6664

6765
pub fn hash_iter<'a, T: 'a, I, F, E>(&self, iter: I, hashf: F) -> Result<PyHash, E>

compiler/codegen/src/compile.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,8 @@ impl Compiler {
507507
SymbolScope::Cell => {
508508
cache = &mut info.cellvar_cache;
509509
NameOpType::Deref
510-
}
511-
// // TODO: is this right?
512-
// SymbolScope::Unknown => NameOpType::Global,
510+
} // TODO: is this right?
511+
// SymbolScope::Unknown => NameOpType::Global,
513512
};
514513

515514
if NameUsage::Load == usage && name == "__debug__" {

stdlib/src/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ mod _socket {
5454
// put IPPROTO_MAX later
5555
use c::{
5656
AF_INET, AF_INET6, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK, INADDR_NONE, IPPROTO_ICMP,
57-
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_TCP,
57+
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_TCP,
5858
IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK,
5959
MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST, NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST,
6060
NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET,

vm/src/builtins/object.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ impl Constructor for PyBaseObject {
6161
name, methods
6262
)));
6363
}
64-
_ => unreachable!("unimplemented_abstract_method_count is always positive"),
64+
// TODO: remove `allow` when redox build doesn't complain about it
65+
#[allow(unreachable_patterns)]
66+
_ => unreachable!(),
6567
}
6668
}
6769
}

vm/src/exceptions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ impl ExceptionZoo {
779779
let errno_getter =
780780
ctx.new_readonly_getset("errno", excs.os_error, |exc: PyBaseExceptionRef| {
781781
let args = exc.args();
782-
args.get(0)
782+
args.first()
783783
.filter(|_| args.len() > 1 && args.len() <= 5)
784784
.cloned()
785785
});
@@ -1116,7 +1116,7 @@ pub(super) mod types {
11161116
args: ::rustpython_vm::function::FuncArgs,
11171117
vm: &::rustpython_vm::VirtualMachine,
11181118
) -> ::rustpython_vm::PyResult<()> {
1119-
zelf.set_attr("value", vm.unwrap_or_none(args.args.get(0).cloned()), vm)?;
1119+
zelf.set_attr("value", vm.unwrap_or_none(args.args.first().cloned()), vm)?;
11201120
Ok(())
11211121
}
11221122
}

vm/src/warn.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,13 @@ pub fn warn(
8787
}
8888

8989
fn get_default_action(vm: &VirtualMachine) -> PyResult<PyObjectRef> {
90-
vm.state
91-
.warnings
92-
.default_action
93-
.clone()
94-
.try_into()
95-
.map_err(|_| {
96-
vm.new_value_error(format!(
97-
"_warnings.defaultaction must be a string, not '{}'",
98-
vm.state.warnings.default_action
99-
))
100-
})
90+
Ok(vm.state.warnings.default_action.clone().into())
91+
// .map_err(|_| {
92+
// vm.new_value_error(format!(
93+
// "_warnings.defaultaction must be a string, not '{}'",
94+
// vm.state.warnings.default_action
95+
// ))
96+
// })
10197
}
10298

10399
fn get_filter(
@@ -125,7 +121,7 @@ fn get_filter(
125121
.ok_or_else(|| vm.new_value_error(format!("_warnings.filters item {i} isn't a 5-tuple")))?;
126122

127123
/* Python code: action, msg, cat, mod, ln = item */
128-
let action = if let Some(action) = tmp_item.get(0) {
124+
let action = if let Some(action) = tmp_item.first() {
129125
action.str(vm).map(|action| action.into_object())
130126
} else {
131127
Err(vm.new_type_error("action must be a string".to_string()))

0 commit comments

Comments
 (0)