Skip to content

Commit 13e33b6

Browse files
committed
Fix stable clippy
1 parent 0d492a6 commit 13e33b6

File tree

7 files changed

+36
-23
lines changed

7 files changed

+36
-23
lines changed

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: 13 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,10 @@ 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!(
948+
"'{error_string} (missed __exit__ method)",
949+
error_string = error_string()
950+
)
945951
})
946952
})?;
947953
self.push_value(exit);
@@ -968,7 +974,10 @@ impl ExecutingFrame<'_> {
968974
.get_attr(identifier!(vm, __aexit__), vm)
969975
.map_err(|_exc| {
970976
vm.new_type_error({
971-
format!("'{} (missed __aexit__ method)", error_string())
977+
format!(
978+
"'{error_string} (missed __aexit__ method)",
979+
error_string = error_string()
980+
)
972981
})
973982
})?;
974983
self.push_value(aexit);
@@ -1638,7 +1647,7 @@ impl ExecutingFrame<'_> {
16381647
F: FnMut(PyObjectRef) -> PyResult<()>,
16391648
{
16401649
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)));
1650+
return Err(vm.new_type_error(format!("{error_prefix} must be a mapping")));
16421651
};
16431652

16441653
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

0 commit comments

Comments
 (0)