Skip to content

Commit fe2c9bf

Browse files
authored
Fix stable clippy (#5843)
1 parent 0d492a6 commit fe2c9bf

File tree

13 files changed

+41
-31
lines changed

13 files changed

+41
-31
lines changed

benches/execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn benchmark_file_parsing(group: &mut BenchmarkGroup<WallTime>, name: &str,
7171
pub fn benchmark_pystone(group: &mut BenchmarkGroup<WallTime>, contents: String) {
7272
// Default is 50_000. This takes a while, so reduce it to 30k.
7373
for idx in (10_000..=30_000).step_by(10_000) {
74-
let code_with_loops = format!("LOOPS = {}\n{}", idx, contents);
74+
let code_with_loops = format!("LOOPS = {idx}\n{contents}");
7575
let code_str = code_with_loops.as_str();
7676

7777
group.throughput(Throughput::Elements(idx as u64));

compiler/literal/src/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ fn test_to_hex() {
261261
// println!("{} -> {}", f, hex);
262262
let roundtrip = hexf_parse::parse_hexf64(&hex, false).unwrap();
263263
// println!(" -> {}", roundtrip);
264-
assert!(f == roundtrip, "{} {} {}", f, hex, roundtrip);
264+
assert!(f == roundtrip, "{f} {hex} {roundtrip}");
265265
}
266266
}
267267

examples/dis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn main() -> Result<(), lexopt::Error> {
5959
if script.exists() && script.is_file() {
6060
let res = display_script(script, mode, opts.clone(), expand_code_objects);
6161
if let Err(e) = res {
62-
error!("Error while compiling {:?}: {}", script, e);
62+
error!("Error while compiling {script:?}: {e}");
6363
}
6464
} else {
6565
eprintln!("{script:?} is not a file.");

examples/parse_folder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ fn main() {
4141

4242
fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> {
4343
let mut res = vec![];
44-
info!("Parsing folder of python code: {:?}", path);
44+
info!("Parsing folder of python code: {path:?}");
4545
for entry in path.read_dir()? {
46-
debug!("Entry: {:?}", entry);
46+
debug!("Entry: {entry:?}");
4747
let entry = entry?;
4848
let metadata = entry.metadata()?;
4949

@@ -56,7 +56,7 @@ fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> {
5656
let parsed_file = parse_python_file(&path);
5757
match &parsed_file.result {
5858
Ok(_) => {}
59-
Err(y) => error!("Erreur in file {:?} {:?}", path, y),
59+
Err(y) => error!("Erreur in file {path:?} {y:?}"),
6060
}
6161

6262
res.push(parsed_file);
@@ -66,7 +66,7 @@ fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> {
6666
}
6767

6868
fn parse_python_file(filename: &Path) -> ParsedFile {
69-
info!("Parsing file {:?}", filename);
69+
info!("Parsing file {filename:?}");
7070
match std::fs::read_to_string(filename) {
7171
Err(e) => ParsedFile {
7272
num_lines: 0,

jit/tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl StackMachine {
172172
if let Some(StackValue::Function(function)) = self.locals.get(name) {
173173
function.clone()
174174
} else {
175-
panic!("There was no function named {}", name)
175+
panic!("There was no function named {name}")
176176
}
177177
}
178178
}

stdlib/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ mod array {
601601

602602
fn try_from(ch: WideChar) -> Result<Self, Self::Error> {
603603
// safe because every configuration of bytes for the types we support are valid
604-
u32_to_char(ch.0 as u32)
604+
u32_to_char(ch.0 as _)
605605
}
606606
}
607607

vm/src/builtins/genericalias.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,9 @@ pub fn subs_parameters<F: Fn(&VirtualMachine) -> PyResult<String>>(
388388
new_args.push(substituted);
389389
} else {
390390
// CPython doesn't support default values in this context
391-
return Err(vm.new_type_error(format!(
392-
"No argument provided for parameter at index {}",
393-
idx
394-
)));
391+
return Err(
392+
vm.new_type_error(format!("No argument provided for parameter at index {idx}"))
393+
);
395394
}
396395
} else {
397396
new_args.push(subs_tvars(arg.clone(), &parameters, arg_items, vm)?);

vm/src/frame.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ impl ExecutingFrame<'_> {
349349
}
350350

351351
fn run(&mut self, vm: &VirtualMachine) -> PyResult<ExecutionResult> {
352-
flame_guard!(format!("Frame::run({})", self.code.obj_name));
352+
flame_guard!(format!(
353+
"Frame::run({obj_name})",
354+
obj_name = self.code.obj_name
355+
));
353356
// Execute until return or exception:
354357
let instructions = &self.code.instructions;
355358
let mut arg_state = bytecode::OpArgState::default();
@@ -941,7 +944,7 @@ impl ExecutingFrame<'_> {
941944
.get_attr(identifier!(vm, __exit__), vm)
942945
.map_err(|_exc| {
943946
vm.new_type_error({
944-
format!("'{} (missed __exit__ method)", error_string())
947+
format!("{} (missed __exit__ method)", error_string())
945948
})
946949
})?;
947950
self.push_value(exit);
@@ -968,7 +971,7 @@ impl ExecutingFrame<'_> {
968971
.get_attr(identifier!(vm, __aexit__), vm)
969972
.map_err(|_exc| {
970973
vm.new_type_error({
971-
format!("'{} (missed __aexit__ method)", error_string())
974+
format!("{} (missed __aexit__ method)", error_string())
972975
})
973976
})?;
974977
self.push_value(aexit);
@@ -1638,7 +1641,7 @@ impl ExecutingFrame<'_> {
16381641
F: FnMut(PyObjectRef) -> PyResult<()>,
16391642
{
16401643
let Some(keys_method) = vm.get_method(mapping.clone(), vm.ctx.intern_str("keys")) else {
1641-
return Err(vm.new_type_error(format!("{} must be a mapping", error_prefix)));
1644+
return Err(vm.new_type_error(format!("{error_prefix} must be a mapping")));
16421645
};
16431646

16441647
let keys = keys_method?.call((), vm)?.get_iter(vm)?;

vm/src/stdlib/functools.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ mod _functools {
286286
key.str(vm)?.as_str().to_owned()
287287
};
288288
let value_str = value.repr(vm)?;
289-
parts.push(format!("{}={}", key_part, value_str.as_str()));
289+
parts.push(format!(
290+
"{key_part}={value_str}",
291+
value_str = value_str.as_str()
292+
));
290293
}
291294

292295
let class_name = zelf.class().name();
@@ -306,14 +309,17 @@ mod _functools {
306309
// For test modules, just use the class name without module prefix
307310
class_name.to_owned()
308311
}
309-
_ => format!("{}.{}", module_name, class_name),
312+
_ => format!("{module_name}.{class_name}"),
310313
}
311314
}
312315
Err(_) => class_name.to_owned(),
313316
}
314317
};
315318

316-
Ok(format!("{}({})", qualified_name, parts.join(", ")))
319+
Ok(format!(
320+
"{qualified_name}({parts})",
321+
parts = parts.join(", ")
322+
))
317323
} else {
318324
Ok("...".to_owned())
319325
}

vm/src/stdlib/sys.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,10 @@ mod sys {
373373
let type_name = exc_val.class().name();
374374
// TODO: fix error message
375375
let msg = format!(
376-
"TypeError: print_exception(): Exception expected for value, {} found\n",
377-
type_name
376+
"TypeError: print_exception(): Exception expected for value, {type_name} found\n"
378377
);
379378
use crate::py_io::Write;
380-
write!(&mut crate::py_io::PyWriter(stderr, vm), "{}", msg)?;
379+
write!(&mut crate::py_io::PyWriter(stderr, vm), "{msg}")?;
381380
Ok(())
382381
}
383382
}

vm/src/stdlib/typing.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ pub(crate) mod decl {
171171
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
172172
let name = zelf.name.str(vm)?;
173173
let repr = if zelf.covariant {
174-
format!("+{}", name)
174+
format!("+{name}")
175175
} else if zelf.contravariant {
176-
format!("-{}", name)
176+
format!("-{name}")
177177
} else {
178-
format!("~{}", name)
178+
format!("~{name}")
179179
};
180180
Ok(repr)
181181
}
@@ -738,7 +738,7 @@ pub(crate) mod decl {
738738
#[inline(always)]
739739
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
740740
let name = zelf.name.str(vm)?;
741-
Ok(format!("*{}", name))
741+
Ok(format!("*{name}"))
742742
}
743743
}
744744

@@ -785,7 +785,7 @@ pub(crate) mod decl {
785785
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
786786
// Check if origin is a ParamSpec
787787
if let Ok(name) = zelf.__origin__.get_attr("__name__", vm) {
788-
return Ok(format!("{}.args", name.str(vm)?));
788+
return Ok(format!("{name}.args", name = name.str(vm)?));
789789
}
790790
Ok(format!("{:?}.args", zelf.__origin__))
791791
}
@@ -864,7 +864,7 @@ pub(crate) mod decl {
864864
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
865865
// Check if origin is a ParamSpec
866866
if let Ok(name) = zelf.__origin__.get_attr("__name__", vm) {
867-
return Ok(format!("{}.kwargs", name.str(vm)?));
867+
return Ok(format!("{name}.kwargs", name = name.str(vm)?));
868868
}
869869
Ok(format!("{:?}.kwargs", zelf.__origin__))
870870
}

vm/src/vm/vm_object.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl VirtualMachine {
3838
let mut s = String::new();
3939
self.write_exception(&mut s, &exc).unwrap();
4040
error(&s);
41-
panic!("{}; exception backtrace above", msg)
41+
panic!("{msg}; exception backtrace above")
4242
}
4343
#[cfg(all(
4444
target_arch = "wasm32",
@@ -49,7 +49,7 @@ impl VirtualMachine {
4949
use crate::convert::ToPyObject;
5050
let err_string: String = exc.to_pyobject(self).repr(self).unwrap().to_string();
5151
eprintln!("{err_string}");
52-
panic!("{}; python exception not available", msg)
52+
panic!("{msg}; python exception not available")
5353
}
5454
}
5555

wasm/wasm-unknown-test/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ getrandom = "0.3"
1111
rustpython-vm = { path = "../../vm", default-features = false, features = ["compiler"] }
1212

1313
[workspace]
14+
15+
[patch.crates-io]
16+
radium = { version = "1.1.0", git = "https://github.com/youknowone/ferrilab", branch = "fix-nightly" }

0 commit comments

Comments
 (0)