GeezerVison is showing github.com — Fix stable clippy · RustPython/RustPython@5a2da9f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: benches/execution.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -71,7 +71,7 @@ pub fn benchmark_file_parsing(group: &mut BenchmarkGroup<WallTime>, name: &str, | 71 | 71 | pub fn benchmark_pystone(group: &mut BenchmarkGroup<WallTime>, contents: String) { | 72 | 72 | // Default is 50_000. This takes a while, so reduce it to 30k. | 73 | 73 | 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}"); | 75 | 75 | let code_str = code_with_loops.as_str(); | 76 | 76 |
| 77 | 77 | group.throughput(Throughput::Elements(idx as u64)); | |
Collapse file Copy file name to clipboardExpand all lines: compiler/literal/src/float.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -261,7 +261,7 @@ fn test_to_hex() { | 261 | 261 | // println!("{} -> {}", f, hex); | 262 | 262 | let roundtrip = hexf_parse::parse_hexf64(&hex, false).unwrap(); | 263 | 263 | // println!(" -> {}", roundtrip); | 264 | | - assert!(f == roundtrip, "{} {} {}", f, hex, roundtrip); | | 264 | + assert!(f == roundtrip, "{f} {hex} {roundtrip}"); | 265 | 265 | } | 266 | 266 | } | 267 | 267 |
| |
Collapse file Copy file name to clipboardExpand all lines: examples/dis.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,7 +59,7 @@ fn main() -> Result<(), lexopt::Error> { | 59 | 59 | if script.exists() && script.is_file() { | 60 | 60 | let res = display_script(script, mode, opts.clone(), expand_code_objects); | 61 | 61 | if let Err(e) = res { | 62 | | - error!("Error while compiling {:?}: {}", script, e); | | 62 | + error!("Error while compiling {script:?}: {e}"); | 63 | 63 | } | 64 | 64 | } else { | 65 | 65 | eprintln!("{script:?} is not a file."); | |
Collapse file Copy file name to clipboardExpand all lines: examples/parse_folder.rs +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -41,9 +41,9 @@ fn main() { | 41 | 41 |
| 42 | 42 | fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> { | 43 | 43 | let mut res = vec![]; | 44 | | - info!("Parsing folder of python code: {:?}", path); | | 44 | + info!("Parsing folder of python code: {path:?}"); | 45 | 45 | for entry in path.read_dir()? { | 46 | | - debug!("Entry: {:?}", entry); | | 46 | + debug!("Entry: {entry:?}"); | 47 | 47 | let entry = entry?; | 48 | 48 | let metadata = entry.metadata()?; | 49 | 49 |
| @@ -56,7 +56,7 @@ fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> { | 56 | 56 | let parsed_file = parse_python_file(&path); | 57 | 57 | match &parsed_file.result { | 58 | 58 | Ok(_) => {} | 59 | | - Err(y) => error!("Erreur in file {:?} {:?}", path, y), | | 59 | + Err(y) => error!("Erreur in file {path:?} {y:?}"), | 60 | 60 | } | 61 | 61 |
| 62 | 62 | res.push(parsed_file); | @@ -66,7 +66,7 @@ fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> { | 66 | 66 | } | 67 | 67 |
| 68 | 68 | fn parse_python_file(filename: &Path) -> ParsedFile { | 69 | | - info!("Parsing file {:?}", filename); | | 69 | + info!("Parsing file {filename:?}"); | 70 | 70 | match std::fs::read_to_string(filename) { | 71 | 71 | Err(e) => ParsedFile { | 72 | 72 | num_lines: 0, | |
Collapse file Copy file name to clipboardExpand all lines: jit/tests/common.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -172,7 +172,7 @@ impl StackMachine { | 172 | 172 | if let Some(StackValue::Function(function)) = self.locals.get(name) { | 173 | 173 | function.clone() | 174 | 174 | } else { | 175 | | - panic!("There was no function named {}", name) | | 175 | + panic!("There was no function named {name}") | 176 | 176 | } | 177 | 177 | } | 178 | 178 | } | |
Collapse file Copy file name to clipboardExpand all lines: stdlib/src/array.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -601,7 +601,7 @@ mod array { | 601 | 601 |
| 602 | 602 | fn try_from(ch: WideChar) -> Result<Self, Self::Error> { | 603 | 603 | // 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 _) | 605 | 605 | } | 606 | 606 | } | 607 | 607 |
| |
Collapse file Copy file name to clipboardExpand all lines: vm/src/builtins/genericalias.rs +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -388,10 +388,9 @@ pub fn subs_parameters<F: Fn(&VirtualMachine) -> PyResult<String>>( | 388 | 388 | new_args.push(substituted); | 389 | 389 | } else { | 390 | 390 | // 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 | + ); | 395 | 394 | } | 396 | 395 | } else { | 397 | 396 | new_args.push(subs_tvars(arg.clone(), ¶meters, arg_items, vm)?); | |
Collapse file Copy file name to clipboardExpand all lines: vm/src/frame.rs +10-4Lines changed: 10 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -349,7 +349,10 @@ impl ExecutingFrame<'_> { | 349 | 349 | } | 350 | 350 |
| 351 | 351 | 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 | + )); | 353 | 356 | // Execute until return or exception: | 354 | 357 | let instructions = &self.code.instructions; | 355 | 358 | let mut arg_state = bytecode::OpArgState::default(); | @@ -941,7 +944,10 @@ impl ExecutingFrame<'_> { | 941 | 944 | .get_attr(identifier!(vm, __exit__), vm) | 942 | 945 | .map_err(|_exc| { | 943 | 946 | vm.new_type_error({ | 944 | | - format!("'{} (missed __exit__ method)", error_string()) | | 947 | + format!( | | 948 | + "'{error_string} (missed __exit__ method)", | | 949 | + error_string = error_string() | | 950 | + ) | 945 | 951 | }) | 946 | 952 | })?; | 947 | 953 | self.push_value(exit); | @@ -968,7 +974,7 @@ impl ExecutingFrame<'_> { | 968 | 974 | .get_attr(identifier!(vm, __aexit__), vm) | 969 | 975 | .map_err(|_exc| { | 970 | 976 | vm.new_type_error({ | 971 | | - format!("'{} (missed __aexit__ method)", error_string()) | | 977 | + format!("{} (missed __aexit__ method)", error_string()) | 972 | 978 | }) | 973 | 979 | })?; | 974 | 980 | self.push_value(aexit); | @@ -1638,7 +1644,7 @@ impl ExecutingFrame<'_> { | 1638 | 1644 | F: FnMut(PyObjectRef) -> PyResult<()>, | 1639 | 1645 | { | 1640 | 1646 | 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))); | | 1647 | + return Err(vm.new_type_error(format!("{error_prefix} must be a mapping"))); | 1642 | 1648 | }; | 1643 | 1649 |
| 1644 | 1650 | let keys = keys_method?.call((), vm)?.get_iter(vm)?; | |
Collapse file Copy file name to clipboardExpand all lines: vm/src/stdlib/functools.rs +9-3Lines changed: 9 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -286,7 +286,10 @@ mod _functools { | 286 | 286 | key.str(vm)?.as_str().to_owned() | 287 | 287 | }; | 288 | 288 | 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 | + )); | 290 | 293 | } | 291 | 294 |
| 292 | 295 | let class_name = zelf.class().name(); | @@ -306,14 +309,17 @@ mod _functools { | 306 | 309 | // For test modules, just use the class name without module prefix | 307 | 310 | class_name.to_owned() | 308 | 311 | } | 309 | | - _ => format!("{}.{}", module_name, class_name), | | 312 | + _ => format!("{module_name}.{class_name}"), | 310 | 313 | } | 311 | 314 | } | 312 | 315 | Err(_) => class_name.to_owned(), | 313 | 316 | } | 314 | 317 | }; | 315 | 318 |
| 316 | | - Ok(format!("{}({})", qualified_name, parts.join(", "))) | | 319 | + Ok(format!( | | 320 | + "{qualified_name}({parts})", | | 321 | + parts = parts.join(", ") | | 322 | + )) | 317 | 323 | } else { | 318 | 324 | Ok("...".to_owned()) | 319 | 325 | } | |
Collapse file Copy file name to clipboardExpand all lines: vm/src/stdlib/sys.rs +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -373,11 +373,10 @@ mod sys { | 373 | 373 | let type_name = exc_val.class().name(); | 374 | 374 | // TODO: fix error message | 375 | 375 | 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" | 378 | 377 | ); | 379 | 378 | 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}")?; | 381 | 380 | Ok(()) | 382 | 381 | } | 383 | 382 | } | |
|