Skip to content

Fix stable clippy #5843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn benchmark_file_parsing(group: &mut BenchmarkGroup<WallTime>, name: &str,
pub fn benchmark_pystone(group: &mut BenchmarkGroup<WallTime>, contents: String) {
// Default is 50_000. This takes a while, so reduce it to 30k.
for idx in (10_000..=30_000).step_by(10_000) {
let code_with_loops = format!("LOOPS = {}\n{}", idx, contents);
let code_with_loops = format!("LOOPS = {idx}\n{contents}");
let code_str = code_with_loops.as_str();

group.throughput(Throughput::Elements(idx as u64));
Expand Down
2 changes: 1 addition & 1 deletion compiler/literal/src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ fn test_to_hex() {
// println!("{} -> {}", f, hex);
let roundtrip = hexf_parse::parse_hexf64(&hex, false).unwrap();
// println!(" -> {}", roundtrip);
assert!(f == roundtrip, "{} {} {}", f, hex, roundtrip);
assert!(f == roundtrip, "{f} {hex} {roundtrip}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/dis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() -> Result<(), lexopt::Error> {
if script.exists() && script.is_file() {
let res = display_script(script, mode, opts.clone(), expand_code_objects);
if let Err(e) = res {
error!("Error while compiling {:?}: {}", script, e);
error!("Error while compiling {script:?}: {e}");
}
} else {
eprintln!("{script:?} is not a file.");
Expand Down
8 changes: 4 additions & 4 deletions examples/parse_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@

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

Expand All @@ -56,7 +56,7 @@
let parsed_file = parse_python_file(&path);
match &parsed_file.result {
Ok(_) => {}
Err(y) => error!("Erreur in file {:?} {:?}", path, y),
Err(y) => error!("Erreur in file {path:?} {y:?}"),

Check warning on line 59 in examples/parse_folder.rs

View workflow job for this annotation

GitHub Actions / Check Rust code with rustfmt and clippy

Unknown word (Erreur)
}

res.push(parsed_file);
Expand All @@ -66,7 +66,7 @@
}

fn parse_python_file(filename: &Path) -> ParsedFile {
info!("Parsing file {:?}", filename);
info!("Parsing file {filename:?}");
match std::fs::read_to_string(filename) {
Err(e) => ParsedFile {
num_lines: 0,
Expand Down
2 changes: 1 addition & 1 deletion jit/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl StackMachine {
if let Some(StackValue::Function(function)) = self.locals.get(name) {
function.clone()
} else {
panic!("There was no function named {}", name)
panic!("There was no function named {name}")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ mod array {

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

Expand Down
7 changes: 3 additions & 4 deletions vm/src/builtins/genericalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,9 @@ pub fn subs_parameters<F: Fn(&VirtualMachine) -> PyResult<String>>(
new_args.push(substituted);
} else {
// CPython doesn't support default values in this context
return Err(vm.new_type_error(format!(
"No argument provided for parameter at index {}",
idx
)));
return Err(
vm.new_type_error(format!("No argument provided for parameter at index {idx}"))
);
}
} else {
new_args.push(subs_tvars(arg.clone(), &parameters, arg_items, vm)?);
Expand Down
11 changes: 7 additions & 4 deletions vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ impl ExecutingFrame<'_> {
}

fn run(&mut self, vm: &VirtualMachine) -> PyResult<ExecutionResult> {
flame_guard!(format!("Frame::run({})", self.code.obj_name));
flame_guard!(format!(
"Frame::run({obj_name})",
obj_name = self.code.obj_name
));
// Execute until return or exception:
let instructions = &self.code.instructions;
let mut arg_state = bytecode::OpArgState::default();
Expand Down Expand Up @@ -941,7 +944,7 @@ impl ExecutingFrame<'_> {
.get_attr(identifier!(vm, __exit__), vm)
.map_err(|_exc| {
vm.new_type_error({
format!("'{} (missed __exit__ method)", error_string())
format!("{} (missed __exit__ method)", error_string())
})
})?;
self.push_value(exit);
Expand All @@ -968,7 +971,7 @@ impl ExecutingFrame<'_> {
.get_attr(identifier!(vm, __aexit__), vm)
.map_err(|_exc| {
vm.new_type_error({
format!("'{} (missed __aexit__ method)", error_string())
format!("{} (missed __aexit__ method)", error_string())
})
})?;
self.push_value(aexit);
Expand Down Expand Up @@ -1638,7 +1641,7 @@ impl ExecutingFrame<'_> {
F: FnMut(PyObjectRef) -> PyResult<()>,
{
let Some(keys_method) = vm.get_method(mapping.clone(), vm.ctx.intern_str("keys")) else {
return Err(vm.new_type_error(format!("{} must be a mapping", error_prefix)));
return Err(vm.new_type_error(format!("{error_prefix} must be a mapping")));
};

let keys = keys_method?.call((), vm)?.get_iter(vm)?;
Expand Down
12 changes: 9 additions & 3 deletions vm/src/stdlib/functools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ mod _functools {
key.str(vm)?.as_str().to_owned()
};
let value_str = value.repr(vm)?;
parts.push(format!("{}={}", key_part, value_str.as_str()));
parts.push(format!(
"{key_part}={value_str}",
value_str = value_str.as_str()
));
}

let class_name = zelf.class().name();
Expand All @@ -306,14 +309,17 @@ mod _functools {
// For test modules, just use the class name without module prefix
class_name.to_owned()
}
_ => format!("{}.{}", module_name, class_name),
_ => format!("{module_name}.{class_name}"),
}
}
Err(_) => class_name.to_owned(),
}
};

Ok(format!("{}({})", qualified_name, parts.join(", ")))
Ok(format!(
"{qualified_name}({parts})",
parts = parts.join(", ")
))
} else {
Ok("...".to_owned())
}
Expand Down
5 changes: 2 additions & 3 deletions vm/src/stdlib/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,10 @@ mod sys {
let type_name = exc_val.class().name();
// TODO: fix error message
let msg = format!(
"TypeError: print_exception(): Exception expected for value, {} found\n",
type_name
"TypeError: print_exception(): Exception expected for value, {type_name} found\n"
);
use crate::py_io::Write;
write!(&mut crate::py_io::PyWriter(stderr, vm), "{}", msg)?;
write!(&mut crate::py_io::PyWriter(stderr, vm), "{msg}")?;
Ok(())
}
}
Expand Down
12 changes: 6 additions & 6 deletions vm/src/stdlib/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ pub(crate) mod decl {
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
let name = zelf.name.str(vm)?;
let repr = if zelf.covariant {
format!("+{}", name)
format!("+{name}")
} else if zelf.contravariant {
format!("-{}", name)
format!("-{name}")
} else {
format!("~{}", name)
format!("~{name}")
};
Ok(repr)
}
Expand Down Expand Up @@ -738,7 +738,7 @@ pub(crate) mod decl {
#[inline(always)]
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
let name = zelf.name.str(vm)?;
Ok(format!("*{}", name))
Ok(format!("*{name}"))
}
}

Expand Down Expand Up @@ -785,7 +785,7 @@ pub(crate) mod decl {
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
// Check if origin is a ParamSpec
if let Ok(name) = zelf.__origin__.get_attr("__name__", vm) {
return Ok(format!("{}.args", name.str(vm)?));
return Ok(format!("{name}.args", name = name.str(vm)?));
}
Ok(format!("{:?}.args", zelf.__origin__))
}
Expand Down Expand Up @@ -864,7 +864,7 @@ pub(crate) mod decl {
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
// Check if origin is a ParamSpec
if let Ok(name) = zelf.__origin__.get_attr("__name__", vm) {
return Ok(format!("{}.kwargs", name.str(vm)?));
return Ok(format!("{name}.kwargs", name = name.str(vm)?));
}
Ok(format!("{:?}.kwargs", zelf.__origin__))
}
Expand Down
4 changes: 2 additions & 2 deletions vm/src/vm/vm_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl VirtualMachine {
let mut s = String::new();
self.write_exception(&mut s, &exc).unwrap();
error(&s);
panic!("{}; exception backtrace above", msg)
panic!("{msg}; exception backtrace above")
}
#[cfg(all(
target_arch = "wasm32",
Expand All @@ -49,7 +49,7 @@ impl VirtualMachine {
use crate::convert::ToPyObject;
let err_string: String = exc.to_pyobject(self).repr(self).unwrap().to_string();
eprintln!("{err_string}");
panic!("{}; python exception not available", msg)
panic!("{msg}; python exception not available")
}
}

Expand Down
3 changes: 3 additions & 0 deletions wasm/wasm-unknown-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ getrandom = "0.3"
rustpython-vm = { path = "../../vm", default-features = false, features = ["compiler"] }

[workspace]

[patch.crates-io]
radium = { version = "1.1.0", git = "https://github.com/youknowone/ferrilab", branch = "fix-nightly" }
Loading