Skip to content

Commit 7236109

Browse files
authored
Merge pull request RustPython#5144 from youknowone/clippy
Fix 1.75 clippy warnings
2 parents 5001b2e + 506c8a6 commit 7236109

File tree

11 files changed

+32
-37
lines changed

11 files changed

+32
-37
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ indexmap = { version = "1.9.3", features = ["std"] }
5656
insta = "1.33.0"
5757
itertools = "0.11.0"
5858
is-macro = "0.3.0"
59-
libc = "0.2.133"
59+
libc = "0.2.151"
6060
log = "0.4.16"
6161
nix = "0.26"
6262
malachite-bigint = "0.2.0"

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

compiler/codegen/src/symboltable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ mod stack {
230230
res.unwrap_or_else(|x| panic::resume_unwind(x))
231231
}
232232

233-
pub fn iter(&self) -> impl Iterator<Item = &T> + DoubleEndedIterator + '_ {
233+
pub fn iter(&self) -> impl DoubleEndedIterator<Item = &T> + '_ {
234234
self.as_ref().iter().copied()
235235
}
236-
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> + DoubleEndedIterator + '_ {
236+
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut T> + '_ {
237237
self.as_mut().iter_mut().map(|x| &mut **x)
238238
}
239239
// pub fn top(&self) -> Option<&T> {

stdlib/src/resource.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ mod resource {
1111
use std::{io, mem};
1212

1313
cfg_if::cfg_if! {
14-
if #[cfg(any(target_os = "linux", target_os = "android"))] {
14+
if #[cfg(target_os = "android")] {
1515
use libc::RLIM_NLIMITS;
1616
} else {
17-
// in bsd-ish platforms, this constant isn't abi-stable across os versions, so we just
17+
// This constant isn't abi-stable across os versions, so we just
1818
// pick a high number so we don't get false positive ValueErrors and just bubble up the
1919
// EINVAL that get/setrlimit return on an invalid resource
2020
const RLIM_NLIMITS: i32 = 256;

stdlib/src/socket.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ mod _socket {
8282
// put IPPROTO_MAX later
8383
use c::{
8484
AF_INET, AF_INET6, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK, INADDR_NONE, IPPROTO_ICMP,
85-
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_TCP,
86-
IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK,
87-
MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST, NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST,
88-
NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET,
89-
SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE, SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
85+
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IPV6, IPPROTO_TCP, IPPROTO_TCP as SOL_TCP, IPPROTO_UDP,
86+
MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST,
87+
NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST, NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR,
88+
SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE,
89+
SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
9090
};
9191

9292
#[cfg(not(target_os = "redox"))]
9393
#[pyattr]
9494
use c::{
9595
AF_DECnet, AF_APPLETALK, AF_IPX, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP,
96-
IPPROTO_FRAGMENT, IPPROTO_HOPOPTS, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_NONE, IPPROTO_PIM,
97-
IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING,
96+
IPPROTO_FRAGMENT, IPPROTO_HOPOPTS, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IPIP, IPPROTO_NONE,
97+
IPPROTO_PIM, IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING,
9898
};
9999

100100
#[cfg(unix)]

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/builtins/type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl PyType {
299299
}
300300
}
301301

302-
pub fn iter_mro(&self) -> impl Iterator<Item = &PyType> + DoubleEndedIterator {
302+
pub fn iter_mro(&self) -> impl DoubleEndedIterator<Item = &PyType> {
303303
std::iter::once(self).chain(self.mro.iter().map(|cls| -> &PyType { cls }))
304304
}
305305

@@ -420,7 +420,7 @@ impl Py<PyType> {
420420
self.as_object().is(cls.borrow()) || self.mro.iter().any(|c| c.is(cls.borrow()))
421421
}
422422

423-
pub fn iter_mro(&self) -> impl Iterator<Item = &Py<PyType>> + DoubleEndedIterator {
423+
pub fn iter_mro(&self) -> impl DoubleEndedIterator<Item = &Py<PyType>> {
424424
std::iter::once(self).chain(self.mro.iter().map(|x| x.deref()))
425425
}
426426

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
}

0 commit comments

Comments
 (0)