From c9f1f61baeb4312e05183a80850b9e34d7cf31fe Mon Sep 17 00:00:00 2001 From: Jeong Yunwon Date: Sat, 7 May 2022 20:00:57 +0900 Subject: [PATCH] fix clippy warnings --- common/src/str.rs | 5 ++--- vm/src/builtins/str.rs | 2 +- vm/src/bytesinner.rs | 6 +++++- vm/src/format.rs | 2 +- vm/src/stdlib/builtins.rs | 2 +- vm/src/stdlib/io.rs | 2 +- vm/src/stdlib/itertools.rs | 3 ++- vm/src/stdlib/os.rs | 2 +- vm/src/stdlib/posix.rs | 3 +-- vm/src/vm/interpreter.rs | 2 +- 10 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common/src/str.rs b/common/src/str.rs index 66dccf470..31ab144d7 100644 --- a/common/src/str.rs +++ b/common/src/str.rs @@ -312,7 +312,7 @@ impl Repr<'_> { repr.write_str(s)?; } else { for ch in s.chars() { - let res = match ch { + match ch { '\n' => repr.write_str("\\n"), '\t' => repr.write_str("\\t"), '\r' => repr.write_str("\\r"), @@ -338,8 +338,7 @@ impl Repr<'_> { _ => { write!(repr, "\\U{:08x}", ch as u32) } - }; - let () = res?; + }?; } } repr.write_char(quote) diff --git a/vm/src/builtins/str.rs b/vm/src/builtins/str.rs index 4d1411248..e24f700a1 100644 --- a/vm/src/builtins/str.rs +++ b/vm/src/builtins/str.rs @@ -734,7 +734,7 @@ impl PyStr { let s = self.as_str(); !s.is_empty() && s.chars() - .filter(|c| !c.is_digit(10)) + .filter(|c| !c.is_ascii_digit()) .all(|c| valid_unicodes.contains(&(c as u16))) } diff --git a/vm/src/bytesinner.rs b/vm/src/bytesinner.rs index 8cc60ffeb..87b67a92a 100644 --- a/vm/src/bytesinner.rs +++ b/vm/src/bytesinner.rs @@ -307,7 +307,11 @@ impl PyBytesInner { } pub fn isdigit(&self) -> bool { - !self.elements.is_empty() && self.elements.iter().all(|x| char::from(*x).is_digit(10)) + !self.elements.is_empty() + && self + .elements + .iter() + .all(|x| char::from(*x).is_ascii_digit()) } pub fn islower(&self) -> bool { diff --git a/vm/src/format.rs b/vm/src/format.rs index f756bb096..954ea5763 100644 --- a/vm/src/format.rs +++ b/vm/src/format.rs @@ -120,7 +120,7 @@ pub(crate) struct FormatSpec { pub(crate) fn get_num_digits(text: &str) -> usize { for (index, character) in text.char_indices() { - if !character.is_digit(10) { + if !character.is_ascii_digit() { return index; } } diff --git a/vm/src/stdlib/builtins.rs b/vm/src/stdlib/builtins.rs index f0c739c7d..d7bfc94c7 100644 --- a/vm/src/stdlib/builtins.rs +++ b/vm/src/stdlib/builtins.rs @@ -920,7 +920,7 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) { crate::protocol::VecBuffer::make_class(&vm.ctx); - let _ = builtins::extend_module(vm, &module); + builtins::extend_module(vm, &module); let debug_mode: bool = vm.state.settings.optimize == 0; extend_module!(vm, module, { diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index 3473c32a8..a18dabb9b 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -1280,7 +1280,7 @@ mod _io { } } if self.writable() { - let _ = self.flush_rewind(vm)?; + self.flush_rewind(vm)?; } self.reset_read(); self.pos = 0; diff --git a/vm/src/stdlib/itertools.rs b/vm/src/stdlib/itertools.rs index 95ef9dd70..bd4de3ce0 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -316,7 +316,8 @@ mod decl { fn repr(&self, vm: &VirtualMachine) -> PyResult { let mut fmt = format!("{}", &self.object.repr(vm)?); if let Some(ref times) = self.times { - fmt.push_str(&format!(", {}", times.read())); + fmt.push_str(", "); + fmt.push_str(×.read().to_string()); } Ok(format!("repeat({})", fmt)) } diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 32f8d3bea..a0ee7c509 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -1763,7 +1763,7 @@ pub(crate) struct SupportFunc { follow_symlinks: Option, } -impl<'a> SupportFunc { +impl SupportFunc { pub(crate) fn new( name: &'static str, fd: Option, diff --git a/vm/src/stdlib/posix.rs b/vm/src/stdlib/posix.rs index f72a4b4fe..717d10e8d 100644 --- a/vm/src/stdlib/posix.rs +++ b/vm/src/stdlib/posix.rs @@ -516,8 +516,7 @@ pub mod module { #[pyfunction] fn sched_yield(vm: &VirtualMachine) -> PyResult<()> { - let _ = nix::sched::sched_yield().map_err(|e| e.to_pyexception(vm))?; - Ok(()) + nix::sched::sched_yield().map_err(|e| e.to_pyexception(vm)) } #[pyattr] diff --git a/vm/src/vm/interpreter.rs b/vm/src/vm/interpreter.rs index fa9d7cb1e..d1955abc2 100644 --- a/vm/src/vm/interpreter.rs +++ b/vm/src/vm/interpreter.rs @@ -71,7 +71,7 @@ impl Interpreter { .map_err(|exc| vm.handle_exit_exception(exc)) .unwrap_or_else(|code| code); - let _ = atexit::_run_exitfuncs(vm); + atexit::_run_exitfuncs(vm); flush_std(vm);