fix clippy warnings

This commit is contained in:
Jeong Yunwon
2022-05-07 20:00:57 +09:00
parent 2ba1d93550
commit c9f1f61bae
10 changed files with 16 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1280,7 +1280,7 @@ mod _io {
}
}
if self.writable() {
let _ = self.flush_rewind(vm)?;
self.flush_rewind(vm)?;
}
self.reset_read();
self.pos = 0;

View File

@@ -316,7 +316,8 @@ mod decl {
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
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(&times.read().to_string());
}
Ok(format!("repeat({})", fmt))
}

View File

@@ -1763,7 +1763,7 @@ pub(crate) struct SupportFunc {
follow_symlinks: Option<bool>,
}
impl<'a> SupportFunc {
impl SupportFunc {
pub(crate) fn new(
name: &'static str,
fd: Option<bool>,

View File

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

View File

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