Skip to content

Commit 57e2bee

Browse files
committed
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
1 parent 7941480 commit 57e2bee

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

vm/src/obj/objcode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn copy_code(code_obj: &PyObjectRef) -> bytecode::CodeObject {
2727

2828
fn code_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
2929
arg_check!(vm, args, required = [(_cls, None)]);
30-
Err(vm.new_type_error(format!("Cannot directly create code object")))
30+
Err(vm.new_type_error("Cannot directly create code object".to_string()))
3131
}
3232

3333
fn code_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
@@ -43,7 +43,7 @@ fn code_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
4343
};
4444

4545
// TODO: fetch proper line info from code object
46-
let line = format!(", line 1");
46+
let line = ", line 1".to_string();
4747

4848
let repr = format!("<code object at .. {}{}>", file, line);
4949
Ok(vm.new_str(repr))

vm/src/obj/objframe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ pub fn init(context: &PyContext) {
1919

2020
fn frame_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
2121
arg_check!(vm, args, required = [(_cls, None)]);
22-
Err(vm.new_type_error(format!("Cannot directly create frame object")))
22+
Err(vm.new_type_error("Cannot directly create frame object".to_string()))
2323
}
2424

2525
fn frame_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
2626
arg_check!(vm, args, required = [(_frame, Some(vm.ctx.frame_type()))]);
27-
let repr = format!("<frame object at .. >");
27+
let repr = "<frame object at .. >".to_string();
2828
Ok(vm.new_str(repr))
2929
}
3030

vm/src/obj/objsuper.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ fn super_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
5353

5454
// Check obj type:
5555
if !(objtype::isinstance(&py_obj, &py_type) || objtype::issubclass(&py_obj, &py_type)) {
56-
return Err(vm.new_type_error(format!(
57-
"super(type, obj): obj must be an instance or subtype of type"
58-
)));
56+
return Err(vm.new_type_error(
57+
"super(type, obj): obj must be an instance or subtype of type".to_string(),
58+
));
5959
}
6060

6161
// TODO: how to store those types?

vm/src/pyobject.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,13 +1037,13 @@ impl PyObject {
10371037
dict: ref _dict,
10381038
mro: _,
10391039
} => format!("<class '{}'>", name),
1040-
PyObjectPayload::Instance { dict: _ } => format!("<instance>"),
1041-
PyObjectPayload::Code { code: _ } => format!("<code>"),
1042-
PyObjectPayload::Function { .. } => format!("<func>"),
1043-
PyObjectPayload::Generator { .. } => format!("<generator>"),
1044-
PyObjectPayload::Frame { .. } => format!("<frame>"),
1045-
PyObjectPayload::BoundMethod { .. } => format!("<bound-method>"),
1046-
PyObjectPayload::RustFunction { function: _ } => format!("<rustfunc>"),
1040+
PyObjectPayload::Instance { dict: _ } => "<instance>".to_string(),
1041+
PyObjectPayload::Code { code: _ } => "<code>".to_string(),
1042+
PyObjectPayload::Function { .. } => "<func>".to_string(),
1043+
PyObjectPayload::Generator { .. } => "<generator>".to_string(),
1044+
PyObjectPayload::Frame { .. } => "<frame>".to_string(),
1045+
PyObjectPayload::BoundMethod { .. } => "<bound-method>".to_string(),
1046+
PyObjectPayload::RustFunction { function: _ } => "<rustfunc>".to_string(),
10471047
PyObjectPayload::Module { ref name, dict: _ } => format!("<module '{}'>", name),
10481048
PyObjectPayload::Scope { ref scope } => format!("<scope '{:?}'>", scope),
10491049
PyObjectPayload::Slice {

vm/src/stdlib/pystruct.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn pack_bool(
7676
data.write_u8(v).unwrap();
7777
Ok(())
7878
} else {
79-
Err(vm.new_type_error(format!("Expected boolean")))
79+
Err(vm.new_type_error("Expected boolean".to_string()))
8080
}
8181
}
8282

@@ -150,7 +150,7 @@ fn pack_f32(
150150
data.write_f32::<LittleEndian>(v).unwrap();
151151
Ok(())
152152
} else {
153-
Err(vm.new_type_error(format!("Expected float")))
153+
Err(vm.new_type_error("Expected float".to_string()))
154154
}
155155
}
156156

@@ -164,7 +164,7 @@ fn pack_f64(
164164
data.write_f64::<LittleEndian>(v).unwrap();
165165
Ok(())
166166
} else {
167-
Err(vm.new_type_error(format!("Expected float")))
167+
Err(vm.new_type_error("Expected float".to_string()))
168168
}
169169
}
170170

@@ -216,7 +216,7 @@ fn struct_pack(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
216216
)))
217217
}
218218
} else {
219-
Err(vm.new_type_error(format!("First argument must be of str type")))
219+
Err(vm.new_type_error("First argument must be of str type".to_string()))
220220
}
221221
}
222222
}

0 commit comments

Comments
 (0)