Fixed the 'useless_format' clippy warning

This replaces all the occurrences of the format!(<&str>) with the <&str>.to_string()

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
This commit is contained in:
ZapAnton
2019-02-04 22:33:25 +03:00
parent 7941480fca
commit 57e2beef3a
5 changed files with 18 additions and 18 deletions

View File

@@ -27,7 +27,7 @@ pub fn copy_code(code_obj: &PyObjectRef) -> bytecode::CodeObject {
fn code_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(_cls, None)]);
Err(vm.new_type_error(format!("Cannot directly create code object")))
Err(vm.new_type_error("Cannot directly create code object".to_string()))
}
fn code_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
@@ -43,7 +43,7 @@ fn code_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
};
// TODO: fetch proper line info from code object
let line = format!(", line 1");
let line = ", line 1".to_string();
let repr = format!("<code object at .. {}{}>", file, line);
Ok(vm.new_str(repr))

View File

@@ -19,12 +19,12 @@ pub fn init(context: &PyContext) {
fn frame_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(_cls, None)]);
Err(vm.new_type_error(format!("Cannot directly create frame object")))
Err(vm.new_type_error("Cannot directly create frame object".to_string()))
}
fn frame_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(_frame, Some(vm.ctx.frame_type()))]);
let repr = format!("<frame object at .. >");
let repr = "<frame object at .. >".to_string();
Ok(vm.new_str(repr))
}

View File

@@ -53,9 +53,9 @@ fn super_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
// Check obj type:
if !(objtype::isinstance(&py_obj, &py_type) || objtype::issubclass(&py_obj, &py_type)) {
return Err(vm.new_type_error(format!(
"super(type, obj): obj must be an instance or subtype of type"
)));
return Err(vm.new_type_error(
"super(type, obj): obj must be an instance or subtype of type".to_string(),
));
}
// TODO: how to store those types?

View File

@@ -1037,13 +1037,13 @@ impl PyObject {
dict: ref _dict,
mro: _,
} => format!("<class '{}'>", name),
PyObjectPayload::Instance { dict: _ } => format!("<instance>"),
PyObjectPayload::Code { code: _ } => format!("<code>"),
PyObjectPayload::Function { .. } => format!("<func>"),
PyObjectPayload::Generator { .. } => format!("<generator>"),
PyObjectPayload::Frame { .. } => format!("<frame>"),
PyObjectPayload::BoundMethod { .. } => format!("<bound-method>"),
PyObjectPayload::RustFunction { function: _ } => format!("<rustfunc>"),
PyObjectPayload::Instance { dict: _ } => "<instance>".to_string(),
PyObjectPayload::Code { code: _ } => "<code>".to_string(),
PyObjectPayload::Function { .. } => "<func>".to_string(),
PyObjectPayload::Generator { .. } => "<generator>".to_string(),
PyObjectPayload::Frame { .. } => "<frame>".to_string(),
PyObjectPayload::BoundMethod { .. } => "<bound-method>".to_string(),
PyObjectPayload::RustFunction { function: _ } => "<rustfunc>".to_string(),
PyObjectPayload::Module { ref name, dict: _ } => format!("<module '{}'>", name),
PyObjectPayload::Scope { ref scope } => format!("<scope '{:?}'>", scope),
PyObjectPayload::Slice {

View File

@@ -76,7 +76,7 @@ fn pack_bool(
data.write_u8(v).unwrap();
Ok(())
} else {
Err(vm.new_type_error(format!("Expected boolean")))
Err(vm.new_type_error("Expected boolean".to_string()))
}
}
@@ -150,7 +150,7 @@ fn pack_f32(
data.write_f32::<LittleEndian>(v).unwrap();
Ok(())
} else {
Err(vm.new_type_error(format!("Expected float")))
Err(vm.new_type_error("Expected float".to_string()))
}
}
@@ -164,7 +164,7 @@ fn pack_f64(
data.write_f64::<LittleEndian>(v).unwrap();
Ok(())
} else {
Err(vm.new_type_error(format!("Expected float")))
Err(vm.new_type_error("Expected float".to_string()))
}
}
@@ -216,7 +216,7 @@ fn struct_pack(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
)))
}
} else {
Err(vm.new_type_error(format!("First argument must be of str type")))
Err(vm.new_type_error("First argument must be of str type".to_string()))
}
}
}