Skip to content

Commit fbf45e1

Browse files
authored
Merge pull request RustPython#3690 from youknowone/clippy
fix clippy warnings
2 parents 2ba1d93 + c9f1f61 commit fbf45e1

File tree

10 files changed

+16
-13
lines changed

10 files changed

+16
-13
lines changed

common/src/str.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl Repr<'_> {
312312
repr.write_str(s)?;
313313
} else {
314314
for ch in s.chars() {
315-
let res = match ch {
315+
match ch {
316316
'\n' => repr.write_str("\\n"),
317317
'\t' => repr.write_str("\\t"),
318318
'\r' => repr.write_str("\\r"),
@@ -338,8 +338,7 @@ impl Repr<'_> {
338338
_ => {
339339
write!(repr, "\\U{:08x}", ch as u32)
340340
}
341-
};
342-
let () = res?;
341+
}?;
343342
}
344343
}
345344
repr.write_char(quote)

vm/src/builtins/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ impl PyStr {
734734
let s = self.as_str();
735735
!s.is_empty()
736736
&& s.chars()
737-
.filter(|c| !c.is_digit(10))
737+
.filter(|c| !c.is_ascii_digit())
738738
.all(|c| valid_unicodes.contains(&(c as u16)))
739739
}
740740

vm/src/bytesinner.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ impl PyBytesInner {
307307
}
308308

309309
pub fn isdigit(&self) -> bool {
310-
!self.elements.is_empty() && self.elements.iter().all(|x| char::from(*x).is_digit(10))
310+
!self.elements.is_empty()
311+
&& self
312+
.elements
313+
.iter()
314+
.all(|x| char::from(*x).is_ascii_digit())
311315
}
312316

313317
pub fn islower(&self) -> bool {

vm/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub(crate) struct FormatSpec {
120120

121121
pub(crate) fn get_num_digits(text: &str) -> usize {
122122
for (index, character) in text.char_indices() {
123-
if !character.is_digit(10) {
123+
if !character.is_ascii_digit() {
124124
return index;
125125
}
126126
}

vm/src/stdlib/builtins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) {
920920

921921
crate::protocol::VecBuffer::make_class(&vm.ctx);
922922

923-
let _ = builtins::extend_module(vm, &module);
923+
builtins::extend_module(vm, &module);
924924

925925
let debug_mode: bool = vm.state.settings.optimize == 0;
926926
extend_module!(vm, module, {

vm/src/stdlib/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ mod _io {
12801280
}
12811281
}
12821282
if self.writable() {
1283-
let _ = self.flush_rewind(vm)?;
1283+
self.flush_rewind(vm)?;
12841284
}
12851285
self.reset_read();
12861286
self.pos = 0;

vm/src/stdlib/itertools.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ mod decl {
316316
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
317317
let mut fmt = format!("{}", &self.object.repr(vm)?);
318318
if let Some(ref times) = self.times {
319-
fmt.push_str(&format!(", {}", times.read()));
319+
fmt.push_str(", ");
320+
fmt.push_str(&times.read().to_string());
320321
}
321322
Ok(format!("repeat({})", fmt))
322323
}

vm/src/stdlib/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ pub(crate) struct SupportFunc {
17631763
follow_symlinks: Option<bool>,
17641764
}
17651765

1766-
impl<'a> SupportFunc {
1766+
impl SupportFunc {
17671767
pub(crate) fn new(
17681768
name: &'static str,
17691769
fd: Option<bool>,

vm/src/stdlib/posix.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,7 @@ pub mod module {
516516

517517
#[pyfunction]
518518
fn sched_yield(vm: &VirtualMachine) -> PyResult<()> {
519-
let _ = nix::sched::sched_yield().map_err(|e| e.to_pyexception(vm))?;
520-
Ok(())
519+
nix::sched::sched_yield().map_err(|e| e.to_pyexception(vm))
521520
}
522521

523522
#[pyattr]

vm/src/vm/interpreter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Interpreter {
7171
.map_err(|exc| vm.handle_exit_exception(exc))
7272
.unwrap_or_else(|code| code);
7373

74-
let _ = atexit::_run_exitfuncs(vm);
74+
atexit::_run_exitfuncs(vm);
7575

7676
flush_std(vm);
7777

0 commit comments

Comments
 (0)