Skip to content

Commit 69e3571

Browse files
Merge pull request RustPython#341 from ZapAnton/toplevel_ref_arg
Fixed the 'toplevel_ref_arg' clippy warning
2 parents 3fb0f32 + 0d3b218 commit 69e3571

22 files changed

+28
-27
lines changed

vm/src/obj/objbool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ pub fn boolval(vm: &mut VirtualMachine, obj: PyObjectRef) -> Result<bool, PyObje
3030
}
3131

3232
pub fn init(context: &PyContext) {
33-
let ref bool_type = context.bool_type;
3433
let bool_doc = "bool(x) -> bool
3534
3635
Returns True when the argument x is true, False otherwise.
3736
The builtins True and False are the only two instances of the class bool.
3837
The class bool is a subclass of the class int, and cannot be subclassed.";
3938

39+
let bool_type = &context.bool_type;
4040
context.set_attr(&bool_type, "__new__", context.new_rustfunc(bool_new));
4141
context.set_attr(&bool_type, "__repr__", context.new_rustfunc(bool_repr));
4242
context.set_attr(&bool_type, "__doc__", context.new_str(bool_doc.to_string()));

vm/src/obj/objbytearray.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use num_traits::ToPrimitive;
1616

1717
/// Fill bytearray class methods dictionary.
1818
pub fn init(context: &PyContext) {
19-
let ref bytearray_type = context.bytearray_type;
19+
let bytearray_type = &context.bytearray_type;
2020
context.set_attr(
2121
&bytearray_type,
2222
"__eq__",

vm/src/obj/objbytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::ops::Deref;
1414

1515
// Fill bytes class methods:
1616
pub fn init(context: &PyContext) {
17-
let ref bytes_type = context.bytes_type;
17+
let bytes_type = &context.bytes_type;
1818
context.set_attr(bytes_type, "__eq__", context.new_rustfunc(bytes_eq));
1919
context.set_attr(bytes_type, "__hash__", context.new_rustfunc(bytes_hash));
2020
context.set_attr(bytes_type, "__new__", context.new_rustfunc(bytes_new));

vm/src/obj/objcode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::super::vm::VirtualMachine;
1010
use super::objtype;
1111

1212
pub fn init(context: &PyContext) {
13-
let ref code_type = context.code_type;
13+
let code_type = &context.code_type;
1414
context.set_attr(code_type, "__new__", context.new_rustfunc(code_new));
1515
context.set_attr(code_type, "__repr__", context.new_rustfunc(code_repr));
1616
}

vm/src/obj/objcomplex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::objtype;
77
use num_complex::Complex64;
88

99
pub fn init(context: &PyContext) {
10-
let ref complex_type = context.complex_type;
10+
let complex_type = &context.complex_type;
1111
context.set_attr(&complex_type, "__add__", context.new_rustfunc(complex_add));
1212
context.set_attr(&complex_type, "__new__", context.new_rustfunc(complex_new));
1313
context.set_attr(

vm/src/obj/objdict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub fn create_type(type_type: PyObjectRef, object_type: PyObjectRef, dict_type:
284284
}
285285

286286
pub fn init(context: &PyContext) {
287-
let ref dict_type = context.dict_type;
287+
let dict_type = &context.dict_type;
288288
context.set_attr(&dict_type, "__len__", context.new_rustfunc(dict_len));
289289
context.set_attr(
290290
&dict_type,

vm/src/obj/objfloat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn float_pow(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
267267
}
268268

269269
pub fn init(context: &PyContext) {
270-
let ref float_type = context.float_type;
270+
let float_type = &context.float_type;
271271
context.set_attr(&float_type, "__eq__", context.new_rustfunc(float_eq));
272272
context.set_attr(&float_type, "__lt__", context.new_rustfunc(float_lt));
273273
context.set_attr(&float_type, "__le__", context.new_rustfunc(float_le));

vm/src/obj/objframe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::super::vm::VirtualMachine;
1010
use super::objtype;
1111

1212
pub fn init(context: &PyContext) {
13-
let ref frame_type = context.frame_type;
13+
let frame_type = &context.frame_type;
1414
context.set_attr(&frame_type, "__new__", context.new_rustfunc(frame_new));
1515
context.set_attr(&frame_type, "__repr__", context.new_rustfunc(frame_repr));
1616
context.set_attr(&frame_type, "f_locals", context.new_property(frame_flocals));

vm/src/obj/objfunction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ use super::super::vm::VirtualMachine;
66
use super::objtype;
77

88
pub fn init(context: &PyContext) {
9-
let ref function_type = context.function_type;
9+
let function_type = &context.function_type;
1010
context.set_attr(&function_type, "__get__", context.new_rustfunc(bind_method));
1111

12-
let ref member_descriptor_type = context.member_descriptor_type;
12+
let member_descriptor_type = &context.member_descriptor_type;
1313
context.set_attr(
1414
&member_descriptor_type,
1515
"__get__",
1616
context.new_rustfunc(member_get),
1717
);
1818

19-
let ref classmethod_type = context.classmethod_type;
19+
let classmethod_type = &context.classmethod_type;
2020
context.set_attr(
2121
&classmethod_type,
2222
"__get__",
@@ -28,7 +28,7 @@ pub fn init(context: &PyContext) {
2828
context.new_rustfunc(classmethod_new),
2929
);
3030

31-
let ref staticmethod_type = context.staticmethod_type;
31+
let staticmethod_type = &context.staticmethod_type;
3232
context.set_attr(
3333
staticmethod_type,
3434
"__get__",

vm/src/obj/objgenerator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::super::vm::VirtualMachine;
1010
use super::objtype;
1111

1212
pub fn init(context: &PyContext) {
13-
let ref generator_type = context.generator_type;
13+
let generator_type = &context.generator_type;
1414
context.set_attr(
1515
&generator_type,
1616
"__iter__",

vm/src/obj/objint.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ fn int_conjugate(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
506506
}
507507

508508
pub fn init(context: &PyContext) {
509-
let ref int_type = context.int_type;
510509
let int_doc = "int(x=0) -> integer
511510
int(x, base=10) -> integer
512511
@@ -521,6 +520,8 @@ by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
521520
Base 0 means to interpret the base from the string as an integer literal.
522521
>>> int('0b100', base=0)
523522
4";
523+
let int_type = &context.int_type;
524+
524525
context.set_attr(&int_type, "__eq__", context.new_rustfunc(int_eq));
525526
context.set_attr(&int_type, "__lt__", context.new_rustfunc(int_lt));
526527
context.set_attr(&int_type, "__le__", context.new_rustfunc(int_le));

vm/src/obj/objiter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn iter_next(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
141141
}
142142

143143
pub fn init(context: &PyContext) {
144-
let ref iter_type = context.iter_type;
144+
let iter_type = &context.iter_type;
145145
context.set_attr(
146146
&iter_type,
147147
"__contains__",

vm/src/obj/objlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ fn list_pop(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
365365
}
366366

367367
pub fn init(context: &PyContext) {
368-
let ref list_type = context.list_type;
368+
let list_type = &context.list_type;
369369
context.set_attr(&list_type, "__add__", context.new_rustfunc(list_add));
370370
context.set_attr(
371371
&list_type,

vm/src/obj/objmemory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn new_memory_view(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
1717
}
1818

1919
pub fn init(ctx: &PyContext) {
20-
let ref memoryview_type = ctx.memoryview_type;
20+
let memoryview_type = &ctx.memoryview_type;
2121
ctx.set_attr(
2222
&memoryview_type,
2323
"__new__",

vm/src/obj/objobject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn object_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
8686
}
8787

8888
pub fn init(context: &PyContext) {
89-
let ref object = context.object;
89+
let object = &context.object;
9090
context.set_attr(&object, "__new__", context.new_rustfunc(new_instance));
9191
context.set_attr(&object, "__init__", context.new_rustfunc(object_init));
9292
context.set_attr(&object, "__eq__", context.new_rustfunc(object_eq));

vm/src/obj/objproperty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::super::vm::VirtualMachine;
99
use super::objtype;
1010

1111
pub fn init(context: &PyContext) {
12-
let ref property_type = context.property_type;
12+
let property_type = &context.property_type;
1313
context.set_attr(
1414
&property_type,
1515
"__get__",

vm/src/obj/objset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn frozenset_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
151151
}
152152

153153
pub fn init(context: &PyContext) {
154-
let ref set_type = context.set_type;
154+
let set_type = &context.set_type;
155155
context.set_attr(
156156
&set_type,
157157
"__contains__",
@@ -162,7 +162,7 @@ pub fn init(context: &PyContext) {
162162
context.set_attr(&set_type, "__repr__", context.new_rustfunc(set_repr));
163163
context.set_attr(&set_type, "add", context.new_rustfunc(set_add));
164164

165-
let ref frozenset_type = context.frozenset_type;
165+
let frozenset_type = &context.frozenset_type;
166166
context.set_attr(
167167
&frozenset_type,
168168
"__contains__",

vm/src/obj/objstr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern crate unicode_segmentation;
1616
use self::unicode_segmentation::UnicodeSegmentation;
1717

1818
pub fn init(context: &PyContext) {
19-
let ref str_type = context.str_type;
19+
let str_type = &context.str_type;
2020
context.set_attr(&str_type, "__add__", context.new_rustfunc(str_add));
2121
context.set_attr(&str_type, "__eq__", context.new_rustfunc(str_eq));
2222
context.set_attr(

vm/src/obj/objsuper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::super::vm::VirtualMachine;
1111
use super::objtype;
1212

1313
pub fn init(context: &PyContext) {
14-
let ref super_type = context.super_type;
14+
let super_type = &context.super_type;
1515
context.set_attr(&super_type, "__init__", context.new_rustfunc(super_init));
1616
}
1717

vm/src/obj/objtuple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn tuple_contains(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
275275
}
276276

277277
pub fn init(context: &PyContext) {
278-
let ref tuple_type = context.tuple_type;
278+
let tuple_type = &context.tuple_type;
279279
context.set_attr(&tuple_type, "__add__", context.new_rustfunc(tuple_add));
280280
context.set_attr(&tuple_type, "__eq__", context.new_rustfunc(tuple_eq));
281281
context.set_attr(

vm/src/obj/objtype.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn create_type(type_type: PyObjectRef, object_type: PyObjectRef, dict_type:
2222
}
2323

2424
pub fn init(context: &PyContext) {
25-
let ref type_type = context.type_type;
25+
let type_type = &context.type_type;
2626
context.set_attr(&type_type, "__call__", context.new_rustfunc(type_call));
2727
context.set_attr(&type_type, "__new__", context.new_rustfunc(type_new));
2828
context.set_attr(
@@ -253,7 +253,7 @@ fn take_next_base(
253253
}
254254

255255
if let Some(head) = next {
256-
for ref mut item in &mut bases {
256+
for item in &mut bases {
257257
if item[0].get_id() == head.get_id() {
258258
item.remove(0);
259259
}

vm/src/pyobject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ impl AttributeProtocol for PyObjectRef {
700700
if let Some(item) = class_get_item(self, attr_name) {
701701
return Some(item);
702702
}
703-
for ref class in mro {
703+
for class in mro {
704704
if let Some(item) = class_get_item(class, attr_name) {
705705
return Some(item);
706706
}

0 commit comments

Comments
 (0)