Skip to content

Commit 2c693d9

Browse files
Merge pull request RustPython#336 from ZapAnton/fix_redundant_field_names
Fixed the 'redundant_field_names' clippy warnings
2 parents a262791 + 040a377 commit 2c693d9

File tree

15 files changed

+45
-53
lines changed

15 files changed

+45
-53
lines changed

vm/src/builtins.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn builtin_eval(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
238238
// TODO: handle optional globals
239239
// Construct new scope:
240240
let scope_inner = Scope {
241-
locals: locals,
241+
locals,
242242
parent: None,
243243
};
244244
let scope = PyObject {
@@ -288,7 +288,7 @@ fn builtin_exec(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
288288

289289
// Construct new scope:
290290
let scope_inner = Scope {
291-
locals: locals,
291+
locals,
292292
parent: None,
293293
};
294294
let scope = PyObject {

vm/src/bytecode.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ impl CodeObject {
4040
instructions: Vec::new(),
4141
label_map: HashMap::new(),
4242
locations: Vec::new(),
43-
arg_names: arg_names,
44-
varargs: varargs,
45-
kwonlyarg_names: kwonlyarg_names,
46-
varkeywords: varkeywords,
47-
source_path: source_path,
48-
obj_name: obj_name,
43+
arg_names,
44+
varargs,
45+
kwonlyarg_names,
46+
varkeywords,
47+
source_path,
48+
obj_name,
4949
is_generator: false,
5050
}
5151
}

vm/src/compile.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn compile(
5353
let code = compiler.pop_code_object();
5454
trace!("Compilation completed: {:?}", code);
5555
Ok(PyObject::new(
56-
PyObjectPayload::Code { code: code },
56+
PyObjectPayload::Code { code },
5757
vm.ctx.code_type(),
5858
))
5959
}
@@ -432,7 +432,7 @@ impl Compiler {
432432

433433
self.prepare_decorators(decorator_list)?;
434434
self.emit(Instruction::LoadConst {
435-
value: bytecode::Constant::Code { code: code },
435+
value: bytecode::Constant::Code { code },
436436
});
437437
self.emit(Instruction::LoadConst {
438438
value: bytecode::Constant::String {
@@ -441,7 +441,7 @@ impl Compiler {
441441
});
442442

443443
// Turn code object into function object:
444-
self.emit(Instruction::MakeFunction { flags: flags });
444+
self.emit(Instruction::MakeFunction { flags });
445445
self.apply_decorators(decorator_list);
446446

447447
self.emit(Instruction::StoreName {
@@ -477,7 +477,7 @@ impl Compiler {
477477

478478
let code = self.pop_code_object();
479479
self.emit(Instruction::LoadConst {
480-
value: bytecode::Constant::Code { code: code },
480+
value: bytecode::Constant::Code { code },
481481
});
482482
self.emit(Instruction::LoadConst {
483483
value: bytecode::Constant::String {
@@ -905,23 +905,23 @@ impl Compiler {
905905
let size = elements.len();
906906
let must_unpack = self.gather_elements(elements)?;
907907
self.emit(Instruction::BuildList {
908-
size: size,
908+
size,
909909
unpack: must_unpack,
910910
});
911911
}
912912
ast::Expression::Tuple { elements } => {
913913
let size = elements.len();
914914
let must_unpack = self.gather_elements(elements)?;
915915
self.emit(Instruction::BuildTuple {
916-
size: size,
916+
size,
917917
unpack: must_unpack,
918918
});
919919
}
920920
ast::Expression::Set { elements } => {
921921
let size = elements.len();
922922
let must_unpack = self.gather_elements(elements)?;
923923
self.emit(Instruction::BuildSet {
924-
size: size,
924+
size,
925925
unpack: must_unpack,
926926
});
927927
}
@@ -932,7 +932,7 @@ impl Compiler {
932932
self.compile_expression(value)?;
933933
}
934934
self.emit(Instruction::BuildMap {
935-
size: size,
935+
size,
936936
unpack: false,
937937
});
938938
}
@@ -941,7 +941,7 @@ impl Compiler {
941941
for element in elements {
942942
self.compile_expression(element)?;
943943
}
944-
self.emit(Instruction::BuildSlice { size: size });
944+
self.emit(Instruction::BuildSlice { size });
945945
}
946946
ast::Expression::Yield { value } => {
947947
self.mark_generator();
@@ -1003,13 +1003,13 @@ impl Compiler {
10031003
self.emit(Instruction::ReturnValue);
10041004
let code = self.pop_code_object();
10051005
self.emit(Instruction::LoadConst {
1006-
value: bytecode::Constant::Code { code: code },
1006+
value: bytecode::Constant::Code { code },
10071007
});
10081008
self.emit(Instruction::LoadConst {
10091009
value: bytecode::Constant::String { value: name },
10101010
});
10111011
// Turn code object into function object:
1012-
self.emit(Instruction::MakeFunction { flags: flags });
1012+
self.emit(Instruction::MakeFunction { flags });
10131013
}
10141014
ast::Expression::Comprehension { kind, generators } => {
10151015
self.compile_comprehension(kind, generators)?;
@@ -1286,7 +1286,7 @@ impl Compiler {
12861286

12871287
// List comprehension code:
12881288
self.emit(Instruction::LoadConst {
1289-
value: bytecode::Constant::Code { code: code },
1289+
value: bytecode::Constant::Code { code },
12901290
});
12911291

12921292
// List comprehension function name:

vm/src/frame.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Frame {
7676
blocks: vec![],
7777
// save the callargs as locals
7878
// globals: locals.clone(),
79-
locals: locals,
79+
locals,
8080
lasti: 0,
8181
}
8282
}
@@ -440,7 +440,7 @@ impl Frame {
440440
bytecode::CallType::Positional(count) => {
441441
let args: Vec<PyObjectRef> = self.pop_multiple(*count);
442442
PyFuncArgs {
443-
args: args,
443+
args,
444444
kwargs: vec![],
445445
}
446446
}

vm/src/obj/objbytearray.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ fn bytearray_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
6363
} else {
6464
vec![]
6565
};
66-
Ok(PyObject::new(
67-
PyObjectPayload::Bytes { value: value },
68-
cls.clone(),
69-
))
66+
Ok(PyObject::new(PyObjectPayload::Bytes { value }, cls.clone()))
7067
}
7168

7269
fn bytesarray_len(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {

vm/src/obj/objbytes.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ fn bytes_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
4848
vec![]
4949
};
5050

51-
Ok(PyObject::new(
52-
PyObjectPayload::Bytes { value: value },
53-
cls.clone(),
54-
))
51+
Ok(PyObject::new(PyObjectPayload::Bytes { value }, cls.clone()))
5552
}
5653

5754
fn bytes_eq(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {

vm/src/obj/objgenerator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn init(context: &PyContext) {
3030

3131
pub fn new_generator(vm: &mut VirtualMachine, frame: Frame) -> PyResult {
3232
let g = PyObject::new(
33-
PyObjectPayload::Generator { frame: frame },
33+
PyObjectPayload::Generator { frame },
3434
vm.ctx.generator_type.clone(),
3535
);
3636
Ok(g)

vm/src/obj/objlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn list_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
5252
};
5353

5454
Ok(PyObject::new(
55-
PyObjectPayload::Sequence { elements: elements },
55+
PyObjectPayload::Sequence { elements },
5656
cls.clone(),
5757
))
5858
}

vm/src/obj/objobject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn new_instance(vm: &mut VirtualMachine, mut args: PyFuncArgs) -> PyResult {
1212
// more or less __new__ operator
1313
let type_ref = args.shift();
1414
let dict = vm.new_dict();
15-
let obj = PyObject::new(PyObjectPayload::Instance { dict: dict }, type_ref.clone());
15+
let obj = PyObject::new(PyObjectPayload::Instance { dict }, type_ref.clone());
1616
Ok(obj)
1717
}
1818

vm/src/obj/objset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn set_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
8282
};
8383

8484
Ok(PyObject::new(
85-
PyObjectPayload::Set { elements: elements },
85+
PyObjectPayload::Set { elements },
8686
cls.clone(),
8787
))
8888
}

vm/src/obj/objtuple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn tuple_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
206206
};
207207

208208
Ok(PyObject::new(
209-
PyObjectPayload::Sequence { elements: elements },
209+
PyObjectPayload::Sequence { elements },
210210
cls.clone(),
211211
))
212212
}

vm/src/obj/objtype.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ pub fn new(typ: PyObjectRef, name: &str, bases: Vec<PyObjectRef>, dict: PyObject
285285
Ok(PyObject::new(
286286
PyObjectPayload::Class {
287287
name: String::from(name),
288-
dict: dict,
289-
mro: mro,
288+
dict,
289+
mro,
290290
},
291291
typ,
292292
))

vm/src/pyobject.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ impl PyContext {
249249
filter_type,
250250
map_type,
251251
dict_type,
252-
none: none,
253-
str_type: str_type,
254-
range_type: range_type,
252+
none,
253+
str_type,
254+
range_type,
255255
object: object_type,
256256
function_type,
257257
super_type,
@@ -463,7 +463,7 @@ impl PyContext {
463463

464464
pub fn new_set(&self, elements: Vec<PyObjectRef>) -> PyObjectRef {
465465
let elements = objset::sequence_to_hashmap(&elements);
466-
PyObject::new(PyObjectPayload::Set { elements: elements }, self.set_type())
466+
PyObject::new(PyObjectPayload::Set { elements }, self.set_type())
467467
}
468468

469469
pub fn new_dict(&self) -> PyObjectRef {
@@ -481,9 +481,7 @@ impl PyContext {
481481

482482
pub fn new_scope(&self, parent: Option<PyObjectRef>) -> PyObjectRef {
483483
let locals = self.new_dict();
484-
485484
let scope = Scope { locals, parent };
486-
487485
PyObject {
488486
payload: PyObjectPayload::Scope { scope },
489487
typ: None,
@@ -524,7 +522,7 @@ impl PyContext {
524522
}
525523

526524
pub fn new_frame(&self, frame: Frame) -> PyObjectRef {
527-
PyObject::new(PyObjectPayload::Frame { frame: frame }, self.frame_type())
525+
PyObject::new(PyObjectPayload::Frame { frame }, self.frame_type())
528526
}
529527

530528
pub fn new_property<F: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>(
@@ -555,8 +553,8 @@ impl PyContext {
555553
PyObject::new(
556554
PyObjectPayload::Function {
557555
code: code_obj,
558-
scope: scope,
559-
defaults: defaults,
556+
scope,
557+
defaults,
560558
},
561559
self.function_type(),
562560
)
@@ -579,7 +577,7 @@ impl PyContext {
579577
}
580578

581579
pub fn new_instance(&self, dict: PyObjectRef, class: PyObjectRef) -> PyObjectRef {
582-
PyObject::new(PyObjectPayload::Instance { dict: dict }, class)
580+
PyObject::new(PyObjectPayload::Instance { dict }, class)
583581
}
584582

585583
// Item set/get:
@@ -987,7 +985,7 @@ impl PyObject {
987985
/* dict: PyObjectRef,*/ typ: PyObjectRef,
988986
) -> PyObjectRef {
989987
PyObject {
990-
payload: payload,
988+
payload,
991989
typ: Some(typ),
992990
// dict: HashMap::new(), // dict,
993991
}

vm/src/stdlib/weakref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn ref_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
2828
arg_check!(vm, args, required = [(cls, None), (referent, None)]);
2929
let referent = Rc::downgrade(referent);
3030
Ok(PyObject::new(
31-
PyObjectPayload::WeakRef { referent: referent },
31+
PyObjectPayload::WeakRef { referent },
3232
cls.clone(),
3333
))
3434
}

vm/src/vm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ impl VirtualMachine {
5353

5454
let stdlib_inits = stdlib::get_module_inits();
5555
VirtualMachine {
56-
builtins: builtins,
56+
builtins,
5757
sys_module: sysmod,
5858
stdlib_inits,
59-
ctx: ctx,
59+
ctx,
6060
current_frame: None,
6161
}
6262
}
@@ -86,7 +86,7 @@ impl VirtualMachine {
8686
let pymsg = self.new_str(msg);
8787
let args: Vec<PyObjectRef> = vec![pymsg];
8888
let args = PyFuncArgs {
89-
args: args,
89+
args,
9090
kwargs: vec![],
9191
};
9292

@@ -211,7 +211,7 @@ impl VirtualMachine {
211211
obj,
212212
method_name,
213213
PyFuncArgs {
214-
args: args,
214+
args,
215215
kwargs: vec![],
216216
},
217217
)

0 commit comments

Comments
 (0)