Skip to content

Commit 011f194

Browse files
committed
Fix nightly clippy warnings
1 parent 4e094ea commit 011f194

File tree

21 files changed

+37
-49
lines changed

21 files changed

+37
-49
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode) -> PyResult<()> {
197197
}
198198
let res = match run_mode {
199199
RunMode::Command(command) => {
200-
debug!("Running command {}", command);
200+
debug!("Running command {command}");
201201
vm.run_code_string(scope.clone(), &command, "<stdin>".to_owned())
202202
.map(drop)
203203
}
204204
RunMode::Module(module) => {
205-
debug!("Running module {}", module);
205+
debug!("Running module {module}");
206206
vm.run_module(&module)
207207
}
208208
RunMode::InstallPip(installer) => install_pip(installer, scope.clone(), vm),

src/shell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
152152
continuing_line = false;
153153
let result = match repl.readline(prompt) {
154154
ReadlineResult::Line(line) => {
155-
debug!("You entered {:?}", line);
155+
debug!("You entered {line:?}");
156156

157157
repl.add_history_entry(line.trim_end()).unwrap();
158158

stdlib/src/binascii.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,7 @@ impl ToPyException for Base64DecodeError {
756756
InvalidLastSymbol(_, PAD) => "Excess data after padding".to_owned(),
757757
InvalidLastSymbol(length, _) => {
758758
format!(
759-
"Invalid base64-encoded string: number of data characters {} cannot be 1 more than a multiple of 4",
760-
length
759+
"Invalid base64-encoded string: number of data characters {length} cannot be 1 more than a multiple of 4"
761760
)
762761
}
763762
// TODO: clean up errors

stdlib/src/csv.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,8 @@ mod _csv {
347347
let arg_len = rest.args.len();
348348
if arg_len != 1 {
349349
return Err(vm.new_type_error(
350-
format!(
351-
"field_size_limit() takes at most 1 argument ({} given)",
352-
arg_len
353-
)
354-
.to_string(),
350+
format!("field_size_limit() takes at most 1 argument ({arg_len} given)")
351+
.to_string(),
355352
));
356353
}
357354
let Ok(new_size) = rest.args.first().unwrap().try_int(vm) else {
@@ -701,7 +698,7 @@ mod _csv {
701698
if let Some(dialect) = g.get(name) {
702699
Ok(self.update_py_dialect(*dialect))
703700
} else {
704-
Err(new_csv_error(vm, format!("{} is not registered.", name)))
701+
Err(new_csv_error(vm, format!("{name} is not registered.")))
705702
}
706703
// TODO
707704
// Maybe need to update the obj from HashMap

vm/src/buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl FormatSpec {
363363
// Loop over all opcodes:
364364
for code in &self.codes {
365365
buffer = &mut buffer[code.pre_padding..];
366-
debug!("code: {:?}", code);
366+
debug!("code: {code:?}");
367367
match code.code {
368368
FormatType::Str => {
369369
let (buf, rest) = buffer.split_at_mut(code.repeat);
@@ -407,7 +407,7 @@ impl FormatSpec {
407407
let mut items = Vec::with_capacity(self.arg_count);
408408
for code in &self.codes {
409409
data = &data[code.pre_padding..];
410-
debug!("unpack code: {:?}", code);
410+
debug!("unpack code: {code:?}");
411411
match code.code {
412412
FormatType::Pad => {
413413
data = &data[code.repeat..];

vm/src/builtins/complex.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ impl PyObjectRef {
6666
warnings::warn(
6767
vm.ctx.exceptions.deprecation_warning,
6868
format!(
69-
"__complex__ returned non-complex (type {}). \
69+
"__complex__ returned non-complex (type {ret_class}). \
7070
The ability to return an instance of a strict subclass of complex \
71-
is deprecated, and may be removed in a future version of Python.",
72-
ret_class
71+
is deprecated, and may be removed in a future version of Python."
7372
),
7473
1,
7574
vm,

vm/src/builtins/object.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ impl Constructor for PyBaseObject {
5353
0 => {}
5454
1 => {
5555
return Err(vm.new_type_error(format!(
56-
"class {} without an implementation for abstract method '{}'",
57-
name, methods
56+
"class {name} without an implementation for abstract method '{methods}'"
5857
)));
5958
}
6059
2.. => {
6160
return Err(vm.new_type_error(format!(
62-
"class {} without an implementation for abstract methods '{}'",
63-
name, methods
61+
"class {name} without an implementation for abstract methods '{methods}'"
6462
)));
6563
}
6664
// TODO: remove `allow` when redox build doesn't complain about it

vm/src/builtins/property.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ impl PyProperty {
132132
let func_args_len = func_args.args.len();
133133
let (_owner, name): (PyObjectRef, PyObjectRef) = func_args.bind(vm).map_err(|_e| {
134134
vm.new_type_error(format!(
135-
"__set_name__() takes 2 positional arguments but {} were given",
136-
func_args_len
135+
"__set_name__() takes 2 positional arguments but {func_args_len} were given"
137136
))
138137
})?;
139138

vm/src/builtins/super.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ impl Initializer for PySuper {
125125
(typ, obj)
126126
};
127127

128-
let mut inner = PySuperInner::new(typ, obj, vm)?;
129-
std::mem::swap(&mut inner, &mut zelf.inner.write());
128+
let inner = PySuperInner::new(typ, obj, vm)?;
129+
*zelf.inner.write() = inner;
130130

131131
Ok(())
132132
}

vm/src/codecs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl StandardEncoding {
419419
match encoding {
420420
"be" => Some(Self::Utf32Be),
421421
"le" => Some(Self::Utf32Le),
422-
_ => return None,
422+
_ => None,
423423
}
424424
} else {
425425
None
@@ -1116,7 +1116,7 @@ fn replace_errors(err: PyObjectRef, vm: &VirtualMachine) -> PyResult<(PyObjectRe
11161116
let replace = replacement_char.repeat(range.end - range.start);
11171117
Ok((replace.to_pyobject(vm), range.end))
11181118
} else {
1119-
return Err(bad_err_type(err, vm));
1119+
Err(bad_err_type(err, vm))
11201120
}
11211121
}
11221122

0 commit comments

Comments
 (0)