Skip to content

Commit e1ab8a9

Browse files
authored
Fix clippy issues for rust 1.67 (RustPython#4478)
1 parent c0ab8e8 commit e1ab8a9

File tree

8 files changed

+18
-25
lines changed

8 files changed

+18
-25
lines changed

stdlib/src/sqlite.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,13 @@ mod _sqlite {
557557
context.result_exception(
558558
vm,
559559
exc,
560-
&format!("user-defined aggregate's '{}' method not defined\0", name),
560+
&format!("user-defined aggregate's '{name}' method not defined\0"),
561561
)
562562
} else {
563563
context.result_exception(
564564
vm,
565565
exc,
566-
&format!("user-defined aggregate's '{}' method raised error\0", name),
566+
&format!("user-defined aggregate's '{name}' method raised error\0"),
567567
)
568568
}
569569
}
@@ -591,13 +591,13 @@ mod _sqlite {
591591
context.result_exception(
592592
vm,
593593
exc,
594-
&format!("user-defined aggregate's '{}' method not defined\0", name),
594+
&format!("user-defined aggregate's '{name}' method not defined\0"),
595595
)
596596
} else {
597597
context.result_exception(
598598
vm,
599599
exc,
600-
&format!("user-defined aggregate's '{}' method raised error\0", name),
600+
&format!("user-defined aggregate's '{name}' method raised error\0"),
601601
)
602602
}
603603
}
@@ -1739,8 +1739,7 @@ mod _sqlite {
17391739
}
17401740
_ => {
17411741
return Err(vm.new_not_implemented_error(format!(
1742-
"unknown column type: {}",
1743-
col_type
1742+
"unknown column type: {col_type}"
17441743
)));
17451744
}
17461745
}

vm/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() {
55
#[cfg(feature = "freeze-stdlib")]
66
for entry in glob::glob("Lib/*/*.py").expect("Lib/ exists?").flatten() {
77
let display = entry.display();
8-
println!("cargo:rerun-if-changed={}", display);
8+
println!("cargo:rerun-if-changed={display}");
99
}
1010

1111
println!("cargo:rustc-env=RUSTPYTHON_GIT_HASH={}", git_hash());

vm/src/builtins/function/jitfunc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn get_jit_arg_type(dict: &PyDictRef, name: &str, vm: &VirtualMachine) -> PyResu
5858
}
5959
} else {
6060
Err(new_jit_error(
61-
format!("argument {} needs annotation", name),
61+
format!("argument {name} needs annotation"),
6262
vm,
6363
))
6464
}

vm/src/format.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ impl IntoPyException for FormatSpecError {
1818
vm.new_value_error("Invalid format specifier".to_owned())
1919
}
2020
FormatSpecError::UnspecifiedFormat(c1, c2) => {
21-
let msg = format!("Cannot specify '{}' with '{}'.", c1, c2);
21+
let msg = format!("Cannot specify '{c1}' with '{c2}'.");
2222
vm.new_value_error(msg)
2323
}
2424
FormatSpecError::UnknownFormatCode(c, s) => {
25-
let msg = format!("Unknown format code '{}' for object of type '{}'", c, s);
25+
let msg = format!("Unknown format code '{c}' for object of type '{s}'");
2626
vm.new_value_error(msg)
2727
}
2828
FormatSpecError::PrecisionNotAllowed => {
2929
vm.new_value_error("Precision not allowed in integer format specifier".to_owned())
3030
}
3131
FormatSpecError::NotAllowed(s) => {
32-
let msg = format!("{} not allowed with integer format specifier 'c'", s);
32+
let msg = format!("{s} not allowed with integer format specifier 'c'");
3333
vm.new_value_error(msg)
3434
}
3535
FormatSpecError::UnableToConvert => {
@@ -39,10 +39,7 @@ impl IntoPyException for FormatSpecError {
3939
vm.new_overflow_error("%c arg not in range(0x110000)".to_owned())
4040
}
4141
FormatSpecError::NotImplemented(c, s) => {
42-
let msg = format!(
43-
"Format code '{}' for object of type '{}' not implemented yet",
44-
c, s
45-
);
42+
let msg = format!("Format code '{c}' for object of type '{s}' not implemented yet");
4643
vm.new_value_error(msg)
4744
}
4845
}

vm/src/stdlib/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ pub(super) mod _os {
16731673
Err(vm.new_value_error(format!("Invalid wait status: {status}")))
16741674
} else {
16751675
i32::try_from(status.rotate_right(8))
1676-
.map_err(|_| vm.new_value_error(format!("invalid wait status: {}", status)))
1676+
.map_err(|_| vm.new_value_error(format!("invalid wait status: {status}")))
16771677
}
16781678
}
16791679
}
@@ -1694,7 +1694,7 @@ pub(super) mod _os {
16941694
_ => 0,
16951695
};
16961696

1697-
Ok(Some(format!("cp{}", cp)))
1697+
Ok(Some(format!("cp{cp}")))
16981698
} else {
16991699
let encoding = unsafe {
17001700
let encoding = libc::nl_langinfo(libc::CODESET);

vm/src/stdlib/posix.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,7 @@ pub mod module {
571571
let priority_type = priority_class.name();
572572
let priority = self.sched_priority.clone();
573573
let value = priority.downcast::<PyInt>().map_err(|_| {
574-
vm.new_type_error(format!(
575-
"an integer is required (got type {})",
576-
priority_type
577-
))
574+
vm.new_type_error(format!("an integer is required (got type {priority_type})"))
578575
})?;
579576
let sched_priority = value.try_to_primitive(vm)?;
580577
Ok(libc::sched_param { sched_priority })
@@ -1991,7 +1988,7 @@ pub mod module {
19911988
#[pyfunction]
19921989
fn getrandom(size: isize, flags: OptionalArg<u32>, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
19931990
let size = usize::try_from(size)
1994-
.map_err(|_| vm.new_os_error(format!("Invalid argument for size: {}", size)))?;
1991+
.map_err(|_| vm.new_os_error(format!("Invalid argument for size: {size}")))?;
19951992
let mut buf = Vec::with_capacity(size);
19961993
unsafe {
19971994
let len = sys_getrandom(

wasm/lib/src/convert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn js_err_to_py_err(vm: &VirtualMachine, js_err: &JsValue) -> PyBaseExceptio
7272
}
7373
None => vm.new_exception_msg(
7474
vm.ctx.exceptions.exception_type.to_owned(),
75-
format!("{:?}", js_err),
75+
format!("{js_err:?}"),
7676
),
7777
}
7878
}
@@ -246,7 +246,7 @@ pub fn js_to_py(vm: &VirtualMachine, js_val: JsValue) -> PyObjectRef {
246246
}
247247

248248
pub fn syntax_err(err: CompileError) -> SyntaxError {
249-
let js_err = SyntaxError::new(&format!("Error parsing Python code: {}", err));
249+
let js_err = SyntaxError::new(&format!("Error parsing Python code: {err}"));
250250
let _ = Reflect::set(&js_err, &"row".into(), &(err.location.row() as u32).into());
251251
let _ = Reflect::set(
252252
&js_err,

wasm/lib/src/js_module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ mod _js {
160160
.map(PyJsValue::new)
161161
.map_err(|err| new_js_error(vm, err))
162162
} else {
163-
Err(vm.new_attribute_error(format!("No attribute {:?} on JS value", name)))
163+
Err(vm.new_attribute_error(format!("No attribute {name:?} on JS value")))
164164
}
165165
}
166166

0 commit comments

Comments
 (0)