mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Fix clippy issues for rust 1.67 (#4478)
This commit is contained in:
1 parent
c0ab8e8256
commit
e1ab8a9b42
8 files changed
+18
-25
No files matched your search
@@ -557,13 +557,13 @@ mod _sqlite {
|
||||
context.result_exception(
|
||||
vm,
|
||||
exc,
|
||||
&format!("user-defined aggregate's '{}' method not defined\0", name),
|
||||
&format!("user-defined aggregate's '{name}' method not defined\0"),
|
||||
)
|
||||
} else {
|
||||
context.result_exception(
|
||||
vm,
|
||||
exc,
|
||||
&format!("user-defined aggregate's '{}' method raised error\0", name),
|
||||
&format!("user-defined aggregate's '{name}' method raised error\0"),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -591,13 +591,13 @@ mod _sqlite {
|
||||
context.result_exception(
|
||||
vm,
|
||||
exc,
|
||||
&format!("user-defined aggregate's '{}' method not defined\0", name),
|
||||
&format!("user-defined aggregate's '{name}' method not defined\0"),
|
||||
)
|
||||
} else {
|
||||
context.result_exception(
|
||||
vm,
|
||||
exc,
|
||||
&format!("user-defined aggregate's '{}' method raised error\0", name),
|
||||
&format!("user-defined aggregate's '{name}' method raised error\0"),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1739,8 +1739,7 @@ mod _sqlite {
|
||||
}
|
||||
_ => {
|
||||
return Err(vm.new_not_implemented_error(format!(
|
||||
"unknown column type: {}",
|
||||
col_type
|
||||
"unknown column type: {col_type}"
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ fn main() {
|
||||
#[cfg(feature = "freeze-stdlib")]
|
||||
for entry in glob::glob("Lib/*/*.py").expect("Lib/ exists?").flatten() {
|
||||
let display = entry.display();
|
||||
println!("cargo:rerun-if-changed={}", display);
|
||||
println!("cargo:rerun-if-changed={display}");
|
||||
}
|
||||
|
||||
println!("cargo:rustc-env=RUSTPYTHON_GIT_HASH={}", git_hash());
|
||||
|
||||
@@ -58,7 +58,7 @@ fn get_jit_arg_type(dict: &PyDictRef, name: &str, vm: &VirtualMachine) -> PyResu
|
||||
}
|
||||
} else {
|
||||
Err(new_jit_error(
|
||||
format!("argument {} needs annotation", name),
|
||||
format!("argument {name} needs annotation"),
|
||||
vm,
|
||||
))
|
||||
}
|
||||
|
||||
+4
-7
@@ -18,18 +18,18 @@ impl IntoPyException for FormatSpecError {
|
||||
vm.new_value_error("Invalid format specifier".to_owned())
|
||||
}
|
||||
FormatSpecError::UnspecifiedFormat(c1, c2) => {
|
||||
let msg = format!("Cannot specify '{}' with '{}'.", c1, c2);
|
||||
let msg = format!("Cannot specify '{c1}' with '{c2}'.");
|
||||
vm.new_value_error(msg)
|
||||
}
|
||||
FormatSpecError::UnknownFormatCode(c, s) => {
|
||||
let msg = format!("Unknown format code '{}' for object of type '{}'", c, s);
|
||||
let msg = format!("Unknown format code '{c}' for object of type '{s}'");
|
||||
vm.new_value_error(msg)
|
||||
}
|
||||
FormatSpecError::PrecisionNotAllowed => {
|
||||
vm.new_value_error("Precision not allowed in integer format specifier".to_owned())
|
||||
}
|
||||
FormatSpecError::NotAllowed(s) => {
|
||||
let msg = format!("{} not allowed with integer format specifier 'c'", s);
|
||||
let msg = format!("{s} not allowed with integer format specifier 'c'");
|
||||
vm.new_value_error(msg)
|
||||
}
|
||||
FormatSpecError::UnableToConvert => {
|
||||
@@ -39,10 +39,7 @@ impl IntoPyException for FormatSpecError {
|
||||
vm.new_overflow_error("%c arg not in range(0x110000)".to_owned())
|
||||
}
|
||||
FormatSpecError::NotImplemented(c, s) => {
|
||||
let msg = format!(
|
||||
"Format code '{}' for object of type '{}' not implemented yet",
|
||||
c, s
|
||||
);
|
||||
let msg = format!("Format code '{c}' for object of type '{s}' not implemented yet");
|
||||
vm.new_value_error(msg)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1673,7 +1673,7 @@ pub(super) mod _os {
|
||||
Err(vm.new_value_error(format!("Invalid wait status: {status}")))
|
||||
} else {
|
||||
i32::try_from(status.rotate_right(8))
|
||||
.map_err(|_| vm.new_value_error(format!("invalid wait status: {}", status)))
|
||||
.map_err(|_| vm.new_value_error(format!("invalid wait status: {status}")))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1694,7 +1694,7 @@ pub(super) mod _os {
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
Ok(Some(format!("cp{}", cp)))
|
||||
Ok(Some(format!("cp{cp}")))
|
||||
} else {
|
||||
let encoding = unsafe {
|
||||
let encoding = libc::nl_langinfo(libc::CODESET);
|
||||
|
||||
@@ -571,10 +571,7 @@ pub mod module {
|
||||
let priority_type = priority_class.name();
|
||||
let priority = self.sched_priority.clone();
|
||||
let value = priority.downcast::<PyInt>().map_err(|_| {
|
||||
vm.new_type_error(format!(
|
||||
"an integer is required (got type {})",
|
||||
priority_type
|
||||
))
|
||||
vm.new_type_error(format!("an integer is required (got type {priority_type})"))
|
||||
})?;
|
||||
let sched_priority = value.try_to_primitive(vm)?;
|
||||
Ok(libc::sched_param { sched_priority })
|
||||
@@ -1991,7 +1988,7 @@ pub mod module {
|
||||
#[pyfunction]
|
||||
fn getrandom(size: isize, flags: OptionalArg<u32>, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
|
||||
let size = usize::try_from(size)
|
||||
.map_err(|_| vm.new_os_error(format!("Invalid argument for size: {}", size)))?;
|
||||
.map_err(|_| vm.new_os_error(format!("Invalid argument for size: {size}")))?;
|
||||
let mut buf = Vec::with_capacity(size);
|
||||
unsafe {
|
||||
let len = sys_getrandom(
|
||||
|
||||
@@ -72,7 +72,7 @@ pub fn js_err_to_py_err(vm: &VirtualMachine, js_err: &JsValue) -> PyBaseExceptio
|
||||
}
|
||||
None => vm.new_exception_msg(
|
||||
vm.ctx.exceptions.exception_type.to_owned(),
|
||||
format!("{:?}", js_err),
|
||||
format!("{js_err:?}"),
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,7 @@ pub fn js_to_py(vm: &VirtualMachine, js_val: JsValue) -> PyObjectRef {
|
||||
}
|
||||
|
||||
pub fn syntax_err(err: CompileError) -> SyntaxError {
|
||||
let js_err = SyntaxError::new(&format!("Error parsing Python code: {}", err));
|
||||
let js_err = SyntaxError::new(&format!("Error parsing Python code: {err}"));
|
||||
let _ = Reflect::set(&js_err, &"row".into(), &(err.location.row() as u32).into());
|
||||
let _ = Reflect::set(
|
||||
&js_err,
|
||||
|
||||
@@ -160,7 +160,7 @@ mod _js {
|
||||
.map(PyJsValue::new)
|
||||
.map_err(|err| new_js_error(vm, err))
|
||||
} else {
|
||||
Err(vm.new_attribute_error(format!("No attribute {:?} on JS value", name)))
|
||||
Err(vm.new_attribute_error(format!("No attribute {name:?} on JS value")))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user